FAILED and REPORTED only reach the caller and are never stored. Where and how do you keep a persistent error log and a change log for a RAP business object?
Say your answer out loud first.
Practise another way
Right, they are the response of one request, not a log. For an application log, I use the released CL_BALI_LOG API. I save it in the late save phase, normally in save_modified with additional save, so the log commits together with the data.
If I must log a rejected save, I use a secondary database connection, which RAP allows for logs. For change history I no longer build Z audit tables: current releases have RAP change documents.
Why FAILED and REPORTED are not enough. They are response parameters of one EML or OData request. Once the UI shows them they are gone, and a background consumer may never read them.
Error and processing log: application log (BALI)
managed with additional save implementation in class zbp_r_travel unique;
METHOD save_modified.
CHECK update-travel IS NOT INITIAL.
TRY.
DATA(log) = cl_bali_log=>create( ).
log->set_header( header = cl_bali_header_setter=>create(
object = 'ZTRAVEL' subobject = 'STATUS' ) ).
LOOP AT update-travel INTO DATA(travel)
WHERE %control-OverallStatus = if_abap_behv=>mk-on.
log->add_item( item = cl_bali_free_text_setter=>create(
severity = if_bali_constants=>c_category_free_text
text = |{ travel-TravelID }: status { travel-OverallStatus }| ) ).
ENDLOOP.
cl_bali_log_db=>get_instance( )->save_log( log = log ).
CATCH cx_bali_runtime.
" logging must never break the business save
ENDTRY.
ENDMETHOD.
- Create the application log object and subobject in ADT; users need
S_APPL_LOGto read the logs. - Where: the late save phase. Database writes are only allowed there, and
with additional saveexists for exactly this: change documents or application logs on top of the managed save. - Rejected saves: if a validation fails, the late phase never runs. To keep a record of the attempt, write it over a secondary database connection, which RAP allows in every phase for data outside the main transaction, such as logs.
Change history: RAP change documents
- RAP change documents log changes of persisted BO data in a change document object, configured in the behavior definition (
changedocuments). The ABAP release news lists them for ABAP release 7.58 and for cloud release 2508. - That replaces the classic pattern of a Z audit table filled in
save_modified.
Custom change logic
save_modifiedreceivescreate,updateanddeletewith%controltelling you which fields changed.- Cloud release 2511 added
READ ENTITIES ... IN LOCAL MODE ... WITH CHANGESfor managed BOs:%chgsays whether an instance was created, updated or deleted in this transaction.
What interviewers want to hear: you separate the response (messages for the user) from the record (log or change document). You write the record in the right phase, and you use standard tools before custom tables.
Explains why responses are not logs, writes BALI logs in the late save with additional save, handles the rejected-save case with a secondary connection, and names RAP change documents.
Inserts into a Z log table from a validation or determination, or relies on REPORTED messages as the audit trail.
Writing a log or audit table in a validation or determination. The data is written outside the late save phase, may not match what is finally saved, and breaks the single database transaction.
- Why may you not write the log table in a validation?
- How do you find which fields changed in save_modified?
- How do you log something when the save is rejected?
4 official pages and 2 prep guides. Confidence: medium. Checked 3 Dec 2026.
- Prep guide Gives the question.
- Prep guide Gives the question.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.