SAP日志log:SLG0,SLG1
首先创建日志对象
slg0:
调用函数添加维护日志
*1.变量定义
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*2.赋值
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*2.创建日志,得到句柄
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*2消息类型处理
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*3添加日志
*----------------------------------------------------------------------*
"
IMPORTING
"
E_S_MSG_HANDLE
=
"
E_MSG_WAS_LOGGED
=
"
E_MSG_WAS_DISPLAYED
=
……如果添加多次,多次调用add函数
*----------------------------------------------------------------------*
*4保存日志
*----------------------------------------------------------------------*
*-----------------------------------------------------------------------
*-----------------------------------------------------------------------
*&---------------------------------------------------------------------*
*&"显示日志: 最简单的显示方式
*&---------------------------------------------------------------------*
CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
* EXPORTING
* I_S_DISPLAY_PROFILE
=
* I_T_LOG_HANDLE
=
* I_T_MSG_HANDLE
=
* I_S_LOG_FILTER
=
* I_S_MSG_FILTER
=
* I_T_LOG_CONTEXT_FILTER
=
* I_T_MSG_CONTEXT_FILTER
=
* I_AMODAL
= '
'
* I_SRT_BY_TIMSTMP
= ' '
* IMPORTING
* E_S_EXIT_COMMAND
=
* EXCEPTIONS
* PROFILE_INCONSISTENT
= 1
* INTERNAL_ERROR
= 2
* NO_DATA_AVAILABLE
= 3
* NO_AUTHORITY
= 4
* OTHERS
= 5
IF sy-subrc <> 0.
ENDIF.
*&---------------------------------------------------------------------*
*&"显示日志: no_tree display方法:
*&---------------------------------------------------------------------*
DATA:
* get display profile
CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'
" 然后再调用
CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
*&---------------------------------------------------------------------*
*&"显示日志: 弹出窗口形式::
*&---------------------------------------------------------------------*
*DATA:
* l_s_display_profile TYPE
bal_s_prof.
* get a prepared profile
CALL FUNCTION 'BAL_DSP_PROFILE_POPUP_GET'
*"然后再调用:
CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
可以可以直接进入slg1,然后查看日志
大概的记录log的方法就是这样子,因为有数据库操作,必然会耗时,什么时候考虑加日志,根据业务要求和具体重要程度去判断吧
http://blog.sina.com.cn/sapliumeng