2020 May 03 6:23 AM
Hello
Can someone help me with the syntax error in the attached code ?
It gives error “No components exists with the name ‘FOR’ "
TYPES:
BEGIN OF ty_for_final,
vbeln TYPE vbeln_va,
vbtyp TYPE vbak-vbtyp,
posnr TYPE vbap-posnr,
END OF ty_for_final.
DATA(li_for_final) = VALUE ty_for_final( FOR wa_vbak IN for_vbak
FOR wa_vbap IN for_vbap WHERE ( vbeln = wa_vbak-vbeln )
( vbeln = wa_vbak-vbeln vbtyp = wa_vbak-vbtyp posnr = wa_vbap-posnr ) ).
2020 May 03 6:51 AM
Hi Vishal,
you see the below code is creating a structure type
VALUE ty_for_final(..)and "FOR" will do iteration and create multiple data(table), so that is the reason of your error.
try creating a table type, it will work.
types: tt_for_final type table of ty_for_final with EMPTY KEY.
DATA(li_for_final) = VALUE tt_for_final( .... ).
-Mahesh
Hello
Can someone help me with the syntax error in the attached code ?
It gives error “No components exists with the name ‘FOR’ "
TYPES:
BEGIN OF ty_for_final,
vbeln TYPE vbeln_va,
vbtyp TYPE vbak-vbtyp,
posnr TYPE vbap-posnr,
END OF ty_for_final.
DATA(li_for_final) = VALUE ty_for_final( FOR wa_vbak IN for_vbak
FOR wa_vbap IN for_vbap WHERE ( vbeln = wa_vbak-vbeln )
( vbeln = wa_vbak-vbeln vbtyp = wa_vbak-vbtyp posnr = wa_vbap-posnr ) ).
2020 May 03 6:51 AM
Hi Vishal,
you see the below code is creating a structure type
VALUE ty_for_final(..)and "FOR" will do iteration and create multiple data(table), so that is the reason of your error.
try creating a table type, it will work.
types: tt_for_final type table of ty_for_final with EMPTY KEY.
DATA(li_for_final) = VALUE tt_for_final( .... ).
-Mahesh
2020 May 09 5:57 AM
If I'm not wrong, the table type TT_FOR_FINAL must be "complete" (i.e. not generic) so that it can be used after the constructor operator, by adding STANDARD (for instance):
types: tt_for_final type STANDARD table of ty_for_final with EMPTY KEY.
2020 May 10 6:52 AM
2020 May 11 12:55 AM
Thanks for the info. As an empty key can only be used with a standard table, I guess specifying the word "standard" is then optional in that case, and is automatically deduced by the compiler.
2020 May 08 10:11 PM
Which support package of NW 7.40 are you talking about?
Table comprehensions and FOR expression has been introduced in 7.40 SP05: https://help.sap.com/doc/abapdocu_740_index_htm/7.40/en-US/abennews-740_sp05-itab.htm
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |