Your unmanaged save must post through a legacy function module that can still reject the data. How do you design the saver so nothing fails after the point of no return, and what do you do when that cannot be guaranteed?
Say your answer out loud first.
Practise another way
I move every check that can fail in front of the point of no return. The handlers fill my buffer, and check_before_save runs the legacy checks or a test mode against that buffer.
Only then does save call the posting, ideally in update task. If the API can still fail late, I use CL_ABAP_BEHAVIOR_SAVER_FAILED, fill the late FAILED and REPORTED, and make the caller handle sy-subrc 8.
The contract. Once the early save phase passes, RAP is past the point of no return. The late phase ends with a successful commit or with a runtime error. It cannot go back to the user. So everything that can say "no" must run earlier.
Design that avoids late failures
- Interaction phase. Handlers call the legacy API in buffer or check mode and translate its messages into
failedandreported. Thelockmethod sets the enqueue locks early. check_before_save. Run the full legacy consistency check on the buffered data for every instance in the transaction. If the API offers a test run or a check function, call it here.adjust_numbers(late numbering). Draw numbers here. A failure here cannot stop the save. With the default base class, onlyREPORTEDis available, and the transaction ends in a runtime error. SAP's reuse-services sample raises a short dump on a number range error. WithCL_ABAP_BEHAVIOR_SAVER_FAILED,adjust_numberscan also fillFAILED. SAP's BAPI facade blog calls the BAPI here for that reason.save. Only post. PreferCALL FUNCTION ... IN UPDATE TASK, which RAP allows only in the late phase. It keeps a single database LUW. NeverCOMMIT WORK; RAP commits.
Typical late-failure risks
- A BAPI that rechecks data that changed in the meantime.
- Authority checks inside old code that run only at posting time.
- Locks the API sets itself in the late phase.
When it cannot be guaranteed. SAP accepts this exception, for example when BAPIs save in the late phase. Let the saver class inherit from CL_ABAP_BEHAVIOR_SAVER_FAILED instead of CL_ABAP_BEHAVIOR_SAVER.
Its saver methods offer response parameters that the normal base class lacks. Fill them so the consumer learns which instance failed:
CLASS lsc_order DEFINITION INHERITING FROM cl_abap_behavior_saver_failed.
PROTECTED SECTION.
METHODS save REDEFINITION.
ENDCLASS.
The consumer then sees sy-subrc 8 after COMMIT ENTITIES. A following RAP operation may dump. To continue, the consumer must call ROLLBACK ENTITIES explicitly.
Operational follow-up. A late failure means the user's data is lost from the buffer. Write an application log on a second database connection, with enough data to repeat the posting. Tell support how to use it.
Release note. CL_ABAP_BEHAVIOR_SAVER_FAILED is part of the RAP runtime on SAP BTP ABAP environment (now SAP Business AI Platform, ABAP environment) and ABAP Platform 2022 or later. Calling unreleased legacy function modules is possible only in Standard ABAP, typically on premise.
Moves all checks into the handlers and check_before_save, posts in update task in save, and names CL_ABAP_BEHAVIOR_SAVER_FAILED with sy-subrc 8 and ROLLBACK ENTITIES as the last resort.
Calls the BAPI with COMMIT WORK in save, or raises an exception from save and expects the user to see a normal error message.
Letting the late save phase decide validity. Any error there ends in a runtime error or, at best, sy-subrc 8, and the user's changes are lost.
- Which legacy checks would you call in check_before_save, and how do you map their messages?
- Why does the save method use an update task instead of direct database writes?
- What must a batch consumer do after sy-subrc 8?
6 official pages. Confidence: medium. Checked 3 Dec 2026.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.