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

Problem while reading filed symbol

Former Member
0 Likes
2,161

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,914

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

6 REPLIES 6
Read only

Former Member
0 Likes
1,914

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.

Read only

Former Member
0 Likes
1,915

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

Read only

0 Likes
1,914

Good catch

Read only

0 Likes
1,914

Thomas,

Thank you very much for your response. It's working fine.

Read only

roberto_vacca2
Active Contributor
0 Likes
1,914

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

Read only

Former Member
0 Likes
1,914

hi ramesh,

I think you are missing ASSIGN Component.

Have a look at the Syntax

ASSIGN COMPONENT <comp> OF STRUCTURE <s> TO <FS>.