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

Former Member
0 Likes
537

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
520

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.

5 REPLIES 5
Read only

Former Member
0 Likes
520

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.

Read only

Former Member
0 Likes
520

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.

Read only

Former Member
0 Likes
520

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.

Read only

Former Member
0 Likes
521

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.

Read only

Former Member
0 Likes
520

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