‎2009 Oct 23 6:41 PM
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
‎2009 Oct 23 7:48 PM
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
‎2009 Oct 23 6:51 PM
You cannot do single statement operations if the structures are not the same. Unfortunately you will have to loop.
‎2009 Oct 23 7:15 PM
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
‎2009 Oct 23 7:48 PM
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
‎2009 Oct 24 7:29 AM
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
‎2009 Oct 24 7:55 AM
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
‎2009 Oct 24 8:25 AM
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