cancel
Showing results for 
Search instead for 
Did you mean: 

DSO data loading issue with End Routine

erdem_sephanelioglu
Participant
0 Kudos

Hello everybody,

when I run DTP, get an error as below

During loading, there was a key violation. You tried to save more than one data record with the same semantic key.

The problematic (newly loaded) data record has the following properties:

-   DataStore object: ZSALES_P

-   Request: 1478

-   Data package: 000002

-   Data record number: 1

I do not see a uption on DTP to DSO like "Handle with duplicated records".

I have no solution until now.

Thank you for the feedbacks.

Regards.

Eddy

Accepted Solutions (0)

Answers (5)

Answers (5)

erdem_sephanelioglu
Participant
0 Kudos

Hello everybody,

I am using yes end routine. The code is syntactically ok. The End Routine is as below

PROGRAM trans_routine.

*---------------------------------------------------------------------*

*       CLASS routine DEFINITION

*---------------------------------------------------------------------*

*

*---------------------------------------------------------------------*

CLASS lcl_transform DEFINITION.

   PUBLIC SECTION.

*  Attributs

     DATA:

       p_check_master_data_exist

             TYPE RSODSOCHECKONLY READ-ONLY,

*-    Instance for getting request runtime attributs;

*     Available information: Refer to methods of

*     interface 'if_rsbk_request_admintab_view'

       p_r_request

             TYPE REF TO if_rsbk_request_admintab_view READ-ONLY.

   PRIVATE SECTION.

     TYPE-POOLS: rsd, rstr.

*   Rule specific types

     TYPES:

       BEGIN OF _ty_s_TG_1,

*      Field: SID.

         SID           TYPE RSSID,

*      Field: DATAPAKID.

         DATAPAKID           TYPE RSDATAPID,

*      Field: RECORD.

         RECORD           TYPE RSARECORD,

*      InfoObject: 0UCINSTALLA Installation Number: Utilities Industry.

         UCINSTALLA           TYPE /BI0/OIUCINSTALLA,

*      InfoObject: 0UC_CONNOBJ Connection Object in the Utilities Indust

*ry.

         UC_CONNOBJ           TYPE /BI0/OIUC_CONNOBJ,

*      InfoObject: 0UCPREMISE Premise.

         UCPREMISE           TYPE /BI0/OIUCPREMISE,

*      InfoObject: 0UCCONTRACT Contract Number: Utilities Industry.

         UCCONTRACT           TYPE /BI0/OIUCCONTRACT,

*      InfoObject: 0SOURSYSTEM Source system ID.

         SOURSYSTEM           TYPE RSSOURSYSID,

*      InfoObject: 0UC_POD_EXT External Point of Delivery ID.

         UC_POD_EXT           TYPE /BI0/OIUC_POD_EXT,

*      InfoObject: 0UC_POD Point of Delivery Utilities Industry.

         UC_POD           TYPE /BI0/OIUC_POD,

*      InfoObject: 0DATETO Valid to.

         DATETO           TYPE /BI0/OIDATETO,

*      InfoObject: 0UCMOVEIN_D Move-in Date.

         UCMOVEIN_D           TYPE /BI0/OIUCMOVEIN_D,

*      InfoObject: 0UCMOVEOUTD Move-Out Date.

         UCMOVEOUTD           TYPE /BI0/OIUCMOVEOUTD,

*      InfoObject: 0POSTCD_GIS CAM: Postal Code (Geo-Relevant).

         POSTCD_GIS           TYPE /BI0/OIPOSTCD_GIS,

*      InfoObject: 0RECORDMODE BW Delta Process: Update Mode.

         RECORDMODE           TYPE RODMUPDMOD,

       END   OF _ty_s_TG_1.

     TYPES:

       _ty_t_TG_1        TYPE STANDARD TABLE OF _ty_s_TG_1

                         WITH NON-UNIQUE DEFAULT KEY.

