Logging, BAL
Logging is critical for business processes. In ABAP systems, the standard tool is the Business Application Log (BAL), available on-premise and in ABAP Cloud environments alike. With abap2UI5, use BAL like you would in classic ABAP and display logs with the framework's built-in popups.
BAL Tables
In classic ABAP, use the BAL function modules and show the BAL table with the popup Z2UI5_CL_POP_MESSAGES:
METHOD z2ui5_if_app~main.
DATA(lt_bal) = VALUE bal_t_msgr(
( msgid = `Z001` msgno = `001` msgty = `S` time_stmp = `21354` msgnumber = `01` )
( msgid = `Z001` msgno = `001` msgty = `S` time_stmp = `21354` msgnumber = `02` ) ).
client->nav_app_call( z2ui5_cl_pop_messages=>factory( lt_bal ) ).
ENDMETHOD.ABAP Cloud
In ABAP Cloud, hand the logging object straight to the popup:
METHOD z2ui5_if_app~main.
DATA(lo_log) = cl_bali_log=>create( ).
DATA(lo_msg) = cl_bali_message_setter=>create(
severity = if_bali_constants=>c_severity_status
id = `DEMO_LOG`
number = `002`
variable_1 = `username` ).
lo_log->add_item( lo_msg ).
DATA(lo_bapi) = cl_bali_message_setter=>create_from_bapiret2(
VALUE #(
type = `E`
id = `DEMO_LOG`
number = `002`
message_v1 = `Dummy` ) ).
lo_log->add_item( lo_bapi ).
client->nav_app_call( z2ui5_cl_pop_messages=>factory( lo_log ) ).
ENDMETHOD.abap-logger
You can also use the open-source project abap-logger. It simplifies work with BAL logs and pairs well with abap2UI5:
METHOD z2ui5_if_app~main.
DATA(lo_log) = zcl_logger_factory=>create_log( desc = `ABAP Logger` ).
lo_log->e( `This is an error...` ).
lo_log->s( `This is a success message...` ).
client->nav_app_call( z2ui5_cl_pop_messages=>factory( lo_log ) ).
ENDMETHOD.BAL Popup
Unlike message classes, BAL logs carry more detail — like timestamps. Use the dedicated BAL log popup to show them. All examples above also work with the Z2UI5_CL_POP_BAL popup for richer output. An example with abap-logger:
METHOD z2ui5_if_app~main.
DATA(lo_log) = zcl_logger_factory=>create_log( desc = `ABAP Logger` ).
lo_log->e( `This is an error...` ).
client->nav_app_call( z2ui5_cl_pop_bal=>factory( lo_log ) ).
ENDMETHOD.TIP
The BAL popup is still in its early stages and offers only basic features. If you've built BAL features with abap2UI5, please consider contributing to grow it.
