Start of Content Area

Procedure documentationBasics  Locate the document in its SAP Library structure

Use

You use the following function modules and types to collect messages and display logs.

Function module

Use

BAL_LOG_CREATE

Create log with header data

BAL_LOG_MSG_ADD

Put message in log

BAL_LOG_EXCEPTION_ADD

Put exception in log

BAL_DSP_LOG_DISPLAY

Display messages in memory

 

Types

Use

BAL_S_LOG

Contains log header data

BAL_S_MSG

Contains message data

BAL_S_EXC

Contains exception data

BALLOGHNDL

Log handle

BALMSGHNDL

Message handle

ExampleThe program SBAL_DEMO_01 simulates a flight check. The check result is logged.

The program SBAL_DEMO_07 logs exception texts for the same checks.

Procedure

Open log

You open a log in Application Log with the function module BAL_LOG_CREATE. You can pass the log header data to this function module in the importing parameter I_S_LOG_HEADER with the structure BAL_S_LOG.

The function module BAL_LOG_CREATE returns the log handle (LOG_HANDLE, CHAR22). The LOG_HANDLE is a globally unique identifier (GUID) which identifies a log uniquely. You can access this log with this handle, e.g. to change the header data (function baustein BAL_LOG_HDR_CHANGE) or to put a message in the log (function baustein BAL_LOG_MSG_ADD). The LOG_HANDLE has its permanent value immediately and remains valid after saving.

Put messages in the Log

A message is put in the log identified by the log handle I_LOG_HANDLE.

The message data is provided in the function module BAL_LOG_MSG_ADD by the importing parameter I_S_MSG (structure BAL_S_MSG).

This data is mostly the T100 information (message type, work area, message number, the 4 message variables). You can also pass other information, e.g. application-specific data (context), parameters for a long text and a callback routine. For more information, see Which Data Can be Collected?.

Put Exceptions in the Log

An exception text is put in the log that is identified by I_LOG_HANDLE.

The exception class, error severity, problem class, and detail level are given to the function module BAL_LOG_EXCEPTION_ADD by means of the IMPORTING parameter I_S_EXC (structure BAL_S_EXC). Context information for exceptions, and the cumulated adding of exceptions are not supported.

The function modules BAL_LOG_MSG_ADD, BAL_LOG_MSG_CUMULATE, etc. return the message handle E_S_MSG_HANDLE.
The message handle comprises the log handle of the log to which the message belongs and an internally-assigned serial number (MSGNUMBER). The handle identifies a message uniquely. You can use it to access a message to change it (function modules BAL_LOG_MSG_CHANGE and BAL_LOG_EXCEPTION_CHANGE) or read it (function modules BAL_LOG_MSG_READ and BAL_LOG_EXCEPTION_READ), for example. You can add parameters to these function modules to change the log format and to display a subset of all messages in the main memory. For more information, see Log Display.

NoteThe log handle is optional for function modules such as BAL_LOG_MSG_ADD, BAL_LOG_MSG_CUMULATE, BAL_LOG_MSG_ADD_FREE_TEXT, etc. If you do not specify it, the default log is used. You can set it (and other defaults) with the function module BAL_GLB_MSG_DEFAULTS_SET. If no default log is defined, it is automatically set by the function module BAL_LOG_CREATE (see the function module documentation for BAL_TP_DEFAULTS_SET_GET).

Display Log

You can display the collected messages with the function module BAL_DSP_LOG_DISPLAY. This function module can be called  without parameters. All messages in memory are displayed in a standard format (this standard format is used e.g. in the transaction SLG1).

 

End of Content Area