Application Development 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: 

SAP ABAP HANA 7.4

0 Kudos

Hi Team.

I am learning ABAP 7.4 new syntax.and trying to display material details along with description details.

Below is the code, but getting the error : No component exist with the name 'FOR' .I tried but not resolved the error please help me out.

DATA p_matnr TYPE mara-matnr VALUE '000000000000000001'.
cl_demo_input=>request( CHANGING field = p_matnr ).

TYPES : BEGIN OF ty_mara,
matnr TYPE matnr,
mtart TYPE mtart,
mbrsh TYPE mbrsh,
meins TYPE meins,
spras TYPE spras,
maktx TYPE maktx,
END OF ty_mara.
SELECT matnr,
mtart,
mbrsh from mara
WHERE matnr = @p_matnr
INTO TABLE @data(it_mara).
IF it_mara is NOT INITIAL.
select matnr,spras,
maktx FROM makt
FOR ALL ENTRIES IN @it_mara
WHERE matnr = @it_mara-matnr
ORDER BY PRIMARY KEY
INTO TABLE @DATA(it_makt).
ENDIF.
LOOP AT it_makt INTO data(wa_MAKT).
READ TABLE it_mara INTO data(wa_mara) WITH KEY MATNR = WA_MAKT-MATNR.
ENDLOOP.
DATA(it_final) = VALUE ty_mara( FOR wa_makt IN it_makt-matnr
( wa_makt-matnr )
( wa_makt-spras )
( wa_makt-maktx )
( wa_mara-mtart )
( wa_mara-mbrsh ) ).
cl_demo_output=>display( it_final ).

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor

About this line:

DATA(it_final) = VALUE ty_mara( FOR wa_makt IN it_makt-matnr

Because the type ty_mara is structured, you can't use FOR.

Instead use a type which is a table type.

Moreover it_makt-matnr is not an internal table.

5 REPLIES 5

matt
Active Contributor

If you click on the code button in the editor and put your code snippet in there, I'll be able to read it, and will be more inclined to help.

Sandra_Rossi
Active Contributor

About this line:

DATA(it_final) = VALUE ty_mara( FOR wa_makt IN it_makt-matnr

Because the type ty_mara is structured, you can't use FOR.

Instead use a type which is a table type.

Moreover it_makt-matnr is not an internal table.

0 Kudos

Thank you Sandra Rosi,

I have created table type of defined structure. and looped makt and mara with (for wa_mara in it_mara where matnr = wa_makt.....

mtart = wa_mara-mtart.........

) ).

Thank u very much once again....

0 Kudos

If you mean that it's solved, that's good news.

An ANSWER is reserved for proposing a solution, please use a COMMENT instead.

0 Kudos

Thank you for your input...got resolved my query.