cancel
Showing results for 
Search instead for 
Did you mean: 

Can we fill serial number for each record in direct update DSO through routine in APD?

anish_samuel
Explorer
0 Kudos

Hi All,

We were loading data to direct update DSO through APD. Recently we are facing error as "Duplication record issue". We have tried aggregation and all similar ways, it didn't work.

Also we don't have unique data for any of the field. So, we planned to have key field as counter in Direct update DSO and this field can be filled by numbers (similar to serial numbers) in order to get unique record.

Could any of you can share a piece of code which will work in APD Routine.

Thanks,

Asamuel

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member185132
Active Contributor
0 Kudos

If your source is a Bex query, there is a simpler solution which will avoid any coding: take the list of all characteristics in the output of the query, and ensure that all of those characteristics are in the key field of the target DSO.

If that is not possible for any reason, and if you want to do with the counter concept, then use an ABAP routine as the final step of the APD (before writing to the target DSO). In the ABAP routine, you derive the record number as below. I'm assuming that the field is called COUNTER in the target DSO.


DATA: ctr type i value 1.

  

   LOOP AT it_source INTO ls_source.

     MOVE-CORRESPONDING ls_source TO ls_target.

     ls_source-counter = ctr.

     ctr = ctr + 1.

     APPEND ls_target TO et_target.

   ENDLOOP.

ssurampally
Active Contributor
0 Kudos

if you are writing the code to update target of APD,  then your internal table and work area are,

et_target  and ls_target respectively,

you can append a field to your target as zrecord,

in routine,

data l_record type i.

l_record = 1.

loop at et_target into ls_target.

  ls_target-zrecord = l_record.

  modify et_target from ls_target.

  l_record = l_record + 1.

endloop.

clear l_record.

this could would generate unique record number for all records,

anish_samuel
Explorer
0 Kudos

Hi sreekanth,

I tried the same, its not populating unique record number for all record.

Please suggest any work around.

Thanks,

Asamuel

ssurampally
Active Contributor
0 Kudos

if you are getting data in et_target internal table, the given code should populate the record number for each record,

if no data came through to et_target as defalt, then you may have to use the code specified by Suhas, which does the following thing,

process every record from source, move to target work area and then target internal tabe,

you can check how the data is flown through APD, at each step of it, by  selecting the object in the context menu, display data,

also you can debug the code by keeping a break point at this to check what is happening,

fcorodriguezl
Contributor
0 Kudos

Hi Anish,

Try filter your empty records in key.

Regards.

ccc_ccc
Active Contributor
0 Kudos

Hi Anish,

Yes, we can generate sequence number using FM "NUMBER_GET_NEXT", generate number and assign to filed.

Thank you,

Nanda

anish_samuel
Explorer
0 Kudos

Hi Nanda,

Could you explain how to use FM "NUMBER_GET_NEXT" in APD Routine? and how to create object in Tcode SNRO.

Thanks

Asamuel