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: 

BDC program - avoid duplicate records

Former Member
0 Kudos

Hello Experts,

I m doing BDC .My query is not working

My req is if company code,Pur Org.,A/c Grp & name1 is same as in the database i.e. if vendor having same these 4 fields in the databse as in the excel, this particular record will not get uploaded .

In it_success is the internal table with records to be uploaded after some validations.

PLz check where i m wrong

loop at i_lfa1.

loop at i_lfb1 where lifnr = i_lfa1-lifnr.

loop at i_lfm1 where lifnr = i_lfb1-lifnr.

main_table-lifnr = i_lfa1-lifnr.

main_table-bukrs = i_lfb1-bukrs.

main_table-ekorg = i_lfm1-ekorg.

main_table-KTOKK = i_lfa1-KTOKK.

main_table-name1 = i_lfa1-name1.

append main_table.

endloop.

endloop.

endloop.

loop at it_success.

loop at main_table where ( bukrs = it_success-bukrs_001

and EKORG = it_success-EKORG_002

and KTOKK = it_success-KTOKK_003

and name1 = it_success-name1_006 ).

MOVE-CORRESPONDING it_success TO it_error.

APPEND it_error.

delete main_table.

if sy-subrc eq 0.

delete it_success.

e_fret-type = 'E'.

e_fret-name = it_error-NAME1_006.

e_fret-message = 'Vendor Name already exists '.

append e_fret.

endif.

endloop.

endloop.

Ravi

Edited by: Julius Bussche on Oct 1, 2008 9:30 AM

Please use meaningfull subject titles.

5 REPLIES 5

Former Member
0 Kudos

Hi ,

Why do you have delete main_table and then delete_success .

when you are moving the records to it_error after that delete delete from it_success .

so it_success will have only those records which are to uploaded.

0 Kudos

Hello Dinesh,

Even i remove line delete main_table,this wiill not give the req result.

Required result is that vendor with same Company code,pur org, a/ group & name1 in the database that record get deleted from it_success.

Ravi

Former Member
0 Kudos

Hi,

loop at i_lfa1.

loop at i_lfb1 where lifnr = i_lfa1-lifnr.

read table i_lfm1 with key lifnr = i_lfb1-lifnr.

if sy-subrc = 0.

main_table-ekorg = i_lfm1-ekorg.

endif.

main_table-lifnr = i_lfa1-lifnr.

main_table-bukrs = i_lfb1-bukrs.

main_table-KTOKK = i_lfa1-KTOKK.

main_table-name1 = i_lfa1-name1.

append main_table.

endloop.

endloop.

Try Above code.

Thanks,

Durai.V

Former Member
0 Kudos

loop at it_success.

if ( it_success-bukrs_001 = it_success-EKORG_002

and it_success-bukrs_001 = it_success-KTOKK_003

and it_success-bukrs_001 = name1

and it_success-bukrs_001 = it_success-name1_006 ).

DELETE it_success.

endif.

ENDLOOP.

0 Kudos

Hello Sathar,

How it is possible that bukrs(com code) is equal to Ekorg(Pur Org)

Ravi