09-04-2008 8:31 AM
hi all
i have 2 tables like zlease and zcust. the common field is zempno and i want to get the records which are no similar in both records eg:
records of both the tables
i_emp|zempno
********
VMX020|
3 |
1 |
10 |
10522 |
i_cust empno
**************
10522
3
vmx020
and i supposed to get 2 records like : 1 and 10.
i hav written the code but that doent give me just see my code pls
*****************************************************************************
loop at i_cust.
read table i_cust with key zempno = i_emp-zempno.
if not i_cust-zempno = i_emp-zempno.
move i_cust to itab.
append itab.
endif.
endloop.
loop at itab.
write : / itab-zempno, itab-zcustnumber, itab-zcustname, itab-zcustbd, itab-zno_chil.
endloop.
records of both the tables
i_emp|zempno
********
VMX020|
3 |
1 |
10 |
10522 |
i_cust empno
**************
10522
3
vmx020
and i supposed to get 2 records like : 1 and 10.
09-04-2008 8:34 AM
Hi
loop at i_cust. -
> here loop at i_emp
read table i_cust with key zempno = i_emp-zempno.
if not i_cust-zempno = i_emp-zempno.-----> if sy-subrc <> 0 then move i_cust to itab . append itab. endif.
move i_cust to itab.
append itab.
endif.
endloop.
09-04-2008 8:44 AM
Hi
Try this.
Loop at i_emp.
Loop at i_cust where empno = zempno.
If sy-subrc <> 0.
move-corresponding i_cust to itab.
append itab.
endif.
endloop.
endloop.
Hope it will help.
Regards
Natasha Garg
09-04-2008 11:19 AM
hi Natasha Garg
if u will do this
Loop at i_emp.
Loop at i_cust where empno = zempno.
If sy-subrc 0.
move-corresponding i_cust to itab.
append itab.
endif.
endloop.
endloop.
in this case record which are silmilar in both table will append to itab.
Regards
anil
09-04-2008 11:12 AM
to get record from i_emp which are not similar to i_cust
loop at i_emp.
read table i_cust with key zempno = i_emp-zempno.
if i_cust-zempno = ' '.
move i_emp to itab.
append itab.
endif.
endloop.
and if u want records from i_cust also do the same
loop at i_cust.
read table i_emp with key zempno = i_cust-zempno.
if i_emp-zempno = ' '.
move i_cust to itab.
append itab.
endif.
endloop.
loop at itab.
write : / itab-zempno, itab-zcustnumber, itab-zcustname, itab-zcustbd, itab-zno_chil.
endloop.
thanks
anil
Edited by: anil chaudhary on Sep 4, 2008 12:14 PM
09-04-2008 11:27 AM