Monday 27 May 2019

Global Class and Method for Application Log

The goal of the object is to create the Global Class and Method for Application Log so that it can be reused where necessary in any RICEF object.

Application Log provides an infrastructure for collecting messages and exceptions in a log, saving, reading and deleting logs in the database and displaying them.

Application Log provides multiple advantages:

◈ System-wide uniform event logging
◈ Accessible standardized UI based on ABAP List Viewer (ALV)
◈ High capabilities for analysis of log data

Application logging records the progress of the execution of an application. Whereas the system log records system events, you can use the application log to record application-specific events.

Application Log is designed to temporarily store messages. Logs should be deleted in intervals (e.g. weekly batch job for deleting logs) to avoid too high database load.

A typical use of the Application Log is within delivery processing. Negative results of a dangerous goods check are written to the Application Log. Application messages and reactions are collected based on a customer defined examination schema (reactions determine how the document will be handled further). This approach increases the transparency of the process for end users. Messages are collected temporarily and are not saved to the database.

First create object and sub object, Go to transaction SLG0.

Go to change mode and click on New entries button on the application tool bar.

ABAP Development, SAP ABAP Guides, SAP ABAP Certifications, SAP ABAP Tutorials and Materials

Then define the sub object for the object.

Select the object and double click on sub object.

ABAP Development, SAP ABAP Guides, SAP ABAP Certifications, SAP ABAP Tutorials and Materials

Create Global Class and Method to define the Application log code

ABAP Development, SAP ABAP Guides, SAP ABAP Certifications, SAP ABAP Tutorials and Materials

Define the following Parameter in Method

ABAP Development, SAP ABAP Guides, SAP ABAP Certifications, SAP ABAP Tutorials and Materials

Define following Data in the Method

ABAP Development, SAP ABAP Guides, SAP ABAP Certifications, SAP ABAP Tutorials and Materials

Populate the Header data with the following details

ABAP Development, SAP ABAP Guides, SAP ABAP Certifications, SAP ABAP Tutorials and Materials

Create the log with FM BAL_LOG_CREATE

ABAP Development, SAP ABAP Guides, SAP ABAP Certifications, SAP ABAP Tutorials and Materials

Add all the message in the log using FM BAL_LOG_MSG_ADD

ABAP Development, SAP ABAP Guides, SAP ABAP Certifications, SAP ABAP Tutorials and Materials

Save the Log using FM BAL_DB_SAVE

ABAP Development, SAP ABAP Guides, SAP ABAP Certifications, SAP ABAP Tutorials and Materials

Display the log using FM  BAL_DSP_LOG_DISPLAY

ABAP Development, SAP ABAP Guides, SAP ABAP Certifications, SAP ABAP Tutorials and Materials

Define that Class and method in the code wherever necessary

ABAP Development, SAP ABAP Guides, SAP ABAP Certifications, SAP ABAP Tutorials and Materials

The Method will create log with all the messages and generate log (Transaction SLG1)

ABAP Development, SAP ABAP Guides, SAP ABAP Certifications, SAP ABAP Tutorials and Materials

Code is attached.

No comments:

Post a Comment