Application Log implementation
To implement basic functionality of application log we need to create object and sub object.
- Creation of object and sub object:
For creating object and sub object go to SLG1 transaction. Select New Entries and create object.
- Then Use function modules for application log.
- BAL_LOG_CREATE
- BAL_LOG_MSG_ADD
- BAL_DB_SAVE
- SLG1 transaction for displaying existing logs.
- SLG2 transaction for deleting existing logs.
Code
DATA: ls_log TYPE bal_s_log,
ls_log1 TYPE bal_s_log ,
ls_log_handle TYPE balloghndl,
lt_log_handle TYPE bal_t_logh,
ls_msg TYPE bal_s_msg.
CLEAR:ls_log, ls_log1, ls_log_handle, ls_msg.
REFRESH:lt_log_handle.
ls_log-aldate = sy-datum.
ls_log-object = cv_object.
ls_log-subobject = cv_subobject.
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = ls_log
IMPORTING
e_log_handle = ls_log_handle.
IF sy-subrc <> 0.
ENDIF.
ls_msg-msgty = 'E'.
ls_msg-msgid = '/RB94/YG2_EX'.
ls_msg-msgno = '000'.
ls_msg-msgv1 = cv_message+0(50).
ls_msg-msgv2 = cv_message+50(50).
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_log_handle = ls_log_handle
i_s_msg = ls_msg.
IF sy-subrc <> 0.
ENDIF.
INSERT ls_log_handle INTO TABLE lt_log_handle.
CALL FUNCTION 'BAL_DB_SAVE'
EXPORTING
i_save_all = 'X'
i_t_log_handle = lt_log_handle.
IF sy-subrc <> 0.
ENDIF.