04-01-2019 4:00 PM
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 ).
04-01-2019 6:59 PM
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.
04-01-2019 5:36 PM
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.
04-01-2019 6:59 PM
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.
04-04-2019 5:34 AM
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....
04-04-2019 1:32 PM
If you mean that it's solved, that's good news.
An ANSWER is reserved for proposing a solution, please use a COMMENT instead.
04-06-2019 7:19 PM