Application Development 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: 

Fill internal table with mutliple entries for nested structure

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

matt
Active Contributor
0 Kudos
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

5 REPLIES 5

matt
Active Contributor
0 Kudos
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

Former Member
0 Kudos

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"?

matt
Active Contributor
0 Kudos

Sorry - I'd edited my reply while you replied... should be clearer now

Former Member
0 Kudos

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.

............................

Former Member
0 Kudos

Thank you.

It works. ; )