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

Fill dynamic table

Former Member
0 Likes
469

Dear all

i created a dynamic internal table with:

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = ifc

IMPORTING

ep_table = dy_table.

the structure is really simple, there are 3 fields named KW1, KW2, KW3 type C(5).

Now i like to fill this table with values. How can I do this?

Thank you for your help

Herbert

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
445

Hi Herbert,

you can try using Field Symbols to populate ur table,

for e.g.

**data declaration

FIELD-SYMBOLS : <FS_KW> type string.

DATA : lv_field type String.

DATA : lv_kw type String.

DATA : lv_var type i.

**

lv_kw = 'KW'.

lv_var = 1.

do 3 times.

CONCATENATE lv_kw lv_var INTO lv_field.

ASSIGN COMPONENT lv_field OF STRUCTURE dy_table TO <FS_KW>.

MOVE 'some data' to <FS_KW>.

enddo.

APPEND dy_table from workarea.

Regards,

Samson Rodrigues.

2 REPLIES 2
Read only

Former Member
0 Likes
446

Hi Herbert,

you can try using Field Symbols to populate ur table,

for e.g.

**data declaration

FIELD-SYMBOLS : <FS_KW> type string.

DATA : lv_field type String.

DATA : lv_kw type String.

DATA : lv_var type i.

**

lv_kw = 'KW'.

lv_var = 1.

do 3 times.

CONCATENATE lv_kw lv_var INTO lv_field.

ASSIGN COMPONENT lv_field OF STRUCTURE dy_table TO <FS_KW>.

MOVE 'some data' to <FS_KW>.

enddo.

APPEND dy_table from workarea.

Regards,

Samson Rodrigues.

Read only

Former Member
0 Likes
445

Hi,

Let say the internal table it_table contains the data which you want ot fill in the dynamic internal table. The process would be as below.

ASSIGN dy_table->* TO <dyn_table>.

CREATE DATA new_line LIKE LINE OF <dyn_table>.

ASSIGN new_line->* TO <dyn_wa>.

loop at it_table into wa_itab.

ASSIGN COMPONENT 'KW1' OF STRUCTURE <dyn_wa> TO <fs2>.

<fs2> = wa_output-sold.

ASSIGN COMPONENT 'KW2' OF STRUCTURE <dyn_wa> TO <fs2>.

<fs2> = wa_output-bill.

ASSIGN COMPONENT 'KW3' OF STRUCTURE <dyn_wa> TO <fs2>.

<fs2> = wa_output-ship.

APPEND <dyn_wa> TO <dyn_table>.

ENDLOOP.

-


Hope this will help.

Ram.