‎2008 Feb 20 2:43 PM
hi all,
i have an ALV report in that report i have data in three internal tables but i want 2 move that data into one final internal table wit specific fields
from the individual internal tables
how can i write the logic
can any one help me
thankss
‎2008 Feb 20 2:54 PM
Hi Verma,
Step 1: Find out the comprehensive table out the 3 (ie, which contain all the records ). for example say internal table it_3.
Step 2 : loop at the table found in step 1.
ie loop at it_3.
endloop.
Step 3 : Inside the loop of step 2 read the other tables using READ TABLE stmt, and if success ( ie sy-subrc = 0 ), then copy the required fields into your final table.
Step 4 : Append the final table values into the final table.
Hope this helps..
Thanks in advance,
rgds,
Harikrishna.
‎2008 Feb 20 2:45 PM
Hi,
You can do as below:
loop at itab.
read table itab1 with key <fieldname> = itab-<fieldname> "Key field
if sy-subrc eq 0.
move fields to itab-fields.
endif.
read table itab1 with key <fieldname> = itab-<fieldname> "Key field
if sy-subrc eq 0.
move fields to itab-fields.
endif.
modify itab.
clear itab.
endloop.
Thanks,
Sriram Ponna.
‎2008 Feb 20 2:46 PM
You can loop the first one and read table the other two...
LOOP AT T_TABLE1.
MOVE CORRESPONDING T_TABLE1 TO T_FINAL.
READ TABLE T_TABLE2 WITH WITH FIELD1 = T_TABLE1-FIELD1.
IF SY-SUBRC EQ 0.
MOVE CORRESPONDING T_TABLE2 TO T_FINAL.
ENDIF.
READ TABLE T_TABLE3 WITH WITH FIELD1 = T_TABLE1-FIELD1.
IF SY-SUBRC EQ 0.
MOVE CORRESPONDING T_TABLE3 TO T_FINAL.
ENDIF.
APPEND T_FINAL.
ENDLOOP.
Greetings,
Blag.
‎2008 Feb 20 2:48 PM
Should have atleast one common field ...
Loop at itab1.
read table itab2 with key <field1> = itab1-field1.
if sy-subrc = 0.
move-corresponding itab2 to final_itab.
endif.
read table itab3 with key <field1> = itab1-field1.
if sy-subrc = 0.
move-corresponding itab3 to final_itab.
endif.
move-corresponding itab1 to final_itab.
append final_itab.
clear final_itab.
endloop.
‎2008 Feb 20 2:54 PM
Hi Verma,
Step 1: Find out the comprehensive table out the 3 (ie, which contain all the records ). for example say internal table it_3.
Step 2 : loop at the table found in step 1.
ie loop at it_3.
endloop.
Step 3 : Inside the loop of step 2 read the other tables using READ TABLE stmt, and if success ( ie sy-subrc = 0 ), then copy the required fields into your final table.
Step 4 : Append the final table values into the final table.
Hope this helps..
Thanks in advance,
rgds,
Harikrishna.
‎2008 Feb 20 3:00 PM
supoose u have
itab1
itab2
and Final_itab.
final_itab[] = itab1[].
append lines of itab2 to final_itab
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Feb 20, 2008 10:02 AM