SAP S4 HANA Application Log (User Manual)

The application log provides an infrastructure and a set of tools to record and monitor system/application-specific log messages in SAP. The application log allows users to monitor all message logs in S4 HANA system centrally.

Application log records system events, such as the execution of workflows for later use, especially to employ when it comes to troubleshooting.

Moreover, custom ABAP programs can store their own application-specific messages in the application log. System users can utilize these application-specific log messages mainly to check the recorded milestones of the application runtime.

view of application log transaction SLG1. Screen showing log header and multiple problem class messages in SAP S4 HANA.
Application log view – Transaction SLG1

Important Application Log Transactions

Following are the most important transactions related to application log mechanism in SAP S4 HANA.

SLG1 – View Application Log

User can analyze log messages with the help of transaction SLG1.

SLG1 transaction allows filtering messages based on:

  1. Object – In order to group messages in a logical way, each log message is assigned under an object and a sub-object. Users can filter messages based on these object/sub-object details.
  2. Time period – filtering based on the date and time when the log message was generated.
  3. Log trigger by Info – filtering based on the user, program, and transaction code details that generated the message.
  4. Log creation and class – filtering based on batch mode, dialog, and the ways how the log message was created.
  5. Log source – filtering based on data source of the log messages.
Selection screen of transaction slg1 with different select options highlighted.
SLG1 – Selection screen
Log analysis window – SLG1 transaction

SLG0 – Create Application Log Object

Application developers can create new application log objects and sub-objects to record messages of custom SAP applications. For example, a custom sales order upload program can use a specific application log object to record all the log messages generated when sales orders are uploaded through the custom application.

Create and Maintain Application Log Objects – Transaction SLG0

SLG2 – Delete Application Log Messages

This transaction allows admins to delete expired messages from the SAP S4 system. We will discuss further how to archive/delete log messages in the section “Ways to Delete Log Messages” of the article.


How Log Messages are Stored in S4 HANA DB

SAP stores log message information in two tables.

  • BALHDR – Log header
  • BALDAT – Log Data

We can identify each log message uniquely by log number (LOGNUMBER). BALHDR tables store the header detail of a log message. Header table contains important information, such as log object, sub-object, creation date/time, user, expiry date, etc.

Application Log Header Table – BALHDR

There can be multiple status messages under one log message. Table BALDAT holds information of status and actual log text of messages. Field LOG_HANDLE links the log message header table BALHDR to the log data table BALDAT.

It is important to notice BALDAT is a cluster table. DATA field of table BALDAT holds information in an encrypted format.

Application Log Item Table – BALDAT

ABAP Functional Modules Related to Logs

SAP has provided a set of Function Modules that can invoke certain application log functionalities, such as recoding a log, deleting a log, etc. These Function Modules can be used by developer to embed application log functionalities to custom ABAP programs.

Here is a list of commonly used FMs related to application logs:

  • BAL_LOG_CREATE – Open a log
  • BAL_LOG_MSG_ADD – Record a message in the log
  • BAL_DSP_LOG_DISPLAY – Display a log
  • BAL_DB_SAVE – Save application logs to HANA database

I have written a custom ABAP program using these Function Modules to record application log messages.


Ways to Delete Log Messages

Accumulation of log messages over a considerable period of time can create an unnecessary load on the SAP S4 HANA database. This is especially true if the system is generating a large volume of log messages in daily use. For example, if there is a large number of custom applications that record log messages in the system or if some components, such as Application Integration Framework, generate a considerable amount of log messages.

Hence, the unwanted/expired log messages should be regularly flushed from the system to avoid performance issues.

There are two ways to remove unwanted messages:

Delete Expired Log Messages

Log messages are useful when it comes to troubleshooting, except for the really old ones. Therefore, system admins should flush out these out-of-date log messages from the system regularly.

There are options in transaction SLG2 to delete messages that have expired. The program behind this transaction is SBAL_DELETE. To view the number of messages that have expired and can be flushed out, use the option “Only Calculate how many” in transaction SLG2.

Table/field BALHDR-ALDATE_DEL holds the expiry date of a log message at database level.

Delete Orphaned Log Messages

Although some applications use function module APPL_LOG_DELETE to delete application log messages, there could be instances where message data in BALDAT table is not deleted. In many cases, the system can contain records in BALDAT that do not have a corresponding header record in BALHDR. Such messages are called orphaned messages.

These orphaned messages can be removed from the database using the program SBAL_DELETE_ORPHAN_MESSAGES. Further information on the issue can be found in SAP note 2057897.


To summarize, we have discussed the use cases of Application Logs, how application logs are saved in SAP HANA database, Function Modules related to application log functionalities, and how to archive log messages from SAP system.

If you have any questions, please leave a comment below.

TECH GADGETS I USE EVERY DAY

These are some of the tech gadgets I use every day. If you make a purchase through these links I will earn a small comission at absolutely no extra cost to you.

Leave a Reply

Your email address will not be published.