0% found this document useful (0 votes)
726 views34 pages

ABAP 7.40 Quick Reference

The document provides a quick reference guide for ABAP 7.40 features including inline declarations, table expressions, conversion and value operators, FOR and REDUCE operators, conditional operators, and more. It gives examples of how code can be improved with ABAP 7.40 and references other useful resources on the topic.

Uploaded by

David Coelho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
726 views34 pages

ABAP 7.40 Quick Reference

The document provides a quick reference guide for ABAP 7.40 features including inline declarations, table expressions, conversion and value operators, FOR and REDUCE operators, conditional operators, and more. It gives examples of how code can be improved with ABAP 7.40 and references other useful resources on the topic.

Uploaded by

David Coelho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

GetStarted

Solutions

Partner

Community

Support

About

Training

Community

Developer

Blogs

ABAP7.40QuickReference
October25,2015

| 9,131Views |

JeffreyTowell
morebythisauthor

ABAPDevelopment
SAPNetWeaver | 740 | abap | document | overveiw | reference | sapnetweaver

share
0

share
14

tweet

share
34

Follow

SoyoureanexperiencedABAPprogrammerwantingtoleverageoff
thefantasticnewfunctionalityavailabletoyouinABAP7.40!

However,searchingforinformationonthistopicleadsyouto
fragmentedpagesorblogsthatrefertoonlyacoupleofthenew
featuresavailabletoyou.
Whatyouneedisaquickreferenceguidewhichgivesyouthe
essentialsyouneedandshowsyouhowthecodeyouarefamiliar
withcanbeimprovedwithABAP7.40.
Thebelowdocumentcontainsexactlythis!
[Link]
[Link]
[Link]

1/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

[Link]
documentdoesnotcontaineverythingpertainingtoABAP740it
certainlycoversthemostusefulpartsintheexperienceoftheauthor.
Thedocumenthasbeencompiledbydrawingonexistingmaterial
[Link]
theblogsbyHorstKellerhavebeenusefulandarethebestreference
Ihavefound(priortothisdocument).Hehasalandingpageofsorts
forhisvariousblogsonthetopichere:
ABAPLanguageNewsforRelease7.40
CreditalsogoestoNaimeshPatelforhisusefulexplanationsand
[Link]
expressionwhichIleanedon(linkstohisother740articlescanbe
foundatthebottomofthelink):
[Link]
IcompiledthebelowdocumenttomakethetransitiontousingABAP
[Link]
andIhopeitwilldothesameforyou.
Regards,
JeffTowell

ABAP7.40QuickReference
Author:

JeffreyTowell

Created:

2015

Contents
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]

[Link]

2/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

[Link]
[Link]
[Link]
[Link]
[Link]
III.Example1
IV.Example2
[Link]|WHILE
[Link]
[Link]
[Link]
III.Example1
IV.Example2
V.Example3
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]
[Link]/Alignment/Padding.

[Link]

3/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]/Methods
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
Description

Before7.40

Data

DATAtextTYPEstring.

DATA(text)=

statement

text=`ABC`.

Loopat

DATAwalikeLINEOFitab.

LOOPATitab

intowork

LOOPATitabINTOwa.

area

ENDLOOP.

ENDLOOP.
Call

DATAa1TYPE

