下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、sap提供标准两数來操作应川h志,这篇文章将详细介绍如何使川应川h志。1> 和关 tcodeslgo > used to maintain the log objectslg1 -> used to view the log2、配置步骤1)运行slgo,系统将弹出一个提示窗口,点击“ok“按钮;2)点击噺增”按钮,在对象名中输入”ztestlog”,在描述中”test log“,并点击”保存”按钮;3、开发步骤1)川se11创建一个结构乙log_message,结构的字段如f:compone ntcomp onent typemsgtysymsgtymsg_text_1sym
2、sgvmsg_text_2symsgvmsg_text_3symsgvmsg_text_4symsgv2) 用se91创建消息类zmessage,并在999输入四个占位符(&)3) 用se37创建函数族”zlog”4) 在创建函数纽后创建函数,ziu_message_logging,*import parameters:l_log_object type balobj d -> application log: object name (application code)i extnumber type string -> application log: external
3、 idexport parameters: nonechanging parameters: nonetables parameters:t_log_message type z_log_messageexceptions:log_header_inconsistentlogging error代码如f:function ziu_message_logging."“local interface:*h importing *h reference(i_log_object) type balobj_d*" reference(i_extnumber) type string
4、*m tables*n t_log_message structure z_log_message*" exceptions*" log_header_inconsistent*n logging_error* author:ashim chowdhury* description: this function module is used insert messages in the* application logconstants: c_message type syst-msgid value message, c_999 type syst-msgno value
5、 '999'.data:l_log_handle type balloghndl, l_s_log type bal_s_log, l_dummy type string, l_ext_no type bal_s_log-extnumber, l_s_mdef type bal_s_mdef. if t_log_message is not initial. lsjog-object = l_log_object. i_ext_no = l_extnumber.i s log-extnumber = i ext no.* create the log with header d
6、atacall function 'bal_log_create'exportingi_s_log = l_s_logimportinge log handle = i log handleexceptionslog_header_inconsistent = 1others = 2.if sy-subrc <> 0.case sy-subrcwhen 1.raise log_header_inconsistent.when othersraise logging_error endcase.endif.i_s_mdef-log_handle = l_log_ha
7、ndle.* set the default valuecall function ,bal_glb_msg_defaults_set,exportingi s msg defaults = i s mdefexceptionsothers = 0.* loop the message table and write the messages into the logloop at t_log_message* use the message type zmessage and msg no 999* issue the message in a dummy variablemessage i
8、d c_message type t_log_message-msgty number c_999 with t_log_message-msg_text_1 t_log_message-msg_text_2 t_log_message-msg_text_3 t_log_message-msg_text_4 into l_dummy.* the parameters set by message statement will be used* add the message in the logperform msg_add.endloop * save logs in the databas
9、ecall function ,bal_db_save,exporting l_save_all = xexceptionslog_not_found = 1save_not_allowed = 2numbering_error = 3others = 4if sy-subrc <> 0.message id sy-msgid type sy-msgty number sy-msgnowith sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.endif.endif.endfunction.* form msg_addadd the message to th
10、e logform msg_adddata:l_s_msg type bal_s_msg.* define data of message for application logl_s_msg-msgty = sy-msgty.i_s_msg-msgid = sy-msgid l_s_msg-msg no = sy-msgno.i_s_msg-msgv1 = sy-msgv1.i_s_msg-msgv2 = sy-msgv2.i_s_msg-msgv3 = sy-msgv3 i_s_msg-msgv4 = sy-msgv4.* add this message to log file* (l_
11、log_handle is not specified, we want to add to the default log.* if it does not exist we do not care =>exceptions log_not_found = 0)call function 'bal_log_msg_add'exporting* l_log_handle =i_s_msg = l_s_msgexceptionslog_not_f ound = 0others = 1.if sy-subrc <> 0.message id sy-msgid ty
12、pe sy-msgty number sy-msgnowith sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4endif.endform.5) 在程序屮使川ziu.message.logging函数來维护应用fl志,代码如下data declarations* internal table for message loggingdata: it_log_message type standard table of z_log_message, wa_log_message type z_log_message,l_ext_number type string.con s
13、tants:c_obj_zxiproxy type balobj_d value 'ztestlog*.* now populate the internal table with the log messages as shown below. wa_log_message-* msgty is the type of the message* e -> error, w -> warning, s -> success* logging code for insert message into logclear wa_log_messagewa_log_messa
14、ge-msgty = "e1. “ can use w or s wa_log_message-msg_text_1 = < message text 1> wa_log_message-msg_text_2 = < message text 2> wa_log_message-msg_text_3 = < message text 3> wa_log_message-msg_text_4 = < message text 4>* append the message into the internal table append wa_
15、log_message to it_log_messageat the end transfer the log message to the system log by calling function module ziu_message_logging. i_ext_number w川 bt any str泊g of your choice.* function module ziu_message_logging will do the logging* ijog_object is the object type (to be configrd using txn slgocall function ,ziu_message_logging,exportingi_log_object = c_obj_zxiproxyi_extnu mber = l_ext_numbertablest_lo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 初中化学题库及答案
- 初一数学期末考试试卷及答案
- 初级电焊工理论考试题及答案
- 2026春统编版小学道德与法治五年级下册《我们的公共生活》课时练习及答案
- 统编版(2024)八年级上册语文期末质量测试卷(含答案解析)
- 2025秋人教版(新教材)初中信息科技人工智能专册上学期知识点及期末测试卷及答案
- 2026年初级行政专员面试题及答案
- 2026年电信行业技术面试题及答案解析
- 2026年河南省洛阳市三年级英语上册月考考试试卷及答案
- 机械设备材料转让协议书
- 英语试卷+答案黑龙江省哈三中2025-2026学年上学期高二学年12月月考(12.11-12.12)
- 中北大学2025年招聘编制外参编管理人员备考题库(一)参考答案详解
- 中华联合财产保险股份有限公司2026年校园招聘备考题库及一套完整答案详解
- 诗经中的爱情课件
- 2025年烟花爆竹经营单位安全管理人员考试试题及答案
- 2025天津大学管理岗位集中招聘15人参考笔试试题及答案解析
- 2025年云南省人民检察院聘用制书记员招聘(22人)考试笔试参考题库及答案解析
- TCAMET02002-2019城市轨道交通预埋槽道及套筒技术规范
- 24- 解析:吉林省长春市2024届高三一模历史试题(解析版)
- 安徽绿沃循环能源科技有限公司12000t-a锂离子电池高值资源化回收利用项目(重新报批)环境影响报告书
- 厦深铁路福建段某标段工程投标施工组织设计
评论
0/150
提交评论