‎2007 Feb 22 8:48 PM
Hi
I have struct1 LIKE TABLE OF struct2.
both are structures. can anybody give me syntax to create the internal table for this and how to store values from struct1 to the internal table/
thanks in advance
kp
‎2007 Feb 22 8:53 PM
you may use -
data: begin of i_tab.
include structure struct1.
data: end of i_tab.
data: wa_tab type struct1.
this will create an internal table without header line and you can use structure to pass value to it.
As an alternative you may also use -
data: begin of i_tab occurs 0.
include structure struct1.
data: end of i_tab.
this will create an internal table with header line but this is not advisable.
Regards,
Amit
Reward all helpful replies.
‎2007 Feb 22 8:54 PM
Hi,
IF you have struct1 LIKE TABLE OF struct2.
Then STRUCT1 is an internal table..
Exa.
DATA: ITAB LIKE TABLE OF STRUCT1.
DATA: WA LIKE STRUCT1.
WA-FIELD1 = 'ABC'.
WA-FIELD2 = 10.
Populate the internal table ITAB from the work area WA
APPEND WA TO ITAB.
display the records.
LOOP AT ITAB INTO WA.
WRITE: / WA-FIELD1, WA-FIELD2.
ENDLOOP.
Thanks,
Naren
‎2007 Feb 22 8:58 PM
You can declare a Internal table using the structure
Data: ITAB_struct1 like struct2 OCCURS 0 WITH HEADER LINE.
ITAB_struct1 = 'abcd'.
append ITAB_struct1.
clear ITAB_struct1.
You can declare the internal table without the headerline also. In that case you don't have to have the clear ITAB_struct1 statement.
Uma.