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的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2712089/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SAP CRM WebClient UI的Delta處理機制介紹WebclientUI
- SAP CRM WebClient UI和Hybris Commerce的懶載入機制WebclientUI
- ABAP Webdynpro和CRM WebClient UI不同的UI表現機制WebclientUI
- 使用Selenium自動化測試SAP CRM WebClient UIWebclientUI
- SAP CRM WebClient UI和Fiori UI混搭並存WebclientUI
- SAP CRM WebClient UI和Hybris backoffice UI開發的相同點WebclientUI
- 將SAP CRM WebClient UI的表格匯出成PDFWebclientUI
- SAP CRM WebClient UI html 格式的 Text 顯示邏輯WebclientUIHTML
- SAP CRM WebClient UI 支援的一些 url 引數WebclientUI
- SAP CRM WebClient UI和Hybris的controller是如何被呼叫的WebclientUIController
- 在SAP CRM WebClient UI中用javascript觸發ABAP eventWebclientUIJavaScript
- SAP CRM WebClient UI的on_new_focus應該怎麼理解WebclientUI
- SAP CRM WebClient UI表格編輯模式的除錯明細WebclientUI模式除錯
- SAP CRM WebClient UI Text Type 顯示的過濾邏輯WebclientUI
- 在SAP CRM WebClient UI裡開啟ABAP Webdynpro頁面WebclientUI
- SAP CRM WebClient UI和ABAP Webdynpro頁面的互相跳轉WebclientUI
- SAP CRM WebClient UI cross component跳轉的一個具體例子WebclientUIROS
- SAP CRM WebClient UI Text 可編輯與否的控制邏輯WebclientUI
- Hybris service layer和SAP CRM WebClient UI架構的橫向比較WebclientUI架構
- redis的持久化機制Redis持久化
- SAP CRM WebClient UI上以html格式顯示note的問題討論WebclientUIHTML
- SAP 電商雲 Accelerator 和 Spartacus UI 的工作機制差異UI
- SAP WebClient UI的白屏問題分析WebclientUI
- SAP CRM WebClient UI上將text area裡的文字清空的後臺處理WebclientUI
- ABAP Webdynpro和WebClient UI不同的會話管理機制WebclientUI會話
- redis持久化機制Redis持久化
- 如何把SAP CRM WebClient UI上某個欄位高亮加粗顯示WebclientUI
- Jerry答網友提問:SAP CRM WebClient UI裡的EXT,STRUCT等含義WebclientUIStruct
- 三種動態控制SAP CRM WebClient UI assignment block顯示與否的方法WebclientUIBloC
- Java異常機制Java
- SAP WebClient UI的會話重啟原理WebclientUI會話
- 使用note++開發SAP WebClient UIWebclientUI
- 如何在SAP WebClient UI裡使用jChartFXWebclientUI
- Product settype在CRM WebClient UI架構中的地位WebclientUI架構
- SAP WebClient UI One Hit Navigation的實現方法WebclientUINavigation
- 異常處理機制
- 在SAP WebClient UI裡顯示倒數計時的UIWebclientUI
- Angular的scope. apply和CRM WebClient UI的modify方法AngularAPPWebclientUI