cancel
Showing results for 
Search instead for 
Did you mean: 

RAP: Action does not update the instance

MioYasutake
Active Contributor
2,603

I've implemented an action on RAP, referring to the following help.

https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/fed023a4ed9d4d7494e5c853b11...

This BO is draft-enabled, managed scenario.

  action set_complete result [1] $self;
  METHOD set_complete.
    "update status
    MODIFY ENTITIES OF zi_person_m IN LOCAL MODE
      ENTITY Person
        UPDATE FIELDS ( Status )
        WITH VALUE #( FOR key IN keys ( %tky = key-%tky
                                        Status = 'C' ) ). "Complete

    "read changed data for action result
    READ ENTITIES OF zi_person_m IN LOCAL MODE
      ENTITY person
        ALL FIELDS WITH
        CORRESPONDING #( keys )
        RESULT DATA(persons).

    result = VALUE #( FOR person IN persons ( %tky = person-%tky
                                              %param = person ) ).

  ENDMETHOD.<br>

The action button has been added to the UI. When I press the button, the action gets triggered and I can see in the debugger that result structure is filled with updated status.

However, the status filed doesn't get updated on the UI. When I checked the browser's network tab, in the response data of $batch request, the status field was empty, so as the DB table.

The following are the current situation as I see it.

1. The result structure is properly filled, but in $batch response status is empty

2. MODIFY ENTITES did not persist the updated status to the db

Does anyone know why this is happening?

Regards,

Mio

MioYasutake
Active Contributor
0 Kudos

One thing I noticed: If I execute the action on a draft instance, status gets updated.

So it seems there's a different way for updating an active instance. Or, should I create a draft, update the draft instance and activate it inside the action?

View Entire Topic
MioYasutake
Active Contributor

The issue has been resolved. The status field was added after the RAP BO had been generated.

So the mapping of status was missing in the behavior definition.

After I added status to the mapping, the action started to work.

  mapping for ZPERSON_M
  {
    PersonUUID = PERSON_UUID;
    FirstName = FIRST_NAME;
    LastName = LAST_NAME;
    Email = EMAIL;
    Birthday = BIRTHDAY;
    Status = STATUS;
TT1992
Discoverer
0 Kudos
thanks man, was torturing myself until your comment saved me