03-14-2013 4:29 AM
Hi all,
I am trying to pass values to a deep structure but not able to do so.
Kindly guide as what is the approach to assign values in such a scenario.
See below the details :
ZIFLIGHT (structure) : Inside this ZFLIGHT_TT (table type) : Inside this ZIFLIGHT_ALL (line type) : Inside this three structure : CONTROL, DATA & DATAX.
Control has 1 field, values has to be assigned to this field.
data and datax has got 11 fields each; values to be assigned to be this field.
ZIFLIGHT (Top structure)
|
ZFLIGHT_TT (table type)
|
ZIFLIGHT_ALL (line type)
|
CONTROL(structure with 1 field)
DATA(structure with 11 fields)
DATAX(structure with 11 fields)
I am trying to do it by using field-symbols e.g.
LOOP AT ITAB ASSIGNING <FS_ITAB>.
ASSIGN COMPONENT 'ZFLIGHT_TT' OF STRUCTURE ZIFLIGHT TO <FS_ZIFLIGHT>.
IF SY-SUBRC EQ 0.
ASSIGN COMPONENT 'ZIFLIGHT_ALL' OF STRUCTURE <FS_ZIFLIGHT> TO <FS_ZIFLIGHT_ALL>.
IF SY-SUBRC EQ 0.
ASSIGN COMPONENT 'CONTROL' OF STRUCTURE <FS_ZIFLIGHT_ALL> TO <FS_CONTROL>.
IF SY-SUBRC EQ 0.
<FS_CONTROL>-TASK = <FS_ITAB>-VALUE.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
But it is not working and giving me dumps. Tried various combinations but not working, kindly guide.
Thanks,
Pradeep
03-14-2013 7:42 AM
Hi Pradeep,
basically it should work like that.
One thing that looks strange to me: in your first ASSIGN you use structure ZIFLIGHT -> is that correct? Means: is that your specific variable to be filled?
If that is not the issue, can you please give us a hint about the specific DUMP? A working (technically) code snippet might also help, so we can test "the real thing" and not have to simulate the behaviour in our heads.
Best regards,
Thorsten
03-14-2013 11:22 AM
Hi Pradeep,
First, let's do it using direct names to see what is wrong.
To access ZFLIGHT_TT, you can simple use:
ZIFLIGHT-ZFLIGHT_TT
But this is an internal table, so if you want its records next step is a loop.
LOOP AT ZIFLIGHT-ZFLIGHT_TT INTO WA_FLIGHT_TT.
Now, you can access your structure in this WA_FLIGHT_TT.
WA_FLIGHT_TT-ZIFLIGHT_ALL-CONTROL
WA_FLIGHT_TT-ZIFLIGHT_ALL-DATA
WA_FLIGHT_TT-ZIFLIGHT_ALL-DATAX
Your job now is adjust this code to use field-symbols.
Hope it helps,
Guilherme Frisoni
03-14-2013 1:11 PM
Hi Pradeep,
the cause of your problem is, that you try to access a component of a table! This won't work.
Let's see in detail:
ASSIGN COMPONENT 'ZFLIGHT_TT' OF STRUCTURE ZIFLIGHT TO <FS_ZIFLIGHT>.
IF SY-SUBRC EQ 0.
OK so far - but the next won't work. First you'll have to
LOOP AT <FS_ZIFLIGHT> ASSIGNING <FS_ZIFLIGHT_L>.
and than change to
ASSIGN COMPONENT 'ZIFLIGHT_ALL' OF STRUCTURE <FS_ZIFLIGHT> TO <FS_ZIFLIGHT_ALL>.
ASSIGN COMPONENT 'ZIFLIGHT_ALL' OF STRUCTURE <FS_ZIFLIGHT_L> TO <FS_ZIFLIGHT_ALL>.
IF SY-SUBRC EQ 0.
ASSIGN COMPONENT 'CONTROL' OF STRUCTURE <FS_ZIFLIGHT_ALL> TO <FS_CONTROL>.
IF SY-SUBRC EQ 0.
<FS_CONTROL>-TASK = <FS_ITAB>-VALUE.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
Hope it helps.
Best regards
Jörg