oref>meth(

method

DATAa2TYPE

IMPORTINGp1=DATA(a1)

oref>meth(IMPORTINGp1=a1

IMPORTINGp2=DATA(a2)

IMPORTINGp2=a2
).
Loopat

FIELDSYMBOLS:<line>type

LOOPATitab

assigning

LOOPATitabASSIGNING<line>.

ASSIGNINGFIELDSYMBOL(<line>).

ENDLOOP.

ENDLOOP.

[Link]

4/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

Read

FIELDSYMBOLS:<line>type

READTABLEitab

assigning

READTABLEitab

ASSIGNINGFIELDSYMBOL(<line>).

ASSIGNING<line>.
Select

DATAitabTYPETABLEOFdbtab.

SELECT*FROMdbtab

into

SELECT*FROMdbtab

INTOTABLEDATA(itab)

INTOTABLEitab

WHEREfld1=@lv_fld1.

table

WHEREfld1=lv_fld1.

Select

SELECTSINGLEf1f2

SELECTSINGLEf1ASmy_f1,

single

FROMdbtab

F2ASabc

into

INTO(lv_f1,lv_f2)

FROMdbtab

WHERE

INTODATA(ls_structure)

WRITE:/lv_f1,lv_f2.

WHERE
WRITE:/ls_structure
my_f1,ls_structure
abc.

[Link]
Ifatablelineisnotfound,theexception
CX_SY_ITAB_LINE_NOT_FOUNDisraised.Nosysubrc.

Description

Read
Table
index
Read
Table
usingkey

Before7.40

READTABLEitabINDEXidx

wa=itab[idx].

INTOwa.
READTABLEitabINDEXidx

wa=itab[KEYkeyINDEXidx].

USINGKEYkey
INTOwa.

Read

READTABLEitab

Table

WITHKEYcol1=

withkey

col2=

wa=itab[col1=

INTOwa.
Read

READTABLEitab

wa=itab[KEYkeycol1=

Table

WITHTABLEKEYkey

col2=

withkey

COMPONENTScol1=

components

col2=
INTOwa.

Does

READTABLEitab

IFline_exists(itab[]).

record
[Link]

5/34

19/01/2017

exist?

ABAP7.40QuickReference|SAPBlogs

TRANSPORTINGNOFIELDS.

IFsysubrc=0.

ENDIF.

ENDIF.
Gettable
index

DATAidxtypesytabix.

DATA(idx)=
line_index(itab[

READTABLE
TRANSPORTINGNOFIELDS.
idx=sytabix.

NB:Therewillbeashortdumpifyouuseaninlineexpressionthat
referencesanonexistentrecord.
SAPsaysyoushouldthereforeassignafieldsymbolandcheck
sysubrc.
ASSIGNlt_tab[1]toFIELDSYMBOL(<ls_tab>).
IFsysubrc=0.

ENDIF.

NB:Useitab[table_line=]foruntypedtables.

[Link]
[Link]
CONVdtype|#()
dtype=Typeyouwanttoconvertto(explicit)
#=compilermustusethecontexttodecidethe
typetoconvertto(implicit)

[Link]
Methodcl_abap_codepage=>convert_toexpectsastring
Before7.40

[Link]

6/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

DATAtextTYPEcLENGTH255.
DATAhelperTYPEstring.
DATAxstrTYPExstring.
helper=text.
xstr=cl_abap_codepage=>convert_to(source=helper).
With7.40

DATAtextTYPEcLENGTH255.
DATA(xstr)=cl_abap_codepage=>convert_to(source=CONVstring(text)
OR
DATA(xstr)=cl_abap_codepage=>convert_to(source=CONV#(text)

[Link]
[Link]
Variables:VALUEdtype|#()
Structures:VALUEdtype|#(comp1=a1comp2=a2)
Tables:VALUEdtype|#(()())

[Link]
TYPES:BEGINOFty_columns1,Simplestructure
cols1TYPEi,
cols2TYPEi,
ENDOFty_columns1.
TYPES:BEGINOFty_columnns2,Nestedstructure
coln1TYPEi,
coln2TYPEty_columns1,
ENDOFty_columns2.
DATA:struc_simpleTYPEty_columns1,
struc_nestTYPEty_columns2.
struct_nest=VALUEt_struct(coln1=1
coln2cols1=1
coln2cols2=2).

OR

[Link]

7/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

struct_nest=VALUEt_struct(coln1=1
coln2=VALUE#(cols1=1
cols2=2)).

[Link]
Elementarylinetype:
TYPESt_itabTYPETABLEOFiWITHEMPTYKEY.

DATAitabTYPEt_itab.

itab=VALUE#(()(1)(2)).
Structuredlinetype(RANGEStable):
DATAitabTYPERANGEOFi.

itab=VALUE#(sign=Ioption=BT(low=1
high=10)
(low=21high=30)
(low=41high=50)
option=GE(low=61)).

[Link]
[Link]
FORwa|<fs>INitab[INDEXINTOidx][cond]

[Link]
[Link]
assignedtoaworkarea(wa)orfieldsymbol(<fs>).
Thiswaor<fs>[Link]
subrourinethevariablewaor<fs>isalocalvariableof
[Link].

Given:
TYPES:BEGINOFty_ship,
tknumTYPEtknum,ShipmentNumber
nameTYPEernam,NameofPersonwho
[Link]

8/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

CreatedtheObject
cityTYPEort01,Startingcity
routeTYPEroute,Shipmentroute
ENDOFty_ship.
TYPES:ty_shipsTYPESORTEDTABLEOFty_shipWITH
UNIQUEKEYtknum.
TYPES:ty_citysTYPESTANDARDTABLEOFort01WITHEMPTY
KEY.
GT_SHIPStypety_ships.>hasbeenpopulatedas
follows:
Row TKNUM[C(10)] Name[C(12)] City[C(25)] Route[C(6)]
1

001

John

Melbourne R0001

002

Gavin

Sydney

R0003

003

Lucy

Adelaide

R0001

004

Elaine

Perth

R0003

III.Example1
PopulateinternaltableGT_CITYSwiththecitiesfrom
GT_SHIPS.
Before7.40

DATA:gt_citysTYPEty_citys,
gs_shipTYPEty_ship,
gs_cityTYPEort01.

LOOPATgt_shipsINTOgs_ship.
gs_city=gs_shipcity.
APPENDgs_cityTOgt_citys.
ENDLOOP.
With7.40

DATA(gt_citys)=VALUEty_citys(FORls_shipINgt_ships

IV.Example2
PopulateinternaltableGT_CITYSwiththecitiesfrom
GT_SHIPSwheretherouteisR0001.

[Link]

9/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

Before7.40

DATA:gt_citysTYPEty_citys,
gs_shipTYPEty_ship,
gs_cityTYPEort01.

LOOPATgt_shipsINTOgs_shipWHEREroute=R0001.
gs_city=gs_shipcity.
APPENDgs_cityTOgt_citys.
ENDLOOP.
With7.40

DATA(gt_citys)=VALUEty_citys(FORls_shipINgt_ships
WHERE(route=R0001

Note:ls_shipdoesnotappeartohavebeendeclaredbutitis
declaredimplicitly.

[Link]|WHILE
FORi=[THENexpr]UNTIL|WHILElog_exp
Populateaninternaltableasfollows:
TYPES:
BEGINOFty_line,
col1TYPEi,
col2TYPEi,
col3TYPEi,
ENDOFty_line,
ty_tabTYPESTANDARDTABLEOFty_lineWITHEMPTYKEY.
Before7.40

[Link]

10/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

DATA:gt_itabTYPEty_tab,
jTYPEi.
FIELDSYMBOLS<ls_tab>TYPEty_line.

j=1.
DO.
j=j+10.
IFj>[Link].
APPENDINITIALLINETOgt_itabASSIGNING<ls_tab>.
<ls_tab>col1=j.
<ls_tab>col2=j+1.
<ls_tab>col3=j+2.
ENDDO.
With7.40

DATA(gt_itab)=VALUEty_tab(FORj=11THENj+10UNTILj>
(col1=jcol2=j+1col3

[Link]
[Link]
REDUCEtype(
INITresult=start_value

FORfor_exp1
FORfor_exp2

NEXT
result=iterated_value
)

[Link]
WhileVALUEandNEWexpressionscanincludeFORexpressions,
[Link]
kindsofFORexpressionsinREDUCE:
withINforiteratinginternaltables
withUNTILorWHILEforconditionaliterations

III.Example1
[Link]

11/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

Countlinesoftablethatmeetacondition(fieldF1containsXYZ).
Before7.40

DATA:lv_linesTYPEi.
LOOPATgt_itabINTOls_itabwhereF1=XYZ.
lv_lines=lv_lines+1.
ENDLOOP.
With7.40

DATA(lv_lines)=REDUCEi(INITx=0FORwaINgt_itab
WHERE(F1=XYZ)NEXTx=x+1

IV.Example2
Sumthevalues1to10storedinthecolumnofatabledefinedas
follows
DATAgt_itabTYPESTANDARDTABLEOFiWITHEMPTYKEY.
gt_itab=VALUE#(FORj=1WHILEj<=10(j)).
Before7.40

DATA:lv_lineTYPEi,
lv_sumTYPEi.
LOOPATgt_itabINTOlv_line.
lv_sum=lv_sum+lv_line.
ENDLOOP.
With7.40

DATA(lv_sum)=REDUCEi(INITx=0FORwaINitabNEXTx

V.Example3
Usingaclassreferenceworksbecausewritemethodreturns
referencetoinstanceobject
With7.40

[Link]

12/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

TYPESoutrefTYPEREFTOif_demo_output.

DATA(output)=REDUCEoutref(INITout=cl_demo_output
text=`Countup:`
FORn=1UNTILn>11
NEXTout=out>write(text
text=|{n}|).

output>display().

[Link]
[Link]
CONDdtype|#(WHENlog_exp1THENresult1
[WHENlog_exp2THENresult2]

[ELSEresultn])
SWITCHdtype|#(operand
WHENconst1THENresult1
[WHENconst2THENresult2]

[ELSEresultn])

[Link]
DATA(time)=
CONDstring(
WHENsytimlo<120000THEN
|{sytimloTIME=ISO}AM|
WHENsytimlo>120000THEN
|{CONVt(sytimlo12*3600)
TIME=ISO}PM|
WHENsytimlo=120000THEN
|HighNoon|
ELSE
THROWcx_cant_be()).

[Link]
DATA(text)=
NEWclass()>meth(
SWITCH#(sylangu
[Link]

13/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

WHENDTHEN`DE`
WHENETHEN`EN`
ELSETHROW
cx_langu_not_supported())).

[Link]
[Link]
CORRESPONDINGtype([BASE(base)]struct|itab
[mapping|except])

[Link]
With7.40

[Link]

14/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

TYPES:BEGINOFline1,col1TYPEi,col2TYPEi,ENDOF
TYPES:BEGINOFline2,col1TYPEi,col2TYPEi,col3TYPEi
DATA(ls_line1)=VALUEline1(col1=1col2=2).
WRITE:/ls_line1=,15ls_line1col1,ls_line1col2.
DATA(ls_line2)=VALUEline2(col1=4col2=5col3=
WRITE:/ls_line2=,15ls_line2col1,ls_line2col2,
SKIP2.
ls_line2=CORRESPONDING#(ls_line1).
WRITE:/ls_line2=CORRESPONDING#(ls_line1)
,70Resultisls_line2=
,ls_line2col1,ls_line2col2,ls_line2col3.
SKIP.
ls_line2=VALUEline2(col1=4col2=5col3=6).
ls_line2=CORRESPONDING#(BASE(ls_line2)ls_line1
WRITE:/ls_line2=CORRESPONDING#(BASE(ls_line2)ls_line1)
,70Resultisls_line2=,ls_line2col1
,ls_line2col2,ls_line2col3.
SKIP.
ls_line2=VALUEline2(col1=4col2=5col3=6).
DATA(ls_line3)=CORRESPONDINGline2(BASE(ls_line2)
WRITE:/DATA(ls_line3)=CORRESPONDINGline2(BASE(ls_line2)ls_line1)
,70Resultisls_line3=,ls_line3col1
,ls_line3col2,ls_line3col3.

[Link]

[Link]
Givenstructuresls_line1&ls_line2definedandpopulatedasabove.
Before7.40

[Link]

15/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

CLEARls_line2.

ls_line2=CORRESPONDING#(ls_line1).

MOVECORRESPONDINGls_line1
TOls_line2.
MOVECORRESPONDINGls_line1

TOls_line2.
3

ls_line2=CORRESPONDING#
(BASE(ls_line2)ls_line1).

DATA:ls_line3likels_line2.

DATA(ls_line3)=

ls_line3=ls_line2.

(BASE(ls_line2)ls_line1).

MOVECORRESPONDINGls_line1
TOls_line2.

1.Thecontentsofls_line1aremovedtols_line2wherethereisa
[Link]

matchthecolumnofls_line2isinitialised.
2.Thisusestheexistingcontentsofls_line2asabaseandoverwritesthe

matchingcolumnsfromls_line1.
ThisisexactlylikeMOVECORRESPONDING.

[Link](ls_line3)whichisbasedon
ls_line2butoverwrittenbymatching
columnsofls_line1.

[Link]
MAPPINGallowsyoutomapfieldswithnonidenticallynamed
componentstoqualifyforthedatatransfer.
MAPPINGt1=s1t2=s2

EXCEPTallowsyoutolistfieldsthatmustbeexcludedfromthedata
transfer
EXCEPT{t1t2}

[Link]
[Link]
Astringtemplateisenclosedbytwocharacters|andcreatesacharacter
string.
[Link]

16/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

Literaltextconsistsofallcharactersthatarenotinbraces{}.Thebracescan
contain:
dataobjects,

calculationexpressions,

constructorexpressions,

tableexpressions,

predefinedfunctions,or

functionalmethodsandmethodchainings

Before7.40

DATAitabTYPETABLEOFscarr.
SELECT*FROMscarrINTOTABLEitab.
DATAwaLIKELINEOFitab.
READTABLEitabWITHKEYcarrid=LHINTOwa.
DATAoutputTYPEstring.
CONCATENATECarrier:wacarrnameINTOoutputSEPARATEDBYspace.
cl_demo_output=>display(output).
With7.40

SELECT*FROMscarrINTOTABLE@DATA(lt_scarr).
cl_demo_output=>display(|Carrier:{lt_scarr[carrid=

[Link]
Before7.40

DATAlv_outputTYPEstring.
CONCATENATEHelloworldINTOlv_outputSEPARATEDBY
With7.40

DATA(lv_out)=|Hello|&||&|world|.

[Link]/Alignment/Padding

[Link]

17/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

WRITE/|{LeftWIDTH=20ALIGN=LEFTPAD=
0}|.
WRITE/|{CentreWIDTH=20ALIGN=CENTERPAD=
0}|.
WRITE/|{RightWIDTH=20ALIGN=RIGHTPAD=
0}|.

[Link]
WRITE/|{TextCASE=(cl_abap_format=>c_raw)}|.
WRITE/|{TextCASE=(cl_abap_format=>c_upper)}|.
WRITE/|{TextCASE=(cl_abap_format=>c_lower)}|.

[Link]
DATA(lv_vbeln)=0000012345.
WRITE/|{lv_vbelnALPHA=OUT}|.oruseALPHA
=INtogoinotherdirection

[Link]
WRITE/|{pa_dateDATE=ISO}|.Date
FormatYYYYMMDD
WRITE/|{pa_dateDATE=User}|.Asper
usersettings
WRITE/|{pa_dateDATE=Environment}|.Formatting
settingoflanguageenvironment

[Link]
[Link]
LOOPATitab result [cond]GROUPBY key(key1=dobj1
key2=dobj2
[gs=GROUPSIZE][gi=GROUPINDEX])
[ASCENDING|DESCENDING[ASTEXT]]
[WITHOUTMEMBERS]
[{INTOgroup}|{ASSIGNING<group>}]

[LOOPATGROUPgroup|<group>

ENDLOOP.]

ENDLOOP.

[Link]

18/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

[Link]
Theouterloopwilldooneiterationperkey.Soif3recordsmatchthekey
[Link](or
<group>)isunusualinthatitcanbeloopedoverusingtheLOOPAT
GROUPstatement.Thiswillloopoverthe3records(members)ofthe
[Link]
structuregroupalsocontainsthecurrentkeyaswellasthesizeofthe
groupandindexofthegroup(ifGROUPSIZEandGROUPINDEXhave
been
assignedafieldname).Thisisbestunderstoodbyanexample.

[Link]
With7.40
TYPES:BEGINOFty_employee,
nameTYPEchar30,
roleTYPEchar30,
ageTYPEi,
ENDOFty_employee,
ty_employee_tTYPESTANDARDTABLEOFty_employeeWITHKEYname.
DATA(gt_employee)=VALUEty_employee_t(
(name=Johnrole=ABAPguruage=34)
(name=Alicerole=FIConsultantage=42)
(name=Barryrole=ABAPguruage=54)
(name=Maryrole=FIConsultantage=37)
(name=Arthurrole=ABAPguruage=34)
(name=Mandyrole=SDConsultantage=64)).
DATA:gv_tot_ageTYPEi,
gv_avg_ageTYPEdecfloat34.
LoopwithgroupingonRole
LOOPATgt_employeeINTODATA(ls_employee)
GROUPBY(role=ls_employeerole
size=GROUPSIZE

[Link]

19/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

index=GROUPINDEX)

With7.40

ASCENDING
ASSIGNINGFIELDSYMBOL(<group>).
CLEAR:gv_tot_age.
Outputinfoatgrouplevel
WRITE:/|Group:{<group>index}Role:{<group>roleWIDTH=15}|
&|Numberinthisrole:{<group>size}|.
Loopatmembersofthegroup
LOOPATGROUP<group>ASSIGNINGFIELDSYMBOL(<ls_member>).
gv_tot_age=gv_tot_age+<ls_member>age.
WRITE:/13<ls_member>name.
ENDLOOP.
Averageage
gv_avg_age=gv_tot_age/<group>size.
WRITE:/|Averageage:{gv_avg_age}|.
SKIP.
ENDLOOP.

[Link]
Group:1Role:ABAPguruNumberinthisrole:3
John
Barry
Arthur
Averageage:40.66666666666666666666666666666667
Group:2Role:FIConsultantNumberinthisrole:2
Alice
Mary
Averageage:39.5
Group:3Role:SDConsultantNumberinthisrole:1
Mandy
Averageage:64

[Link]/Methods
[Link]
Before7.40
[Link]

20/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

DATA:ls_lfa1TYPElfa1,
lv_name1TYPElfa1name1.

ls_lfa1=My_Class=>get_lfa1().
lv_name1=ls_lfa1name1.
With7.40

DATA(lv_name1)=My_Class=>get_lfa1()name1.

[Link]
Before7.40

IFMy_Class=>return_boolean()=abap_true.

ENDIF.
With7.40

IFMy_Class=>return_boolean().

ENDIF.

NB:ThetypeBOOLEANisnotatrueBooleanbutachar1with
allowedvaluesX,and<blank>.
UsingtypeFLAGorWDY_BOOLEANworksjustaswell.

[Link]
Thisoperatorcanbeusedtoinstantiateanobject.
Before7.40

DATA:lo_delivsTYPEREFTOzcl_sd_delivs,
lo_delivTYPEREFTOzcl_sd_deliv.

CREATEOBJECTlo_delivs.
CREATEOBJECTlo_deliv.
lo_deliv=lo_delivs>get_deliv(lv_vbeln).
With7.40

DATA(lo_deliv)=newzcl_sd_delivs()>get_deliv(lv_vbeln

[Link]
Allowsanassociationtobesetupbetweenrelateddatagroups.

[Link]
[Link]

21/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

Giventhefollowing2internaltables:
TYPES:BEGINOFt_manager,
nameTYPEchar10,
salaryTYPEint4,
ENDOFt_manager,
tt_managerTYPESORTEDTABLEOFt_managerWITHUNIQUEKEYname.

TYPES:BEGINOFt_developer,
nameTYPEchar10,
salaryTYPEint4,
managerTYPEchar10,Nameofmanager
ENDOFt_developer,
tt_developerTYPESORTEDTABLEOFt_developerWITHUNIQUEKEY
name.

Populatedasfollows:
Row Name[C(10)] Salary[I(4)]
1

Jason

3000

Thomas

3200

Row

Name[C(10)]

Salary[I(4) Manager[C(10)]

Bob

2100

Jason

David

2000

Thomas

Jack

1000

Thomas

Jerry

1000

Jason

John

2100

Thomas

Tom

2000

Jason

GetthedetailsofJerrysmanagerandalldevelopersmanagedby
Thomas.

[Link]
With7.40

[Link]

22/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

TYPES:BEGINOFMESHm_team,
managersTYPEtt_managerASSOCIATIONmy_employee
ONmanager=name,

developersTYPEtt_developerASSOCIATIONmy_manager
ONname=manager,

ENDOFMESHm_team.
DATA:ls_teamTYPEm_team.
ls_teammanagers=lt_manager.
ls_teamdevelopers=lt_developer.
*GetdetailsofJerrysmanager*
getlineofdevtable
ASSIGNlt_developer[name=Jerry]TOFIELDSYMBOL(<ls_jerry>
DATA(ls_jmanager)=ls_teamdevelopers\my_manager[<ls_jerry>]
WRITE:/|Jerrysmanager:{ls_jmanagername}|,30
|Salary:{ls_jmanagersalary}|.
GetThomasdevelopers
SKIP.
WRITE:/|Thomasdevelopers:|.
lineofmanagertable
ASSIGNlt_manager[name=Thomas]TOFIELDSYMBOL(<ls_thomas>
LOOPATls_teammanagers\my_employee[<ls_thomas>]
ASSIGNINGFIELDSYMBOL(<ls_emp>).
WRITE:/|Employeename:{<ls_emp>name}|.
ENDLOOP.

[Link]
Jerrysmanager:JasonSalary:3000
Thomasdevelopers:
Employeename:David
Employeename:Jack
Employeename:John

[Link]
Filtertherecordsinatablebasedonrecordsinanothertable.

[Link]
[Link]

23/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

FILTERtype(itab[EXCEPT][INftab][USINGKEYkeyname]
WHEREc1opf1[ANDc2opf2[]])

[Link]
FilteraninternaltableofFlightSchedules(SPFLI)toonlythoseflights
basedonafiltertablethatcontainsthefieldsCityfromandCityTo.

[Link]
With7.40

TYPES:BEGINOFty_filter,
cityfromTYPEspflicityfrom,
citytoTYPEspflicityto,
f3TYPEi,
ENDOFty_filter,
ty_filter_tabTYPEHASHEDTABLEOFty_filter
WITHUNIQUEKEYcityfromcityto.
DATA:lt_splfiTYPESTANDARDTABLEOFspfli.
SELECT*FROMspfliAPPENDINGTABLElt_splfi.
DATA(lt_filter)=VALUEty_filter_tab(f3=2
(cityfrom=NEWYORKcityto=SANFRANCISCO

(cityfrom=FRANKFURTcityto=NEWYORK
DATA(lt_myrecs)=FILTER#(lt_splfiINlt_filter
WHEREcityfrom=cityfrom
ANDcityto=cityto
Outputfilteredrecords
LOOPATlt_myrecsASSIGNINGFIELDSYMBOL(<ls_rec>).
WRITE:/<ls_rec>carrid,8<ls_rec>cityfrom,30
<ls_rec>cityto,45<ls_rec>deptime.
ENDLOOP.

Note:usingthekeywordEXCEPT(seedefinitionabove)wouldhave
[Link]
thosereturnedabove.

AlertModerator

[Link]

24/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

31Comments
YoumustbeLoggedontocommentorreplytoapost.

JitendraSoni
October25,2015at1:42pm

HiJeffrey,
Veryinformativeblog.

Belowsyntaxisnotworkingforme.

SELECT*FROMdbtabINTOTABLE@DATA(lt_dbtab)WHEREfield1=
@lv_field1.

ABAPversion:
SAP_BASIS 740 0007 SAPKB74007 0000 SAPBasisComponent
SAP_ABA

740 0007 SAPKA74007 0000 CrossApplicationComponent

JeffreyTowell Postauthor
October26,2015at8:42am

ThanksJitendra.
IamnotsurewhichbitsofABAP7.40comeinwithexactly
[Link]
workonyourboxthenitsfairtosayyoudonothavethe
relevantversionyet.

DATA:lv_bukrstypebukrsVALUE0001.

SELECT*FROMt001INTOTABLE@DATA(lt_t001)
WHEREbukrs=@lv_bukrs.

ChristianoJosBeltroMagalhes
October26,2015at12:20pm

HiJitendra/Jeffrey,

[Link]

25/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

thenewopensqlsyntaxwascreatedinABAP7.40SP05and
enhancedinSP08.MoreinformationinABAPNewsfor7.40,
SP08OpenSQL.

Jeffrey,greatblogveryuseful.

BR,
Christiano.

PaulBakker
October25,2015at9:52pm

Thanksforgoingtosomucheffort!Veryinterestingreading.

Unfortunatelysomeofthecode(insidetheblackborders)istruncatedonthe
[Link]

cheers
Paul

JeffreyTowell Postauthor
October26,2015at12:10am

ThanksforyourcommentsPaul.

Wasalsoconcernedabouttruncationontherightbutfoundthat
ifyouclickonthetextanddragtotherightthatitallbecomes
[Link]
bitinconvenientscrollingdowntofindit.

Cheers,
Jeff

JagadeshDivakaran
October26,2015at5:03am

VerymuchusefuldocumentPaul!

[Link]

26/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

ManuKapur
October26,2015at11:22am

[Link].

RaphaelPacheco
October26,2015at11:45am

GreatpostJeffrey!

JustasuggestionIbelievethatwouldbelessharmfultotheblockswithcommands
havetheedgesalittlethinner.

JeffreyTowell Postauthor
October26,2015at12:05pm

GoodpointRaphael!IfIcanfindarelativelyeasywaytodothat
IthinkIwill.

AshokSivaKumarEasa
October27,2015at1:18pm
Brilliant,lookingforwardforfutureblogs..

MarkusV
October28,2015at12:20pm

veryhelpful,cantwaittousesomeoftheinlineexpressions

[Link]

27/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

GuyLamoureux
October28,2015at1:34pm

[Link]
[Link]

JeffreyTowell Postauthor
October29,2015at2:30am

Guy,IthoughttheexactsamethingatfirstalongwithothersI
[Link],afterusingitawhileIrealiseit
becomesmoreclearasyougetmorefamiliarwiththesyntax.
Afteryearsofusingtheoldsyntaxithasbecomesofamiliarto
usthatitfeelslikewehavetothinktoomuchtounderstand
[Link]
naturetoyouandhenceeasytoread.

GuyLamoureux
October29,2015at11:37am

HiJeffrey,

[Link]
isanABAPprogrammerandnoteverybodyprogramsinABAP
[Link]
[Link]
reasonsbutitspartoftheirjobandthemorewechangethe
languagetosomethingmoreobscure,thelesstheywillbeable
[Link]
slowdowntheprocess.
Onmypart,IveworkedasanABAPprogrammerfor10years,
[Link]
[Link]
obscure.

ChristophSchreiner
[Link]

28/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

October29,2015at7:59am

Niceoverview,thanksforsharingitwithus!

GeorgeMathew
November8,2015at10:56am

Greatjob!Thankyouformakingourlifeeasy

AslamMD
November18,2015at7:17am

HiJeffrey,

Veryinformativematierial.

Thankyouverymuch

AlexanderBeckmann
November18,2015at8:36am

BigTHX:).

Justsentthislinktothewholeteam:).

JakobMainka
November20,2015at2:32pm

WhenIdoaninlineDeclarationofaninternaltable
SELECTFROMINTOTABLE@data(lt_data).
Istherealsosomeway,tohavethisasasorted/hashedtableoratleast
addsecondarykeys?

[Link]

29/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

JeffreyTowell
November23,2015at5:17am

[Link]
youwantwithsortingetc.andcallitsayty_mytabyoucoulddo
aconversionusingCONV:

TYPESty_mytabTYPESORTEDTABLEOFt001wWITHNON
UNIQUEKEYfabkl.

SELECT*FROMt001wINTOTABLE@DATA(lt_t001w).
DATA(lt_new_tab)=CONVty_mytab(lt_t001w).

However,thisdoesnotsaveyouanytime/typingcomparedto
selectingdirectlyintoyourdefinedinternaltable:

TYPESty_mytabTYPESORTEDTABLEOFt001wWITHNON
UNIQUEKEYfabkl.
DATA:lt_new_tabTYPEty_mytab.

SELECT*FROMt001wINTOTABLElt_new_tab.

WilbertSison
November26,2015at2:49am

NicecollectionJeffrey!

JeffreyTowell
November26,2015at2:52am

CheersWilbo!

MichaelCalekta
May18,2016at10:13am

ThanksforyoureffortJeffrey!
YettheresalittlemistakeintheMeshExample:
[Link]

30/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

ASSIGNlt_developer[name=Jerry]TO
FIELDSYMBOL(<ls_jerry>).
DATA(ls_jmanager)=ls_teamdevelopers\my_manager[jerry].

Secondlineshouldreadinstead:
DATA(ls_jmanager)=ls_teamdevelopers\my_manager[
<ls_jerry>].

Sameistrueforthomasafewlinesbelow.
NeverthelessthisisthefirstexampleIfound,wheretheadvantageof
meshescanbeseen.
Allthebest
Michael

JeffreyTowell Postauthor
May19,2016at1:03pm

[Link].
Theamazingthingisthatthecodeisacopyandpastefroma
[Link]<and
>[Link]
theoryisthatwhenitgetsconvertedtoHTMLthatthefield
symbolssometimeslooklikeHTMLtagsbecausetheyare
betweenthe<>.Assuchtheyaresometimesstrippedoutby
thisconversiontoHTML.

Thatsmytheoryanyway.
Thanksagain.

MichaelCalekta
May19,2016at1:17pm

Sorrytointerruptagain,butitwasnotonlythe<>missing,
whichyouhavecorrected,butalsothels_whichisstill
[Link]
[Link]
theoriginalcoding.

[Link]

31/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

Ihavecopiedtheexampleandtriedit,anditreallyworksfine,
onceIcouldeliminatethesyntaxerrorsbecauseofthemissing
letters.

JeffreyTowell Postauthor
May20,2016at4:45am

InterruptionappreciatedasyouarecorrectthatIforgottoadd
thels_in.However,Icanassureyouthattheoriginalcodehas
boththe<>andthels_in.TheHTMLissuehascaused
problemsinotherpartsofthisdocumentwhichiswhyIknow
[Link]
[Link]
documentwordbyword([Link])and
[Link]
renamedthefieldsymbolitsaved.

VinayMutt
June8,2016at9:36am

[Link]
[Link]
DeclarationisaveryhelpfulfeatureofABAP740anditsolveshugeeffotsof
developer.

Regards,
VinayMutt

MartinNeu
June16,2016at5:19am

wonderful!

IamjusttryingtogathersomeInformationaboutNetweaver7.40ABAPfora
forthcominginhousetraininghereinourcompany,andfoundoutsoonthat
theoriginalSAPsamplesarehardlyhelpful.
[Link]

32/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

Yourexamplesarereallystraightforward,easytounderstandandusefulfor
reallifedevelopers.

Thankyou!

Regards,
MartinNeuss

MesnyankinKonstantin
August18,2016at10:08am

Hi,[Link]
variableandonefieldfromanothertableusingonestatement?myexample:

data(RT_CONFIG_PERS_DATA)=
VALUEBSP_DLCT_PERS(forwa_touserinTOUSER
(CORRESPONDING#(RS_CONFIG_PERS_DATAEXCEPT
PERS_FOR_USER)PERS_FOR_USER=wa_touserlow)).

thisstatementgivessyntaxerror.

soiamjustusingclassiccode:

dataRT_CONFIG_PERS_DATAtypeBSP_DLCT_PERS.
LOOPATTOUSERINTODATA(wa_touser).
APPENDINITIALLINETOrt_config_pers_dataASSIGNING
FIELDSYMBOL(<fs>).
MOVECORRESPONDINGrs_config_pers_datato<fs>.
<fs>pers_for_user=wa_touserlow.
ENDLOOP.

isitpossibletodosuchactionsinonestatement?

JeffreyTowell Postauthor
August19,2016at12:07am

HiKonstantin,
[Link]

33/34

19/01/2017

ABAP7.40QuickReference|SAPBlogs

Itspossibletogetitononelinebyusingeachcomponentofthe
[Link]
wouldlooklike:

DATA(rt_config_pers_data)=
VALUEbsp_dlct_pers(FORwa_touserINtouser
(pers_for_user=wa_touserlow
component=rs_config_pers_datacomponent
viewname=rs_config_pers_dataviewname
role_key=rs_config_pers_datarole_key
component_usage=rs_config_pers_datacomponent_usage
object_type=rs_config_pers_dataobject_type
object_sub_type=rs_config_pers_dataobject_sub_type
changed_by=rs_config_pers_datachanged_by
changed_at=rs_config_pers_datachanged_at
config=rs_config_pers_dataconfig
parameters=rs_config_pers_dataparameters
config_type=rs_config_pers_dataconfig_type
invalid_flag=rs_config_pers_datainvalid_flag
marking_flag=rs_config_pers_datamarking_flag
check_flag=rs_config_pers_datacheck_flag)).

Ofcourseyourclassiccodeisbetternotjustbecausethe
aboveislongerbutalsobecausetheabovewillnotworkifthere
iseverachangetothestructurebsp_dlct_pers.

PRUTHVIRAJDAYAM
August30,2016at2:09pm

CantweuseFilterwithNonKeyfields!..anymanipulationpossiblewith
declaration?!

Share & Follow

Privacy

TermsofUse

[Link]

LegalDisclosure

Copyright

Trademark

Sitemap

Newsletter

34/34

You might also like