cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting Duplicate records

former_member410049
Participant
0 Kudos

Dear experts,

                        we have a requirement of deleting duplicate records based on reference key.it needs to be done between datasource and dso.i already develop the code .when i test it it takes long time can u please suggest what are the changes i need to do.

actually the senario first the key cantains nothing ie sapce now they are updating the space with some other no in ecc so we need to update that field with updated key and delete that record.

TYPES : begin of ty_temp,

           serialno type /BIC/OI******NO,

         END OF ty_temp.

     DATA:IT_BIC TYPE TABLE OF /BIC/AZFIAPO0300,

          WA_BIC LIKE LINE OF  IT_BIC.

     DATA: WA_SOURCEPACKAGE like LINE OF SOURCE_PACKAGE.

     DATA : it_temp type STANDARD TABLE OF ty_temp,

            wa_temp type ty_temp.

   loop at SOURCE_PACKAGE into WA_SOURCEPACKAGE.

     CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

       EXPORTING

         INPUT         = WA_SOURCEPACKAGE-****R

       IMPORTING

         OUTPUT        = wa_temp-****no.

       append wa_temp to it_temp.

       clear wa_temp.

   endloop.

     

*     IF SOURCE_PACKAGE IS NOT INITIAL.

         SELECT *   FROM /BIC/*****O0300

              INTO TABLE IT_BIC

              FOR ALL ENTRIES IN it_temp

              where /BIC/****NO = it_temp-*****no.

              " Dont have the same type

*        WHERE /BIC/ZDA_REF = ' '.              "Changes

*       AND ZDA_REF = LT_RESULT-XREF1' '.

*  ENDIF.

     sort it_bic by CREDITOR AC_DOC_NO /BIC/*****NO.

     LOOP AT SOURCE_PACKAGE INTO WA_SOURCEPACKAGE.

       READ TABLE it_bic INTO WA_bic WITH KEY CREDITOR =

       WA_SOURCEPACKAGE-LIFNR

                                              AC_DOC_NO =

                                              WA_SOURCEPACKAGE-BELNR

                                              /BIC/ZSERIALNO =

                                              WA_SOURCEPACKAGE-XBLNR

                                              BINARY SEARCH.

       IF SY-SUBRC = 0 and wa_bic-/BIC/****** = ''.     "Changes

            delete from /BIC/AZFIAPO0300 WHERE CREDITOR = wa_bic-creditor

                                           and AC_DOC_NO =

                                           wa_bic-ac_doc_no

                                           and /BIC/ZSERIALNO =

                                           wa_bic-/bic/zserialno

                                           and /BIC/ZDA_REF = ''.

       endif.

     clear : WA_SOURCEPACKAGE, wa_bic.

endloop.

Accepted Solutions (0)

Answers (1)

Answers (1)

KodandaPani_KV
Active Contributor
0 Kudos

Hi,

instaed select * form use the specifc fields.

IF SOURCE_PACKAGE IS NOT INITIAL.

         SELECT *   FROM /BIC/*****O0300

              INTO TABLE IT_BIC

              FOR ALL ENTRIES IN it_temp

              where /BIC/****NO = it_temp-*****no.

              " Dont have the same type

*        WHERE /BIC/ZDA_REF = ' '.              "Changes

*       AND ZDA_REF = LT_RESULT-XREF1' '.

use the spefic fields for the required.

IF SOURCE_PACKAGE IS NOT INITIAL.

         SELECT x

                        x

                         x

                         x

      FROM /BIC/*****O0300

              INTO TABLE IT_BIC

              FOR ALL ENTRIES IN it_temp

              where /BIC/****NO = it_temp-*****no.

              " Dont have the same type

*        WHERE /BIC/ZDA_REF = ' '.              "Changes

*       AND ZDA_REF = LT_RESULT-XREF1' '.

if you use the select * form - it will read the total table fields.

Thanks,

Phani.

former_member410049
Participant
0 Kudos

thanks for the reply kodandapani

KodandaPani_KV
Active Contributor
0 Kudos

Hi,

let me know have commented the code my early replay.

Former Member
0 Kudos

As suggested by other user...try to include fields those are required only, should not delete table inside loop, instead collect your records in a temp table and delete those at last. You are  hitting database for each loop.

Thanks & Regards,

Mahen

Former Member
0 Kudos

Also if only idea is to delete data from active table then you can include ABAP type in process chain and use a custom program once DSO is loaded. Program will take same conditions and will delete data from active table. Custom program will be called once DSO is activated and it has data loaded.

You are not updating anything in source package only deletion is being done so this is not the right thing that you should do in source package.

Thanks & Regards,

Mahen

former_member410049
Participant
0 Kudos

hi mahender

             thank you for the reply.actually in ecc side some records are modifying and adding some extra information thats why we need to delete the records in dso. i will also check other option that u suggest.

regards

phani chaithanya