Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP 7.40 FOR syntax

KumarVishal
Participant
0 Likes
4,430

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 ) ).

1 ACCEPTED SOLUTION
Read only

maheshpalavalli
Active Contributor
3,668

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

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

5 REPLIES 5
Read only

maheshpalavalli
Active Contributor
3,669

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

Read only

3,668

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.
Read only

3,668

sandra.rossi it makes sense, but for somereason it was not giving any error..

Read only

3,668

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.

Read only

gasparerdelyi
Product and Topic Expert
Product and Topic Expert
0 Likes
3,668

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