Skip to Content
avatar image
Former Member

records fetch which not exist in both tables

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.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Sep 04, 2008 at 07: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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 04, 2008 at 07: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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • avatar image
    Former Member
    Sep 04, 2008 at 10: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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 04, 2008 at 10:27 AM

    thanks all for the help

    Add comment
    10|10000 characters needed characters exceeded