11-12-2008 12:32 PM
Dear ABAP Experts,
I have a question related to fill internal tables with nested structures.
I have a structure like this:
BEGIN OF proto,
sicht TYPE ysicht,
version TYPE FAGLFLEXA-RVERS,
BEGIN OF kons,
kon TYPE YKONSEINHEIT,
END OF kons,
jahr TYPE CHAR04,
END OF proto.
Now I need to fill this structure with values (over an internal table), but how can I achieve that I save multiple datas für element "kon" für one single entry of structure "proto"?
An example could be:
sicht = '01'
version = '100'
kon = 1001 (first entry)
kon = 1002 (second entry)
usw... (n entry)
jahr = '2008'
Thanks in advance for every helpful answer.
Regards
Thomas
11-12-2008 12:35 PM
BEGIN OF proto,
sicht TYPE ysicht,
version TYPE FAGLFLEXA-RVERS,
kons TYPE STANDARD TABLE OF YKONSEINHEIT WITH NON-UNIQUE KEY TABLE_LINE,
jahr TYPE CHAR04,
END OF proto.
DATA: ls_proto TYPE proto,
lt_proto TYPE STANDARD TABLE OF proto,
ls_kon
ls_proto-sicht = '01'.
ls_proto-version = '100'
INSERT '1001' INTO TABLE ls_proto-kons.
INSERT '1002' INTO TABLE ls_proto-kons.
ls_proto-jahr = '2008'.
INSERT ls_proto INTO TABLE lt_proto
If you're going to use a more complicated inner table with several components, then you need to define a type for those components.
matt
11-12-2008 12:35 PM
BEGIN OF proto,
sicht TYPE ysicht,
version TYPE FAGLFLEXA-RVERS,
kons TYPE STANDARD TABLE OF YKONSEINHEIT WITH NON-UNIQUE KEY TABLE_LINE,
jahr TYPE CHAR04,
END OF proto.
DATA: ls_proto TYPE proto,
lt_proto TYPE STANDARD TABLE OF proto,
ls_kon
ls_proto-sicht = '01'.
ls_proto-version = '100'
INSERT '1001' INTO TABLE ls_proto-kons.
INSERT '1002' INTO TABLE ls_proto-kons.
ls_proto-jahr = '2008'.
INSERT ls_proto INTO TABLE lt_proto
If you're going to use a more complicated inner table with several components, then you need to define a type for those components.
matt
11-12-2008 12:38 PM
Thank you for your fast answer and for the good approach you posted.
I will change my structure that way, but how can i fill it now with multiple entries for "kons", für one entry in "proto"?
11-12-2008 12:39 PM
Sorry - I'd edited my reply while you replied... should be clearer now
11-12-2008 12:47 PM
DATA : ITAB TYPE TABLE OF PROTO,
WA LIKE LINE OF ITAB.
WA-SICHT = '01'.
WA-VERSION = '100'.
WA-KONS-KON = 1001. " (first entry)
WA-JAHR = '2008'.
APPEND WA TO ITAB.
WA-SICHT = '01'.
WA-VERSION = '100'.
WA-KONS-KON = 1002. " (Second entry)
WA-JAHR = '2008'.
APPEND WA TO ITAB.
............................
11-12-2008 1:48 PM