*$*$ begin of global - insert your declaration only below this line  *-*

     ... "insert your code here

*$*$ end of global - insert your declaration only before this line   *-*

     METHODS

       new_record__end_routine

         IMPORTING

           source_segid             type rstran_segid

           source_record            type sytabix

         EXPORTING

           record_new               type sytabix.

     METHODS

       end_routine

         IMPORTING

           request                  type rsrequest

           datapackid               type rsdatapid

           segid                    type rsbk_segid

         EXPORTING

           monitor                  type rstr_ty_t_monitors

         CHANGING

           RESULT_PACKAGE              type _ty_t_TG_1

         RAISING

           cx_rsrout_abort

           cx_rsbk_errorcount.

     METHODS

       inverse_end_routine

         IMPORTING

           i_th_fields_outbound         TYPE rstran_t_field_inv

           I_R_SELSET_OUTBOUND          TYPE REF TO CL_RSMDS_SET

           i_is_main_selection          TYPE rs_bool

           i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set

           i_r_universe_inbound         TYPE REF TO CL_RSMDS_UNIVERSE

         CHANGING

           c_th_fields_inbound          TYPE rstran_t_field_inv

           c_r_selset_inbound           TYPE REF TO CL_RSMDS_SET

           c_exact                      TYPE rs_bool.

ENDCLASS.                    "routine DEFINITION

*$*$ begin of 2nd part global - insert your code only below this line  *

... "insert your code here

*$*$ end of 2nd part global - insert your code only before this line   *

*---------------------------------------------------------------------*

*       CLASS routine IMPLEMENTATION

*---------------------------------------------------------------------*

*

*---------------------------------------------------------------------*

CLASS lcl_transform IMPLEMENTATION.

*----------------------------------------------------------------------*

*       Method end_routine

*----------------------------------------------------------------------*

*       Calculation of result package via end routine.

*       Note: Update of target fields depends on rule assignment in

*       transformation editor. Only fields that have a rule assigned,

*       are updated to the data target.

*----------------------------------------------------------------------*

*   <-> result package

*----------------------------------------------------------------------*

   METHOD end_routine.

*=== Segments ===

     FIELD-SYMBOLS:

       <RESULT_FIELDS>    TYPE _ty_s_TG_1.

     DATA:

       MONITOR_REC     TYPE rstmonitor.

