Description:
Easily usage of the SAP-Objects for the application log in complex Abap-OO applications.
Advantage to use it:
- Easy handling of the functions for the application log
 - Fast implementation of the application log
 
New development objects:
Abap interface
Abap class
Abap interface
Create a new interface with SE24/SE80
It needs the 3 events FIRE_MESSAGE, DISPLAY_LOG, REFRESH, SAVE
You can copy the source (text based editor) here zsk_if_applog
(FIRE_MESSAGE is actually enogh to demonstrate)
Abap class
Create a new class with SE24/SE80
You can copy the source (text based editor) here zsk_cl_applog
Usage
- Declare the interface in all classes, which have to use the application log.
 - Optional: use the alias in the class to shorten the event name
e.g.: FM instead of ZSK_IF_APP_LOG~FIRE_MESSAGE - Use the event to trigger the messages
raise event fm
exporting
imp_MSGID = ’00’
imp_MSGTY = ‘I’
imp_MSGNO = ‘398’
imp_MSGV1 = ‘Test Message’. - Now you just have to declare an object refering to the class, instantiate it and set the event handler:
 
Data: gr_log type ref to zsk_cl_applog.
CREATE OBJECT GR_LOG
    EXPORTING
        Imp LOG NAME     = LV_LOG_NAME    ” dynamic value e.g. document number
        Imp OBJECT          = c_OBJECT                ” to be customized in SLG0
        Imp SUBOBJECT = LV SUBOBJECT        ” to be customized in SLG0
        Imp DAYS                = c_DAYS                      “constant e.g. 60 
    EXCEPTIONS
        MISSING INPUT
        LOG NOT FOUND
        LOG HEADER INCONSISTENT 3
        INTERNAL ERROR
        Others
    IF SY-SUBRC 0.
        MESSAGE ID SY-MSGID TYPE ‘E’ NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        return.
    ENDIF.
“you can use also different instances and handle different logs in you applications
set HANDLER gr_log->CATCH_FIRED_MESSAGE for all instances.
- Don’t forget to save & / or display the log. Directly by the method save/display or from you application by triggering the event DISPLAY_LOG or SAVE.