Using Application Logging

New Site Address:


OK Code Values
Other Useful Tips
SAP and ABAP Links
SAP Functions
SAP Reports
SAP Tables
Source Code
Transaction Codes

Site Map (Index)

ABAP Keyword Help

Using Application Logging

SAP provides a method to use a standard logging facility for all of your custom ABAP programs. It consists of several transaction codes, tables, and function modules. By using the SAP functionality, it is possible to have a standard way to store error messages, making the handling of errors much simpler, and increasing the maintainablity of code.

Transaction Codes: SLG0 is used to configure categories for the error messages, and SLG1 is used to view the messages.

Tables: BALHDR is the main (header table), and BALM contains all of the detailed messages.

Function Modules: Much like the SAP function modules used to send email, these function modules would benefit from having a simpler interface wrapped around them. The function modules can be found in Function Group SLG0. Look for the INIT, HEADER, and MESSAGE function modules, as well as the WRITE_DB (I think that is the name...). If you want examples of how these function modules are used, please do a where used on them. I am unable to post the SAP examples here.

All APPL_LOG function modules are from 3.0. Starting at 4.6, see function groups that start with SBAL.

3.0 to 4.5 Function Modules

Create application log

Function group SLG0

You write the application log records with these function modules.

APPL_LOG_WRITE_HEADERWith this function module, you write the log header data in local memory.
APPL_LOG_WRITE_LOG_PARAMETERSWith this function module, you write the name of the log parameters and the associated values for the specified object or sub-object in local memory. If this function module is called repeatedly for the same object or sub-object, the existing parameters are updated accordingly. If you do not specify an object or sub-object with the call, the most recently used is assumed.
APPL_LOG_WRITE_MESSAGESWith this function module you write one or more messages, without parameters, in local memory.
APPL_LOG_WRITE_SINGLE_MESSAGEWith this function module you write a single message, without parameters, in local memory. If no header entry has yet been written for the object or sub-object, it is created. If you do not specify an object or sub-object with the call, the most recently used is assumed.
APPL_LOG_WRITE_MESSAGE_PARAMSWith this function module you write a single message, with parameters, in local memory. Otherwise the function module works like APPL_LOG_WRITE_SINGLE_MESSAGE.
APPL_LOG_SET_OBJECTWith this function module, you create a new object or sub-object for writing in local memory. With a flag you can control whether the APPL_LOG_WRITE_... messages are written in local memory or are output on the screen.
APPL_LOG_INITThis function module checks whether the specified object or sub-object exists and deletes all existing associated data in local memory.
APPL_LOG_WRITE_DBWith this function module you write all data for the specified object or sub-object in local memory to the database. If the log for the object or sub-object in question is new, the log number is returned to the calling program.

Display application log

Function group SLG3

With these function modules you display logs for analysis.

APPL_LOG_DISPLAYWith this function module you can analyze logs in the database.
APPL_LOG_DISPLAY_INTERNWith this function module you can analyze logs in local memory, e.g. when you have only collected log records at runtime and do not want to write to the database.

Read application log

Function group SLG1

If you want to analyze the log yourself, you can read the logs with these function modules.

APPL_LOG_READ_DBWith this function module you read the log data in the database for an object or sub-object according to specified selection conditions.
APPL_LOG_READ_INTERNWith this function module you read all log data whose log class has at least the specified value, from local memory, for the specified object or sub-object.

Delete application log

Function group SLG2

With this function module you delete logs.

APPL_LOG_DELETEWith this function module you delete logs in the database according to specified selection conditions

4.6 Function modules for writing application logs.

Much more flexible than old functions. Modules are relatively well documented. Read the documentation.

Run SBAL_DOCUMENTATION to see detailed documentation.

Simple call

BAL_LOG_CREATECreate log with header data
BAL_LOG_MSG_ADDPut message in log
BAL_DSP_LOG_DISPLAYDisplay messages in memory

Methods of collecting messages

