Skip to Content

Create and view LOG using SLG0 and SLG1 transaction

Create and view LOG using SLG0 and SLG1 transaction

Application LOG

When we need to display all messages together then this set of messages is a log. Logs usually also contain general header information (log type, creator, creation time, etc.). Several logs can be created in a transaction. The Application Log provides a comprehensive infrastructure for collecting messages, saving them in the database and displaying them as logs. It has also traffic icons for the messages based on the message type.

Important Transactions

The important transactions codes used for application log are as following:

·      SLG0 – Create a new Log Object and sub object

·      SLG1 – Display Application Log

·      SLG2 – Delete the Application Log

Creation of object and sub object:

For generating a custom application log we need to create a new log object and sub object. For this we use transaction SLG0.

Go to transaction SLG0 and click on new entries. Then give the name of object and save. For any of the object we can create the sub object as well. Sub objects are simply further classifications of the application log.

To collect messages and display them in LOG in program:

Function modules to be used:

BAL_LOG_CREATE Create log with header data

BAL_LOG_MSG_ADD Add a message to a log

BAL_DB_SAVE Save the messages

BAL_DSP_LOG_DISPLAY Display message in memory

Open Log

The FM BAL_LOG_CREATE is used to open application log. This FM returns log handle. This log handle is a unique identifier for a particular log. We use this log handle later for accessing the log like for example adding messages to the log etc.

Add message to LOG

Using the log handle we can add as many messages we want to the LOG through the FM BAL_LOG_MSG_ADD to the importing parameter I_S_MSG (structure BAL_S_MSG). This data is very much similar to the T100 data that is message type, message number and the four message variables.

Save messages

Logs there in the memory can be saved to database using the FM BAL_DB_SAVE by passing the importing parameter I_SAVE_ALL = ‘X’.The function module BAL_DB_SAVE returns a table (Exporting parameter E_NEW_LOGNUMBERS), which relates LOG_HANDLE, external number EXTNUMBER, temporary LOGNUMBER and permanent LOGNUMBER, so you can find out which number was assigned to a log after saving.

Display messages

FM BAL_DSP_LOG_DISPLAY is used to display collected messages.

Below is one sample code using the above mentioned FMs:

ls_log-object = lc_object.          “Object name

  ls_log-aluser = sy-uname.        “Username

  ls_log-alprog = sy-repid.          “Report name

***Open Log



      i_s_log                 = ls_log


      e_log_handle            = ls_log_handle


      log_header_inconsistent = 1

      OTHERS                  = 2.

  IF sy-subrc EQ 0.

***Create message

    ls_msg-msgty = lc_type.               “Message type

    ls_msg-msgid = lc_msgid.            “Message id

    ls_msg-msgno = lc_msgno.          “Message number

    ls_msg-msgv1 = lv_message1.      “Text that you want to pass as message

    ls_msg-msgv2 = lv_message2.

    ls_msg-msgv3 = lv_message3.

    ls_msg-msgv4 = lv_message4.

    ls_msg-probclass = 2.



       i_log_handle              = ls_log_handle

        i_s_msg                   = ls_msg


*   E_S_MSG_HANDLE            =

*   E_MSG_WAS_LOGGED          =



       log_not_found             = 1

       msg_inconsistent          = 2

       log_is_full               = 3

       OTHERS                    = 4.

    IF sy-subrc NE 0.

      “Do nothing


    INSERT ls_log_handle INTO TABLE li_log_handle.

***Save message



       i_client               = sy-mandt

*   I_IN_UPDATE_TASK       = ‘ ‘

       i_save_all             = lc_set

       i_t_log_handle         = li_log_handle


*   E_NEW_LOGNUMBERS       =


       log_not_found          = 1

       save_not_allowed       = 2

       numbering_error        = 3

       OTHERS                 = 4.

    IF sy-subrc EQ 0.

      REFRESH: li_log_handle.


Usage of Application LOG

We can use application log in the below scenarios:

·      When we want to save the List/Log for the long time: Generally, we have the spool retention period of 8 days. So, the list or log will be deleted automatically.

·      When we want more information compared to Log generated with WRITE: Application Log has more information like User, date of creation, Severity of the message.

·      In ALE / EDI Processing: When we do the cross client processing (IDoc Processing), we can generate the Application log to keep track of the generated errors or the messages.

Summary of the steps to Create and View logs:

1)     1)  Create object and sub object in SLG0 transaction.

2)     2) The program where you want to create the LOG call the FMs:




3)     3)  For viewing the logs go to SLG1 transaction and give the object name, sub object name (if any) and other related information like the Username and date etc.

4)      Then click on Execute. You will be able to see the logs. Double click on any one of them to see the detailed error message.

        4) One can even view the logs through the program itself by using the FM BAL_DSP_LOG_DISPLAY.

You must be Logged on to comment or reply to a post.