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: 

compare internal tables

Former Member
0 Kudos

Hi All,

i have entries from reguh table in 1 it_table. and corresponding entries from bkpf table.

i have to check if the entries in reguh table exist in bkpf table on the basis of document number, document type 'ZP' and posting date

Please help me with the syntax.

Regards,

Kaustubh

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI

let your internal tables be it_reugh and it_bkpf.

do the following.

if not it_reugh is initial.

loop at it_reugh.

read table it_bkpf with key docnum EQ it_reugh-docnum

doctyp EQ 'ZP'

posting_date EQ sy-date.

if sy-subrc EQ 0.

  • Then the record exists

else.

*it does not exist

endif.

endloop.

endif.

try this..it will work.

5 REPLIES 5

Former Member
0 Kudos

The entries in reguh and bkpf tables are in 2 different internal tables.

0 Kudos

LOOP at itab1 and READ (or LOOP in case relationship is 1 : N) the other internal table with the keys mentioned.

Former Member
0 Kudos

These are the common fields in both the tables:

1 ) BKPF-BUKRS REGUH-ZBUKR

2 ) BKPF-WAERS REGUH-WAERS

3 ) BKPF-BELNR EQ REGUH-VBLNR

Compare on the basis of above fields

Good Luck =;

Former Member
0 Kudos

hi check out this code:

sort: itab2 by document number doctype postindate.

loop at itab1 into wa_itab1.

read table itab2 into wa_itab2 with key document number = wa_itab1-docnumber doctype = 'ZP' positng date = wa_itab1-posting date.

if sy-subrc = 0 .

the value come in this portion ,is your required outputvalue.

collect this value to internal table.

endif.

endloop.

Former Member
0 Kudos

HI

let your internal tables be it_reugh and it_bkpf.

do the following.

if not it_reugh is initial.

loop at it_reugh.

read table it_bkpf with key docnum EQ it_reugh-docnum

doctyp EQ 'ZP'

posting_date EQ sy-date.

if sy-subrc EQ 0.

  • Then the record exists

else.

*it does not exist

endif.

endloop.

endif.

try this..it will work.