SAP CRM WebClient UI异常的持久化机制
When I am working together with local partner to resolve one issue caused by incorrect enhancement set configuration for new custom Product set type, I have realized that if the UI exception is raised and caught by framework, there would be no entry in ST22, which causes the difficulties for later trouble shooting.
When I am debugging the code how the framework handles with the exception, I found there is the possibility to let the framework call the error handler defined by ourselves being registered in table bsperrhandler.
So I think it is worthy to create a simple error handler class to persist the exception information into a new transparent table for later checking.
(1) create a class ZCL_ERROR_HANDLER with a static public method STORE_ERROR_INFO, signature as below:
Source code as below. Just extract error message text and the exact position which line of source code has raised the exception:
METHOD store_error_info.
DATA: lv_header_text TYPE string,
l_einternal TYPE REF TO cx_bsp_einternal,
l_exception TYPE REF TO cx_root,
l_program_name TYPE syrepid,
l_include_name TYPE syrepid,
l_source_line TYPE i,
lv_log_text TYPE string,
ls_log TYPE zbsplog.
l_exception = exception.
CHECK server IS NOT INITIAL AND exception IS NOT INITIAL.
lv_header_text = exception->get_text( ).
TRY.
l_einternal ?= exception.
CATCH cx_root.
ENDTRY.
IF l_einternal IS BOUND.
CALL METHOD l_einternal->get_source_position
IMPORTING
program_name = l_program_name
include_name = l_include_name
source_line = l_source_line.
ELSE.
WHILE l_exception->previous IS BOUND.
l_exception = l_exception->previous.
ENDWHILE.
CALL METHOD l_exception->get_source_position
IMPORTING
program_name = l_program_name
include_name = l_include_name
source_line = l_source_line.
ENDIF.
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_16 = ls_log-uuid.
ls_log-error_date = sy-datlo.
ls_log-error_time = sy-timlo.
ls_log-error_string = |<head><h1>{ lv_header_text }</h1><h2>Error Date:{ sy-datlo }</h2><h2>Error Time:{ sy-timlo }</h2>| &&
|<h3>Error program:{ l_program_name }</h3><h3>Error include:{ l_include_name }</h3><h3>Source code line number:{ l_source_line }</h3>|
&& |</head>|.
INSERT zbsplog FROM ls_log.
COMMIT WORK AND WAIT.
ENDMETHOD.
(2) Create a new transparent table to store the exception detail:
(3) Register the new error handler into table bsperrhandler:
(4) Write a simple report to list the exception information. Of course more elegant UI like ALV could be used:
data: lt_table type STANDARD TABLE OF zbsplog,
lv_error TYPE zbsplog-error_string.
FIELD-SYMBOLS:<item> TYPE zbsplog.
START-OF-SELECTION.
SELECT * INTO TABLE lt_table FROM zbsplog.
LOOP AT lt_table ASSIGNING <item>.
WRITE:/ 'guid: ', <item>-uuid,'date: ', <item>-error_date, <item>-error_time.
lv_error = <item>-error_string.
HIDE lv_error.
ENDLOOP.
AT LINE-SELECTION.
cl_demo_output=>display_html( lv_error ).
execute the report and double click one line item, the detail information would be displayed via the handy class cl_demo_output. With the include name and source code line number available, you could implement further handling like automatically navigation to the source code in ABAP editor by calling function module RS_TOOL_ACCESS with include name and source code number passed in.
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
- 程序实现下载文件或者打开文件
- VisualTreeHelper
- Linux下路由配置梳理
- Gitlab利用Webhook实现Push代码后的jenkins自动构建
- db4o 7.4 for .net3.5试用手记
- JQuery笔记(五) 圆角表格的效果
- tomcat内存溢出问题记录
- 微信小程序开放 Wi-Fi、NFC 连接能力,未来可直接刷地铁?
- 2017奇葩机器人大盘点:Sophia想生孩子,Atlas后空翻,贝佐斯骑高达
- silverlight:分享一个不错的自定义布局CollectionFlow(可用于制作相册的哦!)
- 无法取得ConnectionSettings的问题
- DataTable,List去重复记录的方法
- Uploadify的一点总结
- 自动驾驶时代,中国移动要以怎样的姿势进入?
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 使用Angular rxjs进行优雅限流
- Nginx自动重定向
- dotnet OpenXML SDK 形状的翻转与旋转
- C# dotnet 使用 AsyncEx 库的 AsyncLock 异步锁
- bt5.9手动开心
- 项目中多个文件引入同一份公共样式less文件导致编译打包后有多份样式
- Angular rxjs Observable的异步行为
- Angular rxjs里自定义operator的使用
- tensorflow 生成指定大小的赋值0的张量 np.zeros 在TF中对应的语句 生成全0张量
- Angular rxjs fromEvent使用的一个例子
- 在StackBlitz上setup SAP Spartacus
- [898]python获取两个list交集|并集|差集
- [897]使用Maxwell实时同步mysql数据
- Magicodes.IE之导入导出筛选器
- 一文搞懂Flink生成StreamGraph