Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Deleting Duplicate records

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.

Former Member
Not what you were looking for? View more on this topic or Ask a question