*$*$ begin of routine - insert your code only below this line        *-*

     DATA: l_t_result_package LIKE RESULT_PACKAGE,

           l_s_result_package LIKE LINE OF l_t_result_package.

           L_T_RESULT_PACKAGE[] = RESULT_PACKAGE[].

     DATA:

           l_t_ucinstalla type table of /bi0/pucinstalla,

           l_t_ucpremise type table of /bi0/pucpremise,

           l_t_uc_connobj type table of /bi0/puc_connobj,

           l_t_uc_pod type table of /bi0/muc_pod.

     DATA: l_s_ucinstalla LIKE LINE OF l_t_ucinstalla,

           l_s_ucpremise LIKE LINE OF l_t_ucpremise,

           l_s_uc_connobj LIKE LINE OF l_t_uc_connobj,

           l_s_uc_pod LIKE LINE OF l_t_uc_pod.

     SELECT * FROM /bi0/pucinstalla

       INTO CORRESPONDING FIELDS OF TABLE l_t_ucinstalla

       FOR ALL ENTRIES IN RESULT_PACKAGE

           WHERE ucinstalla RESULT_PACKAGE-ucinstalla

           AND objvers = 'A'

           AND soursystem = 'L1'.

     SELECT * FROM /bi0/mucpremise

      INTO CORRESPONDING FIELDS OF TABLE l_t_ucpremise

      FOR ALL ENTRIES IN RESULT_PACKAGE

          WHERE ucpremise = RESULT_PACKAGE-ucpremise

          AND objvers = 'A'

          AND soursystem = 'L1'.

     SELECT * FROM /bi0/puc_connobj

       INTO CORRESPONDING FIELDS OF TABLE l_t_uc_connobj

       FOR ALL ENTRIES IN RESULT_PACKAGE

           WHERE uc_connobj = RESULT_PACKAGE-uc_connobj

           AND objvers = 'A'

           AND soursystem = 'L1'.

     SELECT * FROM /bi0/muc_pod

     INTO CORRESPONDING FIELDS OF TABLE l_t_uc_pod

     FOR ALL ENTRIES IN RESULT_PACKAGE

         WHERE uc_pod = RESULT_PACKAGE-uc_pod

         AND objvers = 'A'

         AND soursystem = 'L1'.

     LOOP AT l_t_result_package INTO l_s_result_package.

       READ TABLE l_t_ucinstalla into l_s_ucinstalla WITH KEY

        ucinstalla = l_s_result_package-ucinstalla

        soursystem = 'L1'

        objvers = 'A'.

       READ TABLE l_t_ucpremise into l_s_ucpremise WITH KEY

        ucpremise = l_s_result_package-ucpremise

        soursystem = 'L1'

        objvers = 'A'.

       READ TABLE l_t_uc_connobj into l_s_uc_connobj WITH KEY

        uc_connobj = l_s_result_package-uc_connobj

        soursystem = 'L1'

        objvers = 'A'.

       READ TABLE l_t_uc_pod into l_s_uc_pod WITH KEY

        uc_pod = l_s_result_package-uc_pod

        soursystem = 'L1'

        objvers = 'A'.

       IF sy-subrc EQ 0.

         l_s_result_package-ucpremise = l_s_ucinstalla-ucpremise.

         l_s_result_package-uc_connobj = l_s_uc_connobj-uc_connobj.

         l_s_result_package-postcd_gis = l_s_uc_connobj-postcd_gis.

         l_s_result_package-uc_pod_ext = l_s_uc_pod-uc_pod_ext.

       ENDIF.

         APPEND l_s_result_package TO RESULT_PACKAGE.

       ENDLOOP.

*$*$ end of routine - insert your code only before this line         *-*

   ENDMETHOD.                    "end_routine

*----------------------------------------------------------------------*

*       Inverse method inverse_end_routine

*----------------------------------------------------------------------*

*       This subroutine needs to be implemented only for direct access

*       (for better performance) and for the Report/Report Interface

*       (drill through).

*       The inverse routine should transform a projection and

*       a selection for the target to a projection and a selection

*       for the source, respectively.

*       If the implementation remains empty all fields are filled and

*       all values are selected.

*----------------------------------------------------------------------*

*       Customer comment:

*----------------------------------------------------------------------*

   METHOD inverse_end_routine.

*   IMPORTING

*     i_r_selset_outbound          TYPE REF TO cl_rsmds_set

*     i_th_fields_outbound         TYPE HASHED TABLE

*     i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set

*     i_r_universe_inbound         TYPE REF TO cl_rsmds_universe

*   CHANGING

*     c_r_selset_inbound           TYPE REF TO cl_rsmds_set

*     c_th_fields_inbound          TYPE HASHED TABLE

*     c_exact                      TYPE rs_bool

*$*$ begin of inverse routine - insert your code only below this line*-*

       ... "insert your code here

*$*$ end of inverse routine - insert your code only before this line *-*

   ENDMETHOD.                    "inverse_end_routine

   METHOD new_record__end_routine.

***** IMPLEMENTATION  is only visible in generated program *****

   ENDMETHOD.

ENDCLASS.                    "routine IMPLEMENTATION

Thanks

Eddy

former_member183519
Contributor
0 Kudos

Hi Eddy,

As i said earlier, you need to manually Update records number while Appending records to result package..

I am mentioned below code for end routine with updated code in BOLD.

*---------------------------------------------------------------------*

*       CLASS routine IMPLEMENTATION

*---------------------------------------------------------------------*

*

