‎2007 Jul 04 9:55 AM
Hi all,
I have a small problem, i have 2 'Z' tables with same fields. but some records are different from the both. i want to write mismatched records. How to do that?
Ex: ztab1 & ztab2 have matnr field but in ztab1 have a,b,c records. in ztab2 have a, b,c, ab, bc, cd, ef. i want to print only ab, bc, cd, ef. plz give soln.
Gowri
‎2007 Jul 04 10:02 AM
Hi
declare 3 int tables ITAB1 ITAB2 ITAB_DIFF with same fields
select * from ZTAB1 into table ITAB1.
Select * from ZTAB2 into table ITAB1.
Loop at ITAB1.
Read table ITAB2 with key a = itab1-a b = itab1-b c = itab1-c.
if sy-subrc <> 0.
move-corresponding iTAB2 to ITAB_DIFF,
append ITAB_DIFF.
endif.
clear ITAB_DIFF.
endloop.
use ITAB_DIFF
Reward points for useful Answers
Regards
Anji
‎2007 Jul 04 9:58 AM
loop at itab1.
read itab2 into wa_itab2 with key fld1 = fld2.
if sy-subrc <> 0.
append wa_itab2 to itab3.
endif.
endloop.
Now Itab3 has different records.
Regards,
Amit
Reward all helpful replies.
‎2007 Jul 04 10:02 AM
Hi
declare 3 int tables ITAB1 ITAB2 ITAB_DIFF with same fields
select * from ZTAB1 into table ITAB1.
Select * from ZTAB2 into table ITAB1.
Loop at ITAB1.
Read table ITAB2 with key a = itab1-a b = itab1-b c = itab1-c.
if sy-subrc <> 0.
move-corresponding iTAB2 to ITAB_DIFF,
append ITAB_DIFF.
endif.
clear ITAB_DIFF.
endloop.
use ITAB_DIFF
Reward points for useful Answers
Regards
Anji
‎2007 Jul 04 10:39 AM
data:
itab1 like table of ztab1 with header line,
itab2 like table of ztab2 with header line,
w_lines1 type i,
w_lines2 type i.
select * from ztab1 into itab1.
select * from ztab2 into itab2.
sort itab1 by matnr.
sort itab2 by matnr.
describe table itab1 lines w_lines1.
describe table itab2 lines w_lines2.
if w_lines1 GE w_lines2.
loop at itab1.
read table itab2 with key matnr = itab1-matnr binary search.
if sy-subrc ne 0.
write:/ itab1-matnr.
endif.
endloop.
else.
loop at itab2.
read table itab1 with key matnr = itab2-matnr binary search.
if sy-subrc ne 0.
write:/ itab2-matnr.
endif.
endloop.
endif.
‎2007 Jul 04 10:41 AM
hi gowri,
u can use inner join on both tables with where condition on matnr.
where ztab1matnr ne ztab2matnr.
this may work...
please reward if useful..
regards,
prashant