BAL_LOG_CREATECreate log with header data
BAL_LOG_MSG_ADDPut message in log
BAL_LOG_MSG_CUMULATEAdd message cumulated
BAL_LOG_MSG_REPLACEReplace last message
BAL_GLB_MSG_CURRENT_HANDLE_GETGet current message handle
BAL_LOG_MSG_DELETEDelete message
BAL_LOG_MSG_CHANGEChange message
BAL_GLB_MSG_DEFAULTS_GETGet message defaults

Program SBAL_DEMO_02

Find and read messages in memory

BAL_GLB_SEARCH_LOGFind logs in memory
BAL_GLB_SEARCH_MSGFind messages in memory
BAL_LOG_HDR_READRead log header and other data
BAL_LOG_MSG_READRead message and other data

Program SBAL_DEMO_03

Log display and display profiles

BAL_DSP_PROFILE_STANDARD_GETStandard profile (SLG1) for a lot of logs
BAL_DSP_PROFILE_SINGLE_LOG_GETStandard profile (SLG1) for one log
BAL_DSP_PROFILE_NO_TREE_GETDisplay without tree (fullscreen)
BAL_DSP_PROFILE_POPUP_GETDisplay without tree (popup)

Program SBAL_DEMO_04

Display log in subscreen

BAL_DSP_OUTPUT_INITInitialize output
BAL_DSP_OUTPUT_SET_DATASet dataset to be displayed


Log display in Control Container

BAL_CNTL_CREATECreate Control for log display
BAL_CNTL_REFRESHPut new data in log display
BAL_CNTL_FREERelease Control


Save, load, find and delete logs in the database

BAL_DB_SAVESave logs in the database
BAL_DB_SEARCHFind logs in the database
BAL_DB_LOADLoad logs from the database
BAL_LOG_REFRESHDelete log from memory
BAL_GLB_MEMORY_REFRESH(Partially) reset global memory
BAL_DB_DELETEDelete logs from the database

Program SBAL_DEMO_05

Change logs

BAL_DB_LOADLoad log(s)
BAL_DB_SAVESave log(s)
BAL_LOG_MSG_CHANGEChange message
BAL_LOG_MSG_DELETEDelete message
BAL_LOG_HDR_CHANGEChange log header
BAL_LOG_DELETEDelete log (from database also at Save)
BAL_LOG_REFRESHDelete log from memory

Start transaction: Initializations

BAL_GLB_CONFIG_SETSet configuration
BAL_GLB_CONFIG_GETRead configuration
BAL_GLB_MEMORY_REFRESH(Partially) initialize memory

Working roll area-independently

BAL_GLB_MEMORY_EXPORTPut function group memory in ABAP-MEMORY
BAL_GLB_MEMORY_IMPORTGet function group memory from ABAP-MEMORY

Data and existence checks

BAL_LOG_HDR_CHECKCheck log header data for consistency
BAL_LOG_MSG_CHECKCheck message data for consistency
BAL_LOG_EXISTCheck existence of a log in memory
BAL_LOG_MSG_EXISTCheck existence of a message in memory

Read or check Application Log object and subobject

BAL_OBJECT_SELECTRead Application Log objects table record
BAL_SUBOBJECT_SELECTRead subobject table record
BAL_OBJECT_SUBOBJECTCheck whether object and subobject exist and the combination is allowed

Log Display: Detail screens

BAL_DSP_MSG_LONGTEXTDisplay message long text
BAL_DSP_MSG_PARAMETERSEither output extended long text or call a callback routine (based on the data in BAL_S_MSG-PARAMS)
BAL_DSP_MSG_TECHNICAL_DATAOutput technical data of a message such as work area, error number, etc.
BAL_DSP_LOG_PARAMETERSEither output extended long text or call a callback routine (based on the data in BAL_S_LOG-PARAMS)
BAL_DSP_LOG_TECHNICAL_DATAOutput all log header data

Here is some documentation on SAP's logging:

PDF format -
HTML document -

New Site Address:

Send any hints or tips to ABAP Hints & Tips .
All submissions will be recognized along with the tip.

Get a cool web address
Free subdomains from