Скрипт для поиска расширений
Скрипт позволяет найти расширения через отладчик.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
*<SCRIPT:PERSISTENT> REPORT rstpda_script_template. *<SCRIPT:HEADER> *<SCRIPTNAME>ZSB_ENHANCMENT_SEARCH</SCRIPTNAME> *<SCRIPT_CLASS>LCL_DEBUGGER_SCRIPT</SCRIPT_CLASS> *<SCRIPT_COMMENT>Поиск расширений</SCRIPT_COMMENT> *<BP_REACHED>X</BP_REACHED> *</SCRIPT:HEADER> *<SCRIPT:PRESETTINGS> *</SCRIPT:PRESETTINGS> *<SCRIPT:SCRIPT_CLASS> CLASS lcl_debugger_script DEFINITION INHERITING FROM cl_tpda_script_class_super . PUBLIC SECTION. METHODS: init REDEFINITION, script REDEFINITION, end REDEFINITION, get_abap_src_info RETURNING VALUE(rs_info) TYPE tpda_scr_prg_info RAISING cx_tpda_src_info, check_stack, check_breakpoints, check_bp IMPORTING iv_bp_type TYPE string it_stack TYPE tpda_stack_view_it. METHODS: check_events_in_stack IMPORTING is_stack_view TYPE tpda_stack_view. PRIVATE SECTION. TYPES: BEGIN OF ts_script_params, trace TYPE flag, debug TYPE flag, customer_exits TYPE flag, new_badi TYPE flag, old_badi TYPE flag, enhancements TYPE flag, bte TYPE flag, user_exits TYPE flag, END OF ts_script_params. DATA: mt_functions TYPE RANGE OF tpda_event. DATA: mt_forms TYPE RANGE OF tpda_event. DATA: mt_progs_cache TYPE HASHED TABLE OF tpda_scr_prg_info WITH UNIQUE KEY program include line. DATA: ms_script_params TYPE ts_script_params. ENDCLASS. "lcl_debugger_script DEFINITION *---------------------------------------------------------------------* * CLASS lcl_debugger_script IMPLEMENTATION *---------------------------------------------------------------------* * *---------------------------------------------------------------------* CLASS lcl_debugger_script IMPLEMENTATION. METHOD init. ms_script_params-trace = ms_script_params-customer_exits = ms_script_params-old_badi = ms_script_params-new_badi = ms_script_params-enhancements = ms_script_params-bte = abap_true. cl_ci_query_attributes=>generic( EXPORTING p_name = CONV #( sy-repid ) p_title = 'Параметры скрипта' p_attributes = VALUE #( ( kind = 'G' text = 'Параметры запуска' ref = REF #( sy-subrc ) ) ( ref = REF #( ms_script_params-trace ) kind = 'R' text = 'Создать файл трассировки' ) ( ref = REF #( ms_script_params-debug ) kind = 'R' text = 'Прерывание в отладчике' ) ( kind = 'G' text = 'Типы расширений' ref = REF #( sy-subrc ) ) ( ref = REF #( ms_script_params-customer_exits ) kind = 'C' text = 'Customer Exits' ) ( ref = REF #( ms_script_params-new_badi ) kind = 'C' text = 'New BAdI' ) ( ref = REF #( ms_script_params-old_badi ) kind = 'C' text = 'Old BAdI' ) ( ref = REF #( ms_script_params-enhancements ) kind = 'C' text = 'Enhancements' ) ( ref = REF #( ms_script_params-bte ) kind = 'C' text = 'BTE (OpenFI)' ) ( ref = REF #( ms_script_params-user_exits ) kind = 'C' text = 'User Exits' ) ) p_display = '' ). TRY. IF ms_script_params-old_badi = abap_true. cl_tpda_script_bp_services=>set_bp_method_global_class( p_methodname = 'GET_INSTANCE' p_classname = 'CL_EXITHANDLER' ). ENDIF. IF ms_script_params-customer_exits = abap_true. cl_tpda_script_bp_services=>set_bp_statement( p_statement = 'CALL CUSTOMER-FUNCTION' ). ENDIF. IF ms_script_params-enhancements = abap_true. cl_tpda_script_bp_services=>set_bp_statement( p_statement = 'ENHANCEMENT' ). ENDIF. IF ms_script_params-new_badi = abap_true. cl_tpda_script_bp_services=>set_bp_statement( p_statement = 'CALL BADI' ). cl_tpda_script_bp_services=>set_bp_statement( p_statement = 'GET BADI' ). ENDIF. cl_tpda_script_bp_services=>set_bp_stack_change( cl_tpda_script_bp_services=>c_script_bp ). CATCH cx_tpda_scr_bp. ENDTRY. IF ms_script_params-bte = abap_true. mt_functions = VALUE #( ( sign = 'I' option = 'CP' low = 'OPEN_FI_PERFORM_*' ) ( sign = 'I' option = 'CP' low = 'OUTBOUND_CALL_*' ) ( sign = 'I' option = 'CP' low = 'EXIT*' ) ). ENDIF. IF ms_script_params-user_exits = abap_true. mt_forms = VALUE #( ( sign = 'I' option = 'CP' low = 'USEREXIT*' ) ). ENDIF. ENDMETHOD. "init METHOD check_bp. CASE iv_bp_type. WHEN 'CALL CUSTOMER-FUNCTION'. CHECK ms_script_params-customer_exits = abap_true. WHEN 'ENHANCEMENT'. CHECK ms_script_params-enhancements = abap_true. WHEN 'CALL BADI' OR 'GET BADI'. CHECK ms_script_params-new_badi = abap_true. WHEN OTHERS. RETURN. ENDCASE. IF ms_script_params-debug = abap_true. me->break( ). ENDIF. IF ms_script_params-trace = abap_true. TRY. DATA(ls_program_info) = get_abap_src_info( ). CATCH cx_tpda_src_info. RETURN. ENDTRY. trace->add_custom_info( EXPORTING p_trace_entry = VALUE #( value = |{ iv_bp_type } AT: { it_stack[ 1 ]-eventtype } { it_stack[ 1 ]-eventname }, line: { it_stack[ 1 ]-line }, program:{ it_stack[ 1 ]-program }| type = iv_bp_type ) ). trace->add_src_info( ). trace->add_event_info( EXPORTING p_abap_only = abap_true ). ENDIF. ENDMETHOD. METHOD get_abap_src_info. cl_tpda_script_abapdescr=>get_abap_src_info( IMPORTING p_prg_info = rs_info ). READ TABLE mt_progs_cache WITH TABLE KEY program = rs_info-program include = rs_info-include line = rs_info-line TRANSPORTING NO FIELDS. IF sy-subrc = 0. RAISE EXCEPTION TYPE cx_tpda_src_info. ELSE. INSERT rs_info INTO TABLE mt_progs_cache. ENDIF. ENDMETHOD. METHOD check_stack. TRY. DATA(lt_stack) = cl_tpda_script_abapdescr=>get_abap_dynp_stack( ). CATCH cx_tpda_stack_error. ENDTRY. check_events_in_stack( is_stack_view = lt_stack[ 1 ] ). ENDMETHOD. METHOD check_breakpoints. TRY. DATA(lt_stack) = cl_tpda_script_abapdescr=>get_abap_dynp_stack( ). CATCH cx_tpda_stack_error. RETURN. ENDTRY. TRY. DATA(lt_breakpoints) = cl_tpda_script_bp_services=>get_reached_script_bps( ). CATCH cx_root. RETURN. ENDTRY. LOOP AT lt_breakpoints ASSIGNING FIELD-SYMBOL(<ls_breakpoint>) WHERE statementsta IS NOT INITIAL. check_bp( it_stack = lt_stack iv_bp_type = CONV #( <ls_breakpoint>-statementsta ) ). ENDLOOP. ENDMETHOD. METHOD script. check_stack( ). check_breakpoints( ). ENDMETHOD. "script METHOD end. ENDMETHOD. "end METHOD check_events_in_stack. DATA: ls_program_info TYPE tpda_scr_prg_info. CASE is_stack_view-eventtype. WHEN 'FUNCTION'. CHECK is_stack_view-eventname IN mt_functions AND ms_script_params-bte = abap_true. IF ms_script_params-trace = abap_true. TRY. ls_program_info = get_abap_src_info( ). CATCH cx_tpda_src_info. RETURN. ENDTRY. trace->add_custom_info( EXPORTING p_trace_entry = VALUE #( value = |FM { is_stack_view-eventname }| type = 'BTE(FM)' ) ). ENDIF. WHEN 'FORM'. CHECK is_stack_view-eventname IN mt_forms AND ms_script_params-user_exits = abap_true. IF ms_script_params-trace = abap_true. TRY. ls_program_info = get_abap_src_info( ). CATCH cx_tpda_src_info. RETURN. ENDTRY. trace->add_custom_info( EXPORTING p_trace_entry = VALUE #( value = |PROGRAM: { ls_program_info-program }, INCLUDE: { ls_program_info-include }, FORM { is_stack_view-eventname }| type = 'USER-EXIT' ) ). ENDIF. WHEN 'METHOD'. IF is_stack_view-eventname = 'GET_INSTANCE' AND is_stack_view-program CP 'CL_EXITHANDLER*' AND ms_script_params-old_badi = abap_true. TRY. DATA(lv_exit_name) = cl_tpda_script_data_descr=>get_simple_value( 'EXIT_NAME' ). CATCH cx_tpda_varname cx_tpda_script_no_simple_type. ENDTRY. IF ms_script_params-trace = abap_true. TRY. ls_program_info = get_abap_src_info( ). CATCH cx_tpda_src_info. RETURN. ENDTRY. ENDIF. IF NOT lv_exit_name IS INITIAL. IF ms_script_params-trace = abap_true. trace->add_custom_info( EXPORTING p_trace_entry = VALUE #( value = | OLD BADI: { lv_exit_name }| type = 'OLD_BADI' ) ). ENDIF. ELSE. TRY. IF ms_script_params-trace = abap_true. DATA(ls_instance) = cl_tpda_script_data_descr=>get_variable_info( p_var_name = 'INSTANCE' ). trace->add_custom_info( EXPORTING p_trace_entry = VALUE #( value = |OLD BADI : { ls_instance-vartype } | type = 'OLD_BADI' ) ). ENDIF. CATCH cx_tpda_varname . RETURN. ENDTRY. ENDIF. ELSEIF ( is_stack_view-eventname CP 'IPR_*' OR is_stack_view-eventname CP 'IPO_*' OR is_stack_view-eventname CP 'IWO_*' ) AND ms_script_params-enhancements = abap_true. IF ms_script_params-trace = abap_true. DATA(lv_type) = SWITCH string( is_stack_view-eventname+0(4) WHEN 'IPR_' THEN 'PreExit Method' WHEN 'IPO_' THEN 'PostExit Method' WHEN 'IWO_' THEN 'OverWrite-Exit Method' ELSE '' ). TRY. ls_program_info = get_abap_src_info( ). CATCH cx_tpda_src_info. RETURN. ENDTRY. SPLIT ls_program_info-program AT '=' INTO sy-msgv1 sy-msgv2 IN CHARACTER MODE. SPLIT ls_program_info-eventname AT '~' INTO sy-msgv2 sy-msgv3 IN CHARACTER MODE. trace->add_custom_info( EXPORTING p_trace_entry = VALUE #( value = |Class: { sy-msgv1 }, Method: { sy-msgv3 } | type = lv_type ) ). ENDIF. ELSE. RETURN. ENDIF. WHEN OTHERS. RETURN. ENDCASE. IF ms_script_params-trace = abap_true. trace->add_src_info( ). trace->add_event_info( EXPORTING p_abap_only = abap_true ). ENDIF. IF ms_script_params-debug = abap_true. me->break( ). ENDIF. ENDMETHOD. ENDCLASS. "lcl_debugger_script IMPLEMENTATION *</SCRIPT:SCRIPT_CLASS> *</SCRIPT:PERSISTENT> |
Об использовании читайте в статье.