Application Development 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: 

comparing two internal tables

Former Member
0 Kudos

Hi All!

I have two int tables as below with the same columns and field names and values below..

<b><u>Item</u></b> <u><b>quan</b></u>

mfg03 50

mfg04 100

mfg05 20.

second IT have the same item numbers but different values.Now my requirement is to add the quantities into 3rd IT item wise.I can use collect statement to do this but confused how to apply on two Internal tables.Please advise.

Regards

Pavan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Take a look :

Loop at tab1.
move-corresponding tab1 to tab_final.
append tab final.   " You can put a collect instead if needed
endloop.

Loop at tab2.
move-corresponding tab2 to tab_final.
collect tab_final.
endloop.

Regards,

Erwan

3 REPLIES 3

Former Member
0 Kudos

Hi,

Take a look :

Loop at tab1.
move-corresponding tab1 to tab_final.
append tab final.   " You can put a collect instead if needed
endloop.

Loop at tab2.
move-corresponding tab2 to tab_final.
collect tab_final.
endloop.

Regards,

Erwan

Former Member
0 Kudos

Hi kumar,

1. simple.

2.

LOOP AT ITAB1.

ITAB3=ITAB1.

COLLECT ITAB3.

ENDLOOP.

LOOP AT ITAB2.

ITAB3=ITAB2.

COLLECT ITAB3.

ENDLOOP.

3. In this way, the TOTAL of all items,

(Item wise)

would now be in internal table 3.

regards,

amit m.

Former Member
0 Kudos

Hi Kumar,

Take 3rd internal table. Add the first two internal tables to 3rd intetnal table and use COLLECT statement on 3rd internal table.

DATA ITAB3 TYPE ITAB OCCURS 0 WITH HEADERLINE.

DATA V_LINES TYPE I.

<b>INSERT LINES OF ITAB1 INTO ITAB3.

DESCRIBE TABLE ITAB1 LINES V_LINES.

INSERT LINES OF ITAB2 INTO ITAB3 INDEX V_LINES.

LOOP AT ITAB3.

COLLECT ITAB3.

ENDLOOP.</b>

Thanks,

Vinay