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: 

records fetch which not exist in both tables

Former Member
0 Kudos

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.

5 REPLIES 5

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

thanks all for the help