Using Application Logging

New Site Address: http://abap.mirrorz.com

Make your own free website on Tripod.com



Home

Definitions
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 o