Your RAP business object must keep a technical log that support can open later, also when the request itself failed. In ABAP Cloud, which object do you create, which API do you call, and where do you save the log?
Say your answer out loud first.
Practise another way
I create an application log object with subobjects in ADT. In code I build the log with CL_BALI_LOG, add messages with the BALI setter classes, and save it with CL_BALI_LOG_DB.
Inside RAP I cannot commit, so a normal save_log only lands if the transaction commits. For a log that must survive a rollback, I call save_log_2nd_db_connection, which commits on its own service connection.
Why not FAILED and REPORTED? They go back to the caller of this request and are gone afterwards. Support needs a persistent record, and the standard one is the application log (BAL), not a custom Z table.
1. The repository object. Create an Application Log Object in ADT (File, New, Other, Application Log Object) with one or more subobjects. Reading logs needs authorization object S_APPL_LOG, as SAP's application-jobs sample notes.
2. The released API (ABAP Cloud)
TRY.
DATA(log) = cl_bali_log=>create_with_header(
cl_bali_header_setter=>create( object = 'ZORDER_LOG'
subobject = 'SAVE'
external_id = CONV #( order_id ) ) ).
log->add_item( cl_bali_free_text_setter=>create(
severity = if_bali_constants=>c_severity_error
text = 'Credit check service did not answer' ) ).
cl_bali_log_db=>get_instance( )->save_log_2nd_db_connection( log = log ).
CATCH cx_bali_runtime.
ENDTRY.
cl_bali_message_setter=>create_from_sy( ) adds a T100 message, and cl_bali_exception_setter adds an exception.
3. Which save method. SAP's documentation for IF_BALI_LOG_DB gives two methods:
save_loguses the default connection. The log is committed only when the application commits. In RAP that means the late save phase; on rollback the log disappears with the data.save_log_2nd_db_connectionuses a service connection and commits at once. The log survives a later rollback. This matches the RAP rule that commits on secondary connections are allowed in every phase for infrastructure such as logs.
The old use_2nd_db_connection parameter of save_log is deprecated. For logs written inside an application job, assign_to_current_appl_job = abap_true links the log to the job display.
4. Finding it again. log->get_handle( ) returns the log UUID. Store it on your entity if users should open the log. A custom entity can read it with cl_bali_log_db=>get_instance( )->load_log( handle = ... ), as SAP's application-jobs sample does.
Release note. CL_BALI_* is the released application log API for ABAP Cloud on SAP BTP ABAP environment (now SAP Business AI Platform, ABAP environment) and SAP S/4HANA Cloud.
SAP's application-jobs sample, which uses it, requires ABAP Platform 2021 or later on premise. For application logs, SAP's released-classes cheat sheet names CL_BALI_LOG. In ABAP Cloud, use the CL_BALI_* classes instead of the classic BAL_LOG_CREATE function modules.
Creates an application log object in ADT, uses CL_BALI_LOG and CL_BALI_LOG_DB, and chooses save_log_2nd_db_connection when the log must outlive a rollback.
Builds a Z log table written in a handler method, or calls BAL_LOG_CREATE and COMMIT WORK inside the behavior pool.
Writing the log with save_log inside RAP and expecting it after a failed save. It shares the LUW and is rolled back; only the second connection commits independently.
- Why would you sometimes prefer save_log over the second connection?
- How would a business user open the log for one order from the Fiori app?
- Which authorization does a user need to read the logs?
6 official pages and 2 prep guides. Confidence: high. 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.
- Official page Backs the answer.
- Official page Backs the answer.