First go to SLG0 tcode, and setup Object 'ZCMS'
then put below code in your program
DATA: ls_log TYPE BAL_S_LOG. " CMS Logging
DATA: ls_msg TYPE BAL_S_MSG.
DATA: ls_LOG_HANDLE TYPE BALLOGHNDL.
DATA: lt_LOG_HANDLE TYPE BAL_T_LOGH.
CLEAR : ls_log.
ls_log-object = 'ZCMS'.
ls_log-aluser = sy-uname.
ls_log-alprog = sy-repid.
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
I_S_LOG = ls_log
IMPORTING
E_LOG_HANDLE = ls_log_handle
EXCEPTIONS
LOG_HEADER_INCONSISTENT = 1
OTHERS = 2.
CLEAR: ls_msg.
ls_msg-msgty = 'S'.
ls_msg-msgid = 'ZCRM'.
ls_msg-msgno = '000'.
ls_msg-msgv1 = 'Process Type'.
ls_msg-msgv2 = ''.
ls_msg-msgv3 = lv_process_type.
ls_msg-probclass = 2.
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
I_LOG_HANDLE = ls_log_handle
I_S_MSG = ls_msg
EXCEPTIONS
LOG_NOT_FOUND = 1
MSG_INCONSISTENT = 2
LOG_IS_FULL = 3
OTHERS = 4.
INSERT ls_log_handle INTO TABLE lt_log_handle.
CALL FUNCTION 'BAL_DB_SAVE'
EXPORTING
I_CLIENT = SY-MANDT
I_IN_UPDATE_TASK = 'X'
I_SAVE_ALL = 'X'
I_T_LOG_HANDLE = lt_log_handle
EXCEPTIONS
LOG_NOT_FOUND = 1
SAVE_NOT_ALLOWED = 2
NUMBERING_ERROR = 3
OTHERS = 4.
IF SY-SUBRC EQ 0.
REFRESH: lt_log_handle.
ENDIF.
No comments:
Post a Comment