In this tutorial, we will explain how to implement a BAL log or application log in an ABAP program.
The following function modules will be used when implementing BAL Log:
  • BAL_LOG_CREATE : To create and initialize the BAL log
  • BAL_LOG_MSG_ADD : To add message to the BAL log
  • BAL_DSP_LOG_DISPLAY : To display the BAL log
*----------------------------------------------------------------------*
* Sub routine to create the application log for error logging          *
* purposes.                                                            *
*----------------------------------------------------------------------*
FORM f_create_log.
*----------------------------------------------------------------------*
* Local data declarations.
* Structures:
  DATA:
    lst_log TYPE bal_s_log.

* Defining some header data of the application log.
  lst_log-extnumber = text-006.   " Text: 'Program Log'.
  lst_log-aluser    = sy-uname.
  lst_log-alprog    = sy-repid.

* Creationg the application log.
  CALL FUNCTION 'BAL_LOG_CREATE'
    EXPORTING
      i_s_log = lst_log
    EXCEPTIONS
      OTHERS  = 1.
  IF sy-subrc NE 0.

*   Display error message.
    MESSAGE ID sy-msgid TYPE gc_i NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 DISPLAY LIKE gc_e.

  ENDIF.

ENDFORM.                    " F_CREATE_LOG



Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP S/4 HANA Logistics Consultant
Contact : serkurumsal@yandex.com