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: 

Comparing two internal tables

Former Member
0 Kudos
60

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.

2 REPLIES 2

Former Member
0 Kudos
40

APPEND it_bsik1_wa TO it_bsik_error.

no need to write

COLLECT it_bsik_bdc_wa INTO it_bsik_bdc.

will automatically append it when record is new

One more thing you can do this also by AT NEW command

Rewards if useful..................

Minal

0 Kudos
40

Hi minal,

thanx for ur prompt reply. but i wanna get sum of records of same BELNR also.

like for all same BELNR in flat file i wanna get sum and if any belnr doesnot exists it should be recoded in log structure.

Regards,

Sachin.