‎2014 Nov 25 12:56 PM
Hi experts,
Please help me on my issue related to filed symbol. I don' t know much about field symbols. In this program i got the data two field symbols and i want to
print it using loop and read statements but i am not able to do it. Because i am getting short dumps. Here is my code
DATA v_matnr TYPE matnr.
SELECT-OPTIONS s_matnr FOR v_matnr.
FIELD-SYMBOLS:<fs_mara> TYPE STANDARD TABLE,
<fs_marc> TYPE STANDARD TABLE,
<fw_mara> TYPE mara,
<fw_marc> TYPE marc.
DATA :it_mara LIKE mara OCCURS 0 WITH HEADER LINE ,
it_marc LIKE marc OCCURS 0 WITH HEADER LINE.
SELECT matnr
mtart
mbrsh
meins FROM mara
INTO CORRESPONDING FIELDS OF TABLE it_mara
WHERE matnr IN s_matnr.
IF it_mara[] IS NOT INITIAL.
SELECT matnr
werks
minbe
eisbe FROM marc
INTO CORRESPONDING FIELDS OF TABLE it_marc
FOR ALL ENTRIES IN it_mara
WHERE matnr = it_mara-matnr.
ENDIF.
ASSIGN it_mara[] TO <fs_mara>.
ASSIGN it_marc[] TO <fs_marc>.
LOOP AT <fs_marc> ASSIGNING <fw_marc>.
READ TABLE <fs_mara> INTO <fw_mara> WITH KEY ('MATNR') = <fw_marc>-matnr .
WRITE:/
<fw_marc>-matnr,
<fw_marc>-werks.
IF sy-tabix > 1.
WRITE:/ <fw_mara>-mtart.
ENDIF.
ENDLOOP.
dump is:field symbol is not assigned.
‎2014 Nov 25 1:08 PM
Hi Ramesh.
You have to use READ TABLE ... ASSIGNING instead of INTO, than it will work.
LOOP AT <fs_marc> ASSIGNING <fw_marc>.
READ TABLE <fs_mara> ASSIGNING <fw_mara> WITH KEY ('MATNR') = <fw_marc>-matnr .
WRITE:/
<fw_marc>-matnr,
<fw_marc>-werks.
IF sy-tabix > 1.
WRITE:/ <fw_mara>-mtart.
ENDIF.
ENDLOOP.
Best regards,
Thomas
‎2014 Nov 25 1:07 PM
why do u need to use field symbols, cant you simply loot at IT_MARC & readt table on IT_MARA?
and second thing, if you want to use field symbols then use sy-subrc to check if ASSIGN was successful or not.
There might be a case where one of the internal tables is empty and hence assign fails and then when you try to use it in loop or read table it gives dump, so either enclose it in sy-subrc or better check for IF <FS> IS ASSIGNED. and proceed on TRUE.
‎2014 Nov 25 1:08 PM
Hi Ramesh.
You have to use READ TABLE ... ASSIGNING instead of INTO, than it will work.
LOOP AT <fs_marc> ASSIGNING <fw_marc>.
READ TABLE <fs_mara> ASSIGNING <fw_mara> WITH KEY ('MATNR') = <fw_marc>-matnr .
WRITE:/
<fw_marc>-matnr,
<fw_marc>-werks.
IF sy-tabix > 1.
WRITE:/ <fw_mara>-mtart.
ENDIF.
ENDLOOP.
Best regards,
Thomas
‎2014 Nov 25 1:09 PM
‎2014 Nov 25 1:14 PM
Thomas,
Thank you very much for your response. It's working fine.
‎2014 Nov 25 1:13 PM
Hi...
Why are you using <fw_mara> without assigning?
READ TABLE <fs_mara> ASSIGNING <fw_mara> WITH KEY ('MATNR') = <fw_marc>-matnr . is the correct one
Hope to help
Bye
‎2014 Nov 25 1:19 PM
hi ramesh,
I think you are missing ASSIGN Component.
Have a look at the Syntax
ASSIGN COMPONENT <comp> OF STRUCTURE <s> TO <FS>.