如何使用应用日志(Application Log)

SAP的应用日志(Application Log)是用于创建,保存和分析系统消息的工具.

相关TCODE:

SLG0: Creation of Object and Sub object
SLG1: Display Application Logs

相关创建应用日志函数

BAL_LOG_CREATE --> Create log with header data
BAL_LOG_MSG_ADD --> Put message in log
BAL_DB_SAVE --> Save logs in the database

创建应用日志的处理步骤:

1: 使用TCODE:SLG0创建对象和子对象.
2: 创建对象,对象名以Z或Y开头.
3: 创建对象后,你将创建子对象.
4: 如果相应的子对象不存在,则创建子对象.
5: 这样对象和子对象就可以在应用日志中使用了.
6: 使用下面三个函数创建和保存应用日志
7: 使用'BAL_LOG_CREATE' 创建日志句柄(log handle)
8: 使用'BAL_LOG_MSG_ADD' 添加消息,
9: 使用'BAL_DB_SAVE' 保存日志

如何查看应用日志?

1. 输入TCODE: SLG1.系统将出现分析应用日志的屏幕.
2. 输入对象,子对象和外部标示符.
3. 输入时间.
4. 规定日志的原因
5. 选择日志类别和创建日志.
6. 执行.
系统将显示结果.

SAP的代码实例:

SBAL_DEMO_06

样例代码:

report sbal_demo_06 .
***********************************************************************
***********************************************************************
*                   REPORT SBAL_DEMO_06
*
*  The application log allows to add application specific data to
*  a log header or a message.
*
*  One simple possibility is to use the context. This allows to
*  to add the content of a (flat, non-hierarchical) DDIC-structure
*  to a log header or a message (sie sub-structure 'CONTEXT' in
*  structure BAL_S_LOG and BAL_S_MSG).
*  There is already an example in Report SBAL_DEMO_02 for this
*  (see FORM msg_add_with_context).
*
*  But sometimes a simple, flat DDIC-structure is not sufficient.
*  If you want to add more complex data (like an internal table,
*  a complex data type, etc.) to a log or a message,
*  you can use table BAL_INDX.
*
*  BAL_INDX is an INDX-like table which can be filled and read
*  with the ABAP-statement EXPORT/IMPORT.
*  This report shows an example how to use BAL_INDEX.
*
*  This report has three options:
*    o create  log
*    o display log
*    o delete  log
*
*  create log:
*  ==========
*  The log which is created consists of a log header
*  and only one message. For both, log header and message
*  the parameters are defined  (see sub-structure 'PARAMS' in
*  BAL_S_LOG and BAL_S_MSG).
*  The parameters are filled and callback routines are defined.
*  When the log is saved, also some internal tables containing
*  further data are saved via EXPORT TO BAL_INDX
*  (see FORM log_save)
*
*  display log:
*  ===========
*  The log is searched on the database, loaded and displayed.
*  When the detail of a message or the log header is selected
*  by the user, the callback-routines are called.
*  In this callback-routine the internal tables are read
*  with 'IMPORT FROM BAL_INDX'.
*  (see FORM CALLBACK_LOG_DETAIL or FORM CALLBACK_MSG_DETAIL, both
*   call FORM LOAD_MY_DATA).
*
*  delete log:
*  ===========
*  The log is searched on the database and deleted.
*  This deletion also deletes the data in table BAL_INDX for this
*  log.
*
***********************************************************************
***********************************************************************


***********************************************************************
******************** SELECTION SCREEN *********************************
***********************************************************************
parameters:
  p_create  radiobutton group par,
  p_disp    radiobutton group par,
  p_delete  radiobutton group par.

***********************************************************************
******************** CONSTANTS, TYPES, DATA ***************************
***********************************************************************
set extended check off.
include sbal_constants.
set extend

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值