Introduction
As mentioned in my wiki 'How to check and identify whether an issue on CRM WebUI is caused by enhancement of some component ..., with method CL_BSP_WD_COMPONENT_DESCRIPTOR->CONSTRUCOR, enhancement information will be retrieved from database table BSPWD_COMP_EXT and BSPWD_CMP_C_REPL when the page is accessed for the first time.
Inside that wiki, a way is introduced on how to by-pass enhancement of some specific component or view.
Here, I will introduce a way to list all the enhancement information for some specific operation. For example, I display a service request. In service request screen, there are several assignment blocks, like 'Details', 'Notes', 'Attachments', 'Status', 'Transaction history', 'business context', etc. I want to know which components are being used inside this service request page, and also want to know if any one of them has been enhanced.
Of course, we can set breakpoint in method CL_BSP_WD_COMPONENT_DESCRIPTOR->CONSTRUCOR. When we click on the service request from the result list to display it, breakpoint will stop every time when a component is processed. For example, it will stop when IV_COMPONENT_NAME = ‘SRQM_INCIDENT_H’, or ‘BTCATEGORIES’, or ‘BTDOCFLOW’, etc. Then we will know them and know if they have been enhanced. But the problem is the breakpoint will stop many times.
If we use debugger script feature in debugging, we are able to make the breakpoint stop less. In this document, firstly, I will introduce how to create the script. After that, I will give a step by step explanation of how to use it.
Understanding of related knowledge
Debugger scripting is a new debugging feature available as of SAP NetWeaver 7.0 Ehp2. It may be used to automate many actions.
We will write our own debugger script. Make it possible to stop at ‘select’ statement for the specific database tables BSPWD_COMP_EXT and BSPWD_CMP_C_REPL. If the ‘select’ statement is for database table BSPWD_COMP_EXT, we will write into trace file that if this component is enhanced or not. If the select statement is for database table BSPWD_CMP_C_REPL, and there are entries returned from this table, we will write into trace file all these entries one by one.
Prerequisite
Authorization to create, edit debugger script.
Sample
Make a search in INBOX with object id = ‘8000000364’ and display it. I will list all components used in the display screen into a trace file, together with enhancement information.
Detailed Steps
Step 1: Create a script and input source codes
Executing T-code SAS, navigate to ‘Script Editor’ tab. Default script ‘RSTPDA_SCRIPT_TEMPLATE’ is displayed:
We can see two parts: class definition part, class implementation part. We also see four methods: prologue, init, script and end. For our purpose, we only need to add source codes in method script. In order to do this, remove the default codes inside method ‘script’, then input following source codes:
METHOD script.
* define trace structure
DATA: ls_trace TYPE tpda_trace_custom.
*--select from db BSPWD_COMP_EXT-- begin
DATA: lv_db_stop_1 TYPE abap_bool,
lv_db_stop_2 TYPE abap_bool.
DATA: l_db_tables_it TYPE cl_tpda_script_scan_sql_sel=>ty_it_db_tables,
l_dbtab LIKE LINE OF l_db_tables_it,
l_scan_object TYPE REF TO cl_tpda_script_scan_sql_sel,
l_curr_dbtab TYPE string.
TRY.
l_scan_object ?= cl_tpda_script_scan=>scan(
p_program = abap_source->program( )
p_include = abap_source->include( )
p_line = abap_source->line( )
).
l_db_tables_it = l_scan_object->db_tables( ).
LOOP AT l_db_tables_it INTO l_dbtab.
IF l_dbtab-dynamic = abap_true.
l_curr_dbtab = cl_tpda_script_data_descr=>get_simple_value( p_var_name = l_dbtab-name ).
ELSE.
l_curr_dbtab = l_dbtab-name.
ENDIF.
IF l_curr_dbtab = 'BSPWD_COMP_EXT'.
lv_db_stop_1 = abap_true.
ELSEIF l_curr_dbtab = 'BSPWD_CMP_C_REPL'.
lv_db_stop_2 = abap_true.
ENDIF.
IF lv_db_stop_1 = abap_true OR lv_db_stop_2 = abap_true.
* if it is the select one of the two tables, one step over so that the select statement is executed
CALL METHOD debugger_controller->debug_step
EXPORTING
p_command = cl_tpda_script_debugger_ctrl=>debug_step_over.
ENDIF.
ENDLOOP.
CATCH cx_sy_move_cast_error.
* MESSAGE S049(TPDA_SCRIPT).
* ME->BREAK( ).
CATCH cx_tpda_script_scan_macro.
* MESSAGE S048(TPDA_SCRIPT).
* ME->BREAK( ).
CATCH cx_tpda_script_scan.
* MESSAGE S049(TPDA_SCRIPT).
* ME->BREAK( ).
CATCH cx_tpda_varname .
* MESSAGE S049(TPDA_SCRIPT).
* ME->BREAK( ).
CATCH cx_tpda_script_no_simple_type .
* MESSAGE S049(TPDA_SCRIPT).
* ME->BREAK( ).
CATCH cx_root.
* MESSAGE S049(TPDA_SCRIPT).
* ME->BREAK( ).
ENDTRY.
* scripts when select on db table BSPWD_COMP_EXT
IF lv_db_stop_1 = abap_true.
*--to read sy_subrc
DATA: lv_sy_subrc LIKE sy-subrc.
DATA: lv_component_name TYPE bsp_wd_component_name.
CALL METHOD cl_tpda_script_data_descr=>get_simple_value
EXPORTING
p_var_name = 'SY-SUBRC'
RECEIVING
p_var_value = lv_sy_subrc.
*--to read iv_component_name
CALL METHOD cl_tpda_script_data_descr=>get_simple_value
EXPORTING
p_var_name = 'IV_COMPONENT_NAME'
RECEIVING
p_var_value = lv_component_name.
IF lv_sy_subrc = 0.
*--trace information when this component is enhanced
ls_trace-value = 'component: ' && lv_component_name && ' has been enhanced '.
ELSE.
*--trace information when this component is not enhanced
ls_trace-value = 'component: ' && lv_component_name && ' is not enhanced '.
ENDIF.
*--write the trace information into trace file
CALL METHOD trace->add_custom_info
EXPORTING
p_trace_entry = ls_trace.
ENDIF.
* scripts when select on db table BSPWD_CMP_C_REPL
IF lv_db_stop_2 = abap_true.
DATA: lv_ehn_set TYPE bsp_wd_enhancement_set,
lv_com TYPE bsp_wd_component_name.
DATA: lt_replacements TYPE STANDARD TABLE OF bspwd_cmp_c_repl.
DATA: ls_entry TYPE bsp_wd_contr_replacement.
FIELD-SYMBOLS: <entry> TYPE bspwd_cmp_c_repl.
*--get enhancement set value
CALL METHOD cl_tpda_script_data_descr=>get_simple_value
EXPORTING
p_var_name = 'IV_ENHANCEMENT_SET'
RECEIVING
p_var_value = lv_ehn_set.
*--get component name
CALL METHOD cl_tpda_script_data_descr=>get_simple_value
EXPORTING
p_var_name = 'ME->DATA-COMP_NAME'
RECEIVING
p_var_value = lv_com.
*--select detailed enhancement information of all views under this component
SELECT * FROM bspwd_cmp_c_repl INTO TABLE lt_replacements
WHERE enhancement_set = lv_ehn_set AND
comp_name = lv_com.
LOOP AT lt_replacements ASSIGNING <entry> .
*--write trace information for every enhanced entry
CONCATENATE <entry>-replaced_c_appl <entry>-replaced_contr INTO ls_entry-replaced SEPARATED BY '/'.
TRANSLATE ls_entry-replaced TO LOWER CASE.
CONCATENATE <entry>-replacing_c_appl <entry>-replacing_contr INTO ls_entry-replacing SEPARATED BY '/'.
TRANSLATE ls_entry-replacing TO LOWER CASE.
ls_trace-value = '.... ' && ls_entry-replaced && ' is replaced by ' && '..' && ls_entry-replacing .
CALL METHOD trace->add_custom_info
EXPORTING
p_trace_entry = ls_trace.
ENDLOOP.
ENDIF.
ENDMETHOD. "script
After that, it will look like this:
Click ‘save as’ button, give a name and description:
Step 2: Add conditions
We need to make the script work on elect statement. So we check the checkbox 'Breakpoint Reached', and then click the 'pen' icon. In the pop up dialog, set ABAP command at 'select'.
Then we click on 'save' button.
Step 3: Use the debugger script
Others
Above steps can be used in several situations to get the enhancement information list. For example, when navigating to menus like 'Sales cycles', 'servcie operations', 'Inbox', 'Knowledge Search' ... from navigation bars, when going to the document details from result lists, etc.
There is also some special situations. For example, when we click a business role to access the CRM WebUI, we want to know what components are processed and which ones are enhanced. In this case, it is not enough to set breakpoint only in method CL_BSP_WD_VIEW_MANAGER->DO_REQUEST. Method CL_BSP_WD_APPL_CONTROLLER->DO_INIT is also involved. And also, when business role is initially accessed, there will be two debug session. What we need to do extrally are:
In case it is too long, I give an example in another article 'Use debugger scripts to list component/view enhancement information 2 – used in business role initi...seperatedly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
38 | |
19 | |
13 | |
13 | |
10 | |
10 | |
10 | |
10 | |
8 | |
8 |