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

Populate Final internal table from Dynamic internal table

Former Member
0 Likes
580

Hello,

I have ti display data in ALV grid whose structure is fixed. I am dynamically selecting data iin an internal table.

Now from this dynamic internal table, i need to populate my final internal table whose structurte is fixed.

Please help.

Rgds,

Himanshu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
497

Hello Himanshu,

When you say dynamic internal table there are two things one is the actual structure and other one is field table that holds information for all the fields used to create dynamic internal table.

No if you want to move data from dynamic table to fixed internal table then you can try as follows:

1.

field-symbols <field_name> TYPE C.

field-symbols <field_value> TYPE C.

Now you either use

LOOP AT fields_itab.

ASSIGN fields_itab-fieldname to <field_name>.

ASSIGN COMPONENT <field_name> OF STRUCTURE <structure_name> TO <field_value>

Now you move value from <field_value> to required field in fixed internal table.

i.e.

itab-fieldname = <field_value>.

Other way to do this:

If you fields order is constant then you can also use index in assign component statement.

do <no_of_fields> times.

ASSIGN COMPONENT sy-index OF STRUCTURE <structure_name> TO <field_value>.

rest is same as first method.

Hope this help!

I have given sudo code and you need to work on it little.

Thanks,

Augustin.

4 REPLIES 4
Read only

vinod_vemuru2
Active Contributor
0 Likes
497

Hi,

Hope MOVE-CORRESPONDING should solve this!!! (Provided field names and length of your final table work area and dynamic field symbol are same for the matching fields)

Thanks,

Vinod.

Read only

0 Likes
497

I cannot use move-corresponding.

Please suggest.

Read only

anup_deshmukh4
Active Contributor
0 Likes
497

You can use Run time type services (RTTS) also.....

Hope it helps

Read only

Former Member
0 Likes
498

Hello Himanshu,

When you say dynamic internal table there are two things one is the actual structure and other one is field table that holds information for all the fields used to create dynamic internal table.

No if you want to move data from dynamic table to fixed internal table then you can try as follows:

1.

field-symbols <field_name> TYPE C.

field-symbols <field_value> TYPE C.

Now you either use

LOOP AT fields_itab.

ASSIGN fields_itab-fieldname to <field_name>.

ASSIGN COMPONENT <field_name> OF STRUCTURE <structure_name> TO <field_value>

Now you move value from <field_value> to required field in fixed internal table.

i.e.

itab-fieldname = <field_value>.

Other way to do this:

If you fields order is constant then you can also use index in assign component statement.

do <no_of_fields> times.

ASSIGN COMPONENT sy-index OF STRUCTURE <structure_name> TO <field_value>.

rest is same as first method.

Hope this help!

I have given sudo code and you need to work on it little.

Thanks,

Augustin.