Skip to Content
0
Former Member
Sep 17, 2007 at 04:59 AM

Comparing two internal tables

20 Views

Hi all,

I have a one internal table in which all records of BSIK tables are there and in other internal table i have records (belnr, bukrs and lifnr ) from my flat file. Now i want to check if that particular record in flat file exists in bsik internal table and if exists it will sum up wrbtr for that record on basis of belnr, lifnr and bukrs otherwise append in file.

Code:

LOOP AT it_bsik_flat INTO it_bsik_flat_wa.

UNPACK it_bsik_flat_wa-lifnr TO var.

  • Read table will read only 1 record at-a-time but there may be muliple records

READ TABLE it_bsik INTO it_bsik1_wa

WITH KEY bukrs = it_bsik_flat_wa-bukrs

lifnr = var

belnr = it_bsik_flat_wa-belnr.

IF sy-subrc = 0.

MOVE it_bsik1_wa-bukrs TO it_bsik_bdc_wa-bukrs.

MOVE it_bsik1_wa-lifnr TO it_bsik_bdc_wa-lifnr.

MOVE it_bsik1_wa-belnr TO it_bsik_bdc_wa-belnr.

MOVE it_bsik1_wa-waers TO it_bsik_bdc_wa-waers.

MOVE it_bsik1_wa-wrbtr TO it_bsik_bdc_wa-wrbtr.

COLLECT it_bsik_bdc_wa INTO it_bsik_bdc.

ELSE.

APPEND it_bsik1_wa TO it_bsik_error.

ENDIF.

ENDLOOP.

Help will be awarded.

Regards,

Sachin.