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

RAP: Action does not update the instance

MioYasutake
SAP Champion
SAP Champion
3,674

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

Accepted Solutions (1)

Accepted Solutions (1)

MioYasutake
SAP Champion
SAP Champion

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
Ram_peddireddi
Explorer
0 Kudos

Hi Mio Yasutake,

Just wanted to know why you used result[1] instead of result[0..*]? What if I need to set the status of multiple rows at a time by selecting all at once. Does this still work? 

action set_complete result [1] $self;

 I'm asking this question because, even I'm facing this issue but using result[1] is working in 2022 but not in 2023. in 2023, I'm getting an error while performing an action, 

Answers (0)