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

Internal table logic required

Former Member
0 Likes
741

Hi ,

I have two internal tables having with different structures . Finally I need to pass data to final internal table.

In runtime we have data in only one table. The final internal table should take either internal1, or internal table 2.

it_final_data[] = it_first_data[].

or

it_final_data[] = it_sec_data[].

i have to one generic include , it will understands the IT_final_data internal table only.

please help me.

regards,

Ajay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
708

Hi Ajay,

Build your final internal table with all the fields from first and second internal table. Use the below logic to move the data to the final internal table depending on the internal table data which you want to display.

IF not it_first_data[] is initial.

loop at it_first_data.

move-corresponding it_frist_data to it_final_data.

append it_final_data.

endloop.

else.

loop at it_second_data.

move-corresponding it_second_data to it_final_data.

append it_final_data.

endloop.

endif.

Hope this works for you.

Regards,

Jayaram

6 REPLIES 6
Read only

Former Member
0 Likes
708

You cannot do single statement operations if the structures are not the same. Unfortunately you will have to loop.

Read only

chaiphon
Contributor
0 Likes
708
 IF it_first_data[] is initial.
  it_final_data[] = it_second_data[].
else.
  it_final_data[] = it_first_data[].
endif.

However, in order to move data between table that has different structure you need to loop. Or you can create it_final_data as dynamic table and assign structure at runtime but this method will make it harder to code program because everything that associate with this table need to be dynamic.

Cheers,

Chaiphon

Read only

Former Member
0 Likes
709

Hi Ajay,

Build your final internal table with all the fields from first and second internal table. Use the below logic to move the data to the final internal table depending on the internal table data which you want to display.

IF not it_first_data[] is initial.

loop at it_first_data.

move-corresponding it_frist_data to it_final_data.

append it_final_data.

endloop.

else.

loop at it_second_data.

move-corresponding it_second_data to it_final_data.

append it_final_data.

endloop.

endif.

Hope this works for you.

Regards,

Jayaram

Read only

0 Likes
708

Hi Jayaram,

Already I did the same. Is there any possibility to avoid the Loop.

I need to take care about the performance of the report.

regards,

Ajay

Read only

0 Likes
708

As already suggested its not possible to avoid the loop if the structures of the internal tables are not same. I dont think you will ever get a solution for this

Read only

Former Member
0 Likes
708

Try to use the below logic,

If it_first_data is initial.

APPEND LINES OF it_sec_data TO it_first_data.

endif.

If it_sec_data is initial.

APPEND LINES OF it_first_data TO it_sec_data.

endif.

Regards,

Benu