cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP RAP: late numbering - how to convert PID to draft UUID

MattDion
Participant
0 Kudos
2,057

Hi,

I am using late numbering for a child entity in a managed draft enabled BO. The user has access to the entity via a table on the parent entity's object page. The user can create multiple entries in this table while in draft mode.

My numbering in ADJUST_NUMBERS needs to take into account the a mandatory value that the user maintains. For this, I need to be able to read the draft table entries when setting the numbering.

The mapped attribute in ADJUST_NUMBERS has a PID assigned, which gives me a unique key for each draft entry about to be saved. The draft table maintains uniqueness through the use of draft UUID. It does not appear that the %pid is related to this draftUUID.

How would I go about reading the corresponding draft table entry for a given PID?

Thanks,

Matt

Accepted Solutions (1)

Accepted Solutions (1)

dominikeiraelias
Product and Topic Expert
Product and Topic Expert

You can use an EML READ passing the %PKY (edit: previously I mentioned %PID which is part of the %pky) and setting the %is_draft flag to on. The %PID field maps directly to the draftUUID, however it might be possible that this entry currently does not exist in the draft table, as the draft provider has a buffer holding modifications of the current session. These modifications are only persisted once the save sequence is executed.

MattDion
Participant

Hi dominikeiraelias,

Thanks for the suggestion!

It took me a while to figure out, but you need to specify the EML read in a different way. You cannot specify draft at all (not on or off) - I guess because in ADJUST_NUMBERS the records are somewhere in between?. You also need to specify in full the %pky and not just the %pid (in my case, there are multiple fields making up the table key, some of which are already populated.

So in the end, the call that works looks like this:

    READ ENTITIES OF <business object> IN LOCAL MODE
      ENTITY <entity>
      FIELDS ( <fields you need> )
      WITH VALUE #( FOR <structure> IN mapped-<entity> (
                                 %pky = VALUE #( %pid = <structure>-%pid
                                                 field1 = <structure>-%tmp-<field1>
field2 = <structure>-%tmp-<field2> ) ) )
RESULT DATA(lt_result)
FAILED DATA(ls_failed).
Gdelmagro
Explorer
0 Kudos
Thanks this worked perfect for me!

Answers (0)