*---------------------------------------------------------------------*

CLASS lcl_transform IMPLEMENTATION.

*----------------------------------------------------------------------*

*       Method end_routine

*----------------------------------------------------------------------*

*       Calculation of result package via end routine.

*       Note: Update of target fields depends on rule assignment in

*       transformation editor. Only fields that have a rule assigned,

*       are updated to the data target.

*----------------------------------------------------------------------*

*   <-> result package

*----------------------------------------------------------------------*

   METHOD end_routine.

*=== Segments ===

     FIELD-SYMBOLS:

       <RESULT_FIELDS>    TYPE _ty_s_TG_1.

     DATA:

       MONITOR_REC     TYPE rstmonitor.

*$*$ begin of routine - insert your code only below this line        *-*

     DATA: l_t_result_package LIKE RESULT_PACKAGE,

           l_s_result_package LIKE LINE OF l_t_result_package.

           L_T_RESULT_PACKAGE[] = RESULT_PACKAGE[].

     DATA:

           l_t_ucinstalla type table of /bi0/pucinstalla,

           l_t_ucpremise type table of /bi0/pucpremise,

           l_t_uc_connobj type table of /bi0/puc_connobj,

           l_t_uc_pod type table of /bi0/muc_pod.

     DATA: l_s_ucinstalla LIKE LINE OF l_t_ucinstalla,

           l_s_ucpremise LIKE LINE OF l_t_ucpremise,

           l_s_uc_connobj LIKE LINE OF l_t_uc_connobj,

           l_s_uc_pod LIKE LINE OF l_t_uc_pod.


DATA: LV_count Type I.

     SELECT * FROM /bi0/pucinstalla

       INTO CORRESPONDING FIELDS OF TABLE l_t_ucinstalla

       FOR ALL ENTRIES IN RESULT_PACKAGE

           WHERE ucinstalla RESULT_PACKAGE-ucinstalla

           AND objvers = 'A'

           AND soursystem = 'L1'.

     SELECT * FROM /bi0/mucpremise

      INTO CORRESPONDING FIELDS OF TABLE l_t_ucpremise

      FOR ALL ENTRIES IN RESULT_PACKAGE

          WHERE ucpremise = RESULT_PACKAGE-ucpremise

          AND objvers = 'A'

          AND soursystem = 'L1'.

     SELECT * FROM /bi0/puc_connobj

       INTO CORRESPONDING FIELDS OF TABLE l_t_uc_connobj

       FOR ALL ENTRIES IN RESULT_PACKAGE

           WHERE uc_connobj = RESULT_PACKAGE-uc_connobj

           AND objvers = 'A'

           AND soursystem = 'L1'.

     SELECT * FROM /bi0/muc_pod

     INTO CORRESPONDING FIELDS OF TABLE l_t_uc_pod

     FOR ALL ENTRIES IN RESULT_PACKAGE

         WHERE uc_pod = RESULT_PACKAGE-uc_pod

         AND objvers = 'A'

         AND soursystem = 'L1'.

Describe table RESULT_PACKAGE   lines LV_count.

     LOOP AT l_t_result_package INTO l_s_result_package.

       READ TABLE l_t_ucinstalla into l_s_ucinstalla WITH KEY

        ucinstalla = l_s_result_package-ucinstalla

        soursystem = 'L1'

        objvers = 'A'.

       READ TABLE l_t_ucpremise into l_s_ucpremise WITH KEY

        ucpremise = l_s_result_package-ucpremise

        soursystem = 'L1'

        objvers = 'A'.

       READ TABLE l_t_uc_connobj into l_s_uc_connobj WITH KEY

        uc_connobj = l_s_result_package-uc_connobj

        soursystem = 'L1'

        objvers = 'A'.

       READ TABLE l_t_uc_pod into l_s_uc_pod WITH KEY

        uc_pod = l_s_result_package-uc_pod

        soursystem = 'L1'

        objvers = 'A'.

       IF sy-subrc EQ 0.

         l_s_result_package-ucpremise = l_s_ucinstalla-ucpremise.

         l_s_result_package-uc_connobj = l_s_uc_connobj-uc_connobj.

         l_s_result_package-postcd_gis = l_s_uc_connobj-postcd_gis.

         l_s_result_package-uc_pod_ext = l_s_uc_pod-uc_pod_ext.

       ENDIF.

         l_s_result_package-record = LV_count + 1.

         APPEND l_s_result_package TO RESULT_PACKAGE.

       ENDLOOP.

CLEAR LV_count.

*$*$ end of routine - insert your code only before this line         *-*

   ENDMETHOD.                    "end_routine




* make changes which are in Bold and give a try!!!


Regards,

Hitesh

Former Member
0 Kudos

Hi Eddy, please try to change your Loop with this source code.

I hope, it can help you.

Best regards

Peter 

LOOP AT l_t_result_package ASSIGNING <result_fields> .      

READ TABLE l_t_ucinstalla into l_s_ucinstalla WITH KEY

         ucinstalla = <result_fields>-ucinstalla

         soursystem = 'L1'

         objvers = 'A'.     

      IF sy-subrc EQ 0.       

         <result_fields>-ucpremise = l_s_ucinstalla-ucpremise.      

      ENDIF.

       READ TABLE l_t_ucpremise into l_s_ucpremise WITH KEY

         ucpremise = <result_fields>-ucpremise

         soursystem = 'L1'

         objvers = 'A'.     

       READ TABLE l_t_uc_connobj into l_s_uc_connobj WITH KEY

         uc_connobj = <result_fields>-uc_connobj

        soursystem = 'L1'       

       objvers = 'A'.

       IF sy-subrc EQ 0.

         <result_fields>-uc_connobj = l_s_uc_connobj-uc_connobj.       

         <result_fields>-postcd_gis = l_s_uc_connobj-postcd_gis.     

       ENDIF.

       READ TABLE l_t_uc_pod into l_s_uc_pod WITH KEY

         uc_pod = <result_fields>-uc_pod

         soursystem = 'L1'

         objvers = 'A'.

       IF sy-subrc EQ 0.

        <result_fields>-uc_pod_ext = l_s_uc_pod-uc_pod_ext.

       ENDIF.

      ENDLOOP.

RafkeMagic
Active Contributor
0 Kudos

Eddy Carl wrote:

*$*$ begin of routine - insert your code only below this line        *-*

  ...

     LOOP AT l_t_result_package INTO l_s_result_package.

...

         APPEND l_s_result_package TO RESULT_PACKAGE.

       ENDLOOP.

*$*$ end of routine - insert your code only before this line         *-*

   ENDMETHOD.                    "end_routine

the reason for your error is the highlighted line above... you're basically adding each line to the result package again.

The rest of your code can be improved greatly, so I suggest you sit together with an ABAP developer and have him/her explain what the different statements mean and what their impact is on performance.

Former Member
0 Kudos

Eddy,

Kindly Share the screenshot plz

former_member183519
Contributor
0 Kudos

Hello Eddy,

Refer link.

In your end routine are you Inserting/appending any records to End_Routine ?

If yes.. then increase record number manually. refer below link for the same.

DTP Error: Duplicate data record detected | SCN

(In the end routine ,record field must be unique)

Regards,

Hitesh

Former Member
0 Kudos

Hi Eddy,

do you have duplicated in source ? I mean in PSA (or) any other target from which your DSO gets data? have you choose any semantic keys in DSO?  if, any field in semantic group (in DTP extraction) tab is on and if you have duplicates in source, then this error is expected. Please confirm

anshu_lilhori
Active Contributor
0 Kudos

Handle duplicate records key comes into picture when you are loading data to master data infoobjects.

Are you trying to append some records in the dso with the help of end routine or start.

Also in the DSO settings check if unique data records is selected.

Regards,

AL