您的位置:首页 > 移动开发

Application Log - TCODE & ABAP Code

2013-11-11 09:29 148 查看
Definition: SLG0

Display: SLG1

FM for Creating Application Log:

BAL_LOG_CREATE

BAL_LOG_MSG_ADD

BAL_DB_SAVE

Example Code:

DATA: ls_bal_msg    TYPE bal_s_msg,
it_msg        TYPE bal_t_msg,
lv_log_handle TYPE balloghndl,
ls_bap_log    TYPE bal_s_log.

* Fill message to it_msg
*...................

" Fill message to ls_bal_log
*  ls_bal_log-object     = lv_obj_id.
*  ls_bal_log-subobject  = lv_sub_obj_id.

CHECK it_msg IS NOT INITIAL.

* Create the BAL Log
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log                 = ls_bap_log
IMPORTING
e_log_handle            = lv_log_handle
EXCEPTIONS
log_header_inconsistent = 1
OTHERS                  = 2.

* Add the log to the list
LOOP AT it_msg INTO ls_bal_msg.
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_log_handle     = lv_log_handle
i_s_msg          = ls_bal_msg
EXCEPTIONS
log_not_found    = 1
msg_inconsistent = 2
log_is_full      = 3
OTHERS           = 4.
IF sy-subrc <> 0.
RAISE log_error.
ENDIF.
ENDLOOP.

" Commit
CALL FUNCTION 'BAL_DB_SAVE'
EXPORTING
i_save_all       = 'X'
EXCEPTIONS
log_not_found    = 1
save_not_allowed = 2
numbering_error  = 3
OTHERS           = 4.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: