‎2006 Jul 03 3:40 PM
Hi All!
I have two int tables as below with the same columns and field names and values below..
<b>Item quan
mfg03 50
mfg04 100
mfg05 20.</b>
second IT is also having item numbers with different values.Now i want to figure out the line items which are not there in the second IT by comparing the first IT .Please advise.
Regards
Pavan
‎2006 Jul 03 3:49 PM
Hi Kumar,
Take third internal table and do as follows.
<b>1)If you sure that you dont have more than one entry for each material in ITAB2 then do as follows.</b>
DATA ITAB3 TYPE ITAB OCCURS 0 WITH HEADERLINE.
loop at itab1.
read table itab2 with key item = itab1-item.
<b>if sy-subrc <> 0.</b>
wa_itab3-quan = itab1-quan - itab2-quan.
wa_itab3-item = itab1-item.
append wa_itab3 to itab3
<b>endif.</b>
endloop.
<b>2)If you more than one entry for each material in ITAB2 then do as follows.</b>
loop at itab1.
<b>loop at itab2 where item <> itab1-item.</b>
wa_itab3-quan = itab1-quan - itab2-quan.
wa_itab3-item = itab1-item.
append wa_itab3 to itab3
<b>endloop.</b>
endloop.
<b>The BOLD STATEMENTS will do comparision for the requirement.</b>
Thanks,
Vinay
Message was edited by: Vinaykumar G
‎2006 Jul 03 3:43 PM
Hi Pavan,
Just go through this link on comparing internal tables..
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3841358411d1829f0000e829fbfe/content.htm
Regards,
SP.
‎2006 Jul 03 3:43 PM
Hi,
Check this code:
Loop at it1.
read table it2 with key fld1 = it1-fld1.
if sy-subrc ne 0.
-
which is in it1 and not in it2.
endif.
endloop.
Laxman
‎2006 Jul 03 3:49 PM
Hi Kumar,
Take third internal table and do as follows.
<b>1)If you sure that you dont have more than one entry for each material in ITAB2 then do as follows.</b>
DATA ITAB3 TYPE ITAB OCCURS 0 WITH HEADERLINE.
loop at itab1.
read table itab2 with key item = itab1-item.
<b>if sy-subrc <> 0.</b>
wa_itab3-quan = itab1-quan - itab2-quan.
wa_itab3-item = itab1-item.
append wa_itab3 to itab3
<b>endif.</b>
endloop.
<b>2)If you more than one entry for each material in ITAB2 then do as follows.</b>
loop at itab1.
<b>loop at itab2 where item <> itab1-item.</b>
wa_itab3-quan = itab1-quan - itab2-quan.
wa_itab3-item = itab1-item.
append wa_itab3 to itab3
<b>endloop.</b>
endloop.
<b>The BOLD STATEMENTS will do comparision for the requirement.</b>
Thanks,
Vinay
Message was edited by: Vinaykumar G
‎2006 Jul 03 3:59 PM
Hi Kumar,
Consider this code,
REPORT as.
TYPES : BEGIN OF tp_test,
item(5),
quan(2),
END OF tp_test.
DATA : it_test1 TYPE STANDARD TABLE OF tp_test,
wa_test1 TYPE tp_test,
it_test2 TYPE STANDARD TABLE OF tp_test,
wa_test2 TYPE tp_test,
it_result TYPE STANDARD TABLE OF tp_test.
*Loop the second Table
LOOP AT it_test2 INTO wa_test2.
*Read the first table
READ TABLE it_test1 INTO wa_test1 WITH KEY item = wa_test2-item
quan = wa_test2-quan.
*If no entry present in the first table for entry in second table then append
*then append the second table entry.
IF sy-subrc NE 0.
APPEND wa_test2 TO it_result.
ENDIF.
ENDLOOP.
Regards,
Arun Sambargi.
‎2006 Jul 03 4:46 PM
Hi kumar pavan ,
loop at itab1.
read table itab2 with key Item quan = itab1-Item quan.
if sy-subrc <> 0.
move itab1 to itab_temp.
append itab_temp.
endif.
endloop.
Regards,
Kiran B
endloop.