cancel
Showing results for 
Search instead for 
Did you mean: 

How to update a RAP object within another RAP-object?

AndreM
Explorer
0 Kudos
445

I have a managed (self-built) RAP object, that is working pretty well together with the generated Fiori-Elements-App.

Upon creating/updating/deleting a dataset in that BO I want to update another (SAP-built) BO through EML. But as I can't commit changes within the "save_modified" and without committing them they won't get saved, I am a bit lost. I also tried to raise a custom Business-Event, fetching it in another class, yet still EML-Modify plus EML-Commit are crashing on runtime because in the obviously synchronous Event-Handling (why synchronous?) I am still "not allowed" to Commit things.

Hope someone can help me soon on how to solve this, Google was no help at all.

Accepted Solutions (0)

Answers (3)

Answers (3)

HunorCzaka
Explorer
0 Kudos

Normally you are not allowed to execute COMMIT within the Transactional Processing, since an implicit COMMIT happens at the end of the SAVE sequence of the processing.

See https://help.sap.com/docs/ABAP_PLATFORM_NEW/fc4c71aa50014fd1b43721701471913d/ab7459048c7e4ecda98d0b6...

You should be able to call through EML external BO MODIFY and should be commited together with your change.

If you want to build around the idea to commit the other BO before your commit happens, you could do it via an async RFC (https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-US/abapcall_function_starting.htm)

patrick_boehm
Explorer
0 Kudos

Hi, 

like yunwu also replied.

The commit should be done by the framework automaticly. I've a similar scenario where I modify entities of a different BO within the RAP LUW. But this is done inside the action implementation ( and not inside the save_modified ) ans this is working well for me

rammel_sapdev
Participant
0 Kudos
But what if there is no action required here? It is just a simple app with editable columns, where I need to update the data upon clicking 'Save'?
rammel_sapdev
Participant
0 Kudos
May I know if you are using managed scenario with draft?
patrick_boehm
Explorer
0 Kudos
Yes, I'm using a managed scenario with draft and there we don't have the use case to modify an other BO by clicking an "Save"
rammel_sapdev
Participant
0 Kudos
Hi @patrick_boehm, can I check with you? was your approach similar to this? https://github.com/SAP-samples/abap-platform-rap-workshops/blob/main/rap6xx/rap610/exercises/ex4/REA.... Your action is getting triggered on an already saved BO?
umasaral
Active Participant
0 Kudos

Hi 

To update another BO through EML in a managed RAP object, avoid committing changes in `save_modified`. Use asynchronous business events to decouple the update and handle the EML operation in a separate transaction. Alternatively, store the required changes in a staging table or buffer and process them later via a background job. This ensures transaction consistency and avoids runtime errors.

AndreM
Explorer
0 Kudos
Actually Business Events are not that "asynchronous" as one might think. From my experience if in save_modified an Business-Event is raised then in the handlers to that event any Commit will also crash, though I can't imagine why SAP would build it like that ... feels like a kernel bug to me.