Write to SAP Application Log

Thursday, 14 July 2016

SAP application log is a great method to display/save messages that occur when executing a SAP application. For custom applications, you can create your own application log object, which will enable user to see the log of the specific application in the future easily filtering using the object. Purpose of application log object is to logical segregation of messages.
With application log you can either save the messages in the system or show the messages as a popup to the user.


There are few important transactions when it comes to application log.

  1. Create application log object  - SLG0
  2. Display application log - SLG1
I will be explaining how to create application log objects, how to append messages using ABAP coding and finally display or save the messages.

Step 1: 
Go to transaction SLG0 and create application log main object and sub objects needed.





Step 2: 
Create your own message class using SE91.



Step 3: 
Add the messages to the application log at run time of the program.



Step 4: 
Show messages as a popup or save for later reference.



Main program:



Top Include:

Selection Screen:


Forms:

create_log_object: 
This will create and initialize the application log object. 






select_data: 
Depending on the result of the SQL, messages are added to application log.




add_single_msg: 
Any number of messages can be added similarly as below. You have to specify the message class, message number, type (E, I, W) and the message variables.


log: 
Messages are saved for later reference if the application is running in the background, else the messages are displayed as a pop up. 


save_log_db: 
Save the log to database which can be displayed using SLG1.


show_log: 
Log is shown as a pop up to the user. Setting the i_s_display_profile parameter enable you to show it as a popup.





if you run the program in the background you can check the log using SLG1. To view the log specify the log object. You can also specify other parameters such as date, time of execution, user name, program name if you need to check the past logs or narrow down the selection.






If the program is run on foreground the application log will be shown as a popup below.



Enjoy!! :)
Share

7 comments:

  1. It was very nice blog to learn about SAP BASIS. Thanks for sharing.SAP basis

    ReplyDelete
  2. Crafsol is the top IT company in Thane, Nashik which provide Top SAP Application Maintenance Support.It provides services like User Support, Applications Continuity, Minor Upgrades.

    ReplyDelete
  3. Thanks for sharing information, it help us a lot for Application Support.
    Application Development Services
    SAP Application Support

    ReplyDelete
  4. Thanks for sharing this Information,

    Got to learn new things from your Blog on Sap abap.

    http://thecreatingexperts.com/sap-abap-training-in-chennai/

    Both online and classroom training is provided.

    Contact 8122241286

    ReplyDelete

 
Copyright © 2015 Sap 4 All
Distributed By SAP 4 ALL |