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

tab1 tab2 tab 3

Former Member
0 Likes
521

how to get the data into one int table from 3 int tables with any common fields?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
480

loop at itab1.

move-correponding itab1 to itabfinal.

read table itab2 with key f1 = itab1-f1.

if sy-subrc = 0.

move-correponding itab2 to itabfinal.

endif.

read table itab3 with key f1 = itab1-f1.

if sy-subrc = 0.

move-correponding itab3 to itabfinal.

endif.

append itabfinal.

clear : itab1,itab2,itab3,itabfinal.

endloop.

regards

shiba dutta

how to get the data into one int table from 3 int tables with any common fields?

2 REPLIES 2
Read only

Former Member
0 Likes
481

loop at itab1.

move-correponding itab1 to itabfinal.

read table itab2 with key f1 = itab1-f1.

if sy-subrc = 0.

move-correponding itab2 to itabfinal.

endif.

read table itab3 with key f1 = itab1-f1.

if sy-subrc = 0.

move-correponding itab3 to itabfinal.

endif.

append itabfinal.

clear : itab1,itab2,itab3,itabfinal.

endloop.

regards

shiba dutta

Read only

Former Member
0 Likes
480

Hi,

Please use LOOP, READ and COLLECT (if you want to sum) statements.

Try this ...


...

SORT ITAB1 BY FIELD1 FIELD2 ASCENDING. 

SORT ITAB2 BY FIELD1 FIELD2 ASCENDING. 

SORT ITAB3 BY FIELD1 FIELD2 ASCENDING. 

LOOP AT ITAB1.
  
   MOVE-CORRESPONDING ITAB1 TO ITAB4.

   READ ITAB2 WITH KEY FIELD1 = ITAB1-FIELD1
                                        FIELD2 = ITAB1-FIELD2.

    IF SY-SUBRC = 0.
       MOVE-CORRESPONDING ITAB2 TO ITAB4.
    ENDIF.


   READ ITAB3 WITH KEY FIELD1 = ITAB1-FIELD1
                                        FIELD2 = ITAB1-FIELD2.

    IF SY-SUBRC = 0.
       MOVE-CORRESPONDING ITAB3 TO ITAB4.
    ENDIF.

*Insert record to internal table ITAB4 
    APPEND ITAB4.

*Sum record to internal table ITAB4 
*   COLLECT ITAB4.

ENDLOOP.

...

Regards,

Ferry Lianto