Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *&---------------------------------------------------------------------*
- *& Report ZZ_SHOW_DATA_FROM_DUMP
- *&---------------------------------------------------------------------*
- *& In ST22 short dumps, the first 510 bytes of a structure are shown in a
- *& four-rows format (in a UTF16 system).
- *& This reports tries to align to the data structure and to display the
- *& data via RS_COMPLEX_OBJECT_EDIT
- *& Just specify the type of the structure, and then paste the
- *& four data rows into the text editor field.
- *& Data references and deep structures as components have to be replaced
- *& by appropriate X fields.
- *& Worked in my case, but is probably not working in general.
- *& Reason: The substitution of references &c. by 10 raw bytes
- *& The number '10' may be something else in other circumstances
- *&---------------------------------------------------------------------*
- report zz_show_data_from_dump.
- types: ty_dumpbin type x length 510.
- parameters: p_type type tabname.
- data: go_type type ref to cl_abap_structdescr.
- at selection-screen on p_type.
- perform get_datatype using p_type changing go_type.
- start-of-selection.
- perform start.
- * ---
- form start.
- data: lv_raw type ty_dumpbin,
- ls_data type ref to data.
- perform get_raw_from_input changing lv_raw.
- perform get_filled_dataobject using go_type lv_raw
- changing ls_data.
- perform display_data using p_type ls_data.
- endform.
- *
- * Enter 4*255 = 1020 hex digits
- * and place them into a 510 byte raw field
- * White space will be stripped away
- form get_raw_from_input changing cv_raw type ty_dumpbin.
- data: lt_rows type stringtab.
- call function 'TERM_CONTROL_EDIT'
- exporting
- titel = 'Vier Zeilen a 255 HexDigits'
- tables
- textlines = lt_rows
- exceptions
- user_cancelled = 1
- others = 2.
- perform build_dumpbin using lt_rows
- changing cv_raw.
- endform.
- * Splice the four rows, each of 255 hex digits, as given
- * in the dump, into a hex digit string,
- * and build the raw field from that
- form build_dumpbin using it_rows type stringtab
- changing cv_raw type ty_dumpbin.
- data: lv_row type string,
- lv_input_total type string,
- lv_digits type c length 1020,
- lv_idx_source type i,
- lv_idx_target type i,
- lv_idx_row type i,
- lv_idx_col type i.
- loop at it_rows into lv_row.
- condense lv_row.
- lv_input_total = lv_input_total && condense( lv_row ).
- endloop.
- translate lv_input_total to upper case.
- if strlen( lv_input_total ) ne 1020.
- message 'Try again: Enter 1020 non-blank characters!' type 'A'.
- endif.
- if not matches( val = lv_input_total regex = '^[0-9A-F]{1020}$' ).
- message 'Try again: Only hex digits allowed' type 'A'.
- endif.
- do 1020 times.
- lv_idx_source = sy-index - 1.
- lv_idx_row = lv_idx_source div 255.
- lv_idx_col = lv_idx_source mod 255.
- lv_idx_target = 4 * lv_idx_col + lv_idx_row.
- lv_digits+lv_idx_target(1) = lv_input_total+lv_idx_source(1).
- enddo.
- cv_raw = lv_digits.
- endform.
- * Given the type of the structure, create a data instance
- * and fill it with the hex data from IV_RAW
- form get_filled_dataobject using io_type type ref to cl_abap_structdescr
- iv_raw type ty_dumpbin
- changing value(es_data) type ref to data.
- field-symbols: <ls_data> type any,
- <lv_x> type x.
- create data es_data type handle io_type.
- assign es_data->* to <ls_data>.
- assign <ls_data> to <lv_x> casting.
- <lv_x> = iv_raw.
- endform.
- * Display a structure
- * IV_TYPE = Name of the type (used for information only)
- form display_data using iv_type type c
- is_data type ref to data.
- field-symbols: <ls_data> type any.
- assign is_data->* to <ls_data>.
- call function 'RS_COMPLEX_OBJECT_EDIT'
- exporting
- object_name = iv_type
- mode = space
- * INSERT_TAB = ' '
- * UPPER_CASE = ' '
- * POPUP = ' '
- * DISPLAY_ACCESSIBLE = ' '
- changing
- object = <ls_data>
- exceptions
- object_not_supported = 1
- others = 2.
- if sy-subrc <> 0.
- message id sy-msgid type 'A' number sy-msgno
- with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
- endif.
- endform.
- * Get data type for the target structure to map the bytes to
- * Replace components that may cause a problem by X fields of appropriate length
- form get_datatype using iv_type type tabname
- changing value(eo_type) type ref to cl_abap_structdescr.
- data: lo_type_orig type ref to cl_abap_structdescr,
- lo_type_abstract type ref to cl_abap_typedescr,
- lt_comp type cl_abap_structdescr=>component_table.
- field-symbols: <ls_comp> like line of lt_comp.
- cl_abap_structdescr=>describe_by_name(
- exporting p_name = iv_type
- receiving p_descr_ref = lo_type_abstract
- exceptions type_not_found = 1 ).
- if sy-subrc ne 0.
- sy-msgli = |Type { iv_type } not found|.
- message sy-msgli type 'E'.
- endif.
- lo_type_orig ?= lo_type_abstract.
- lt_comp = lo_type_orig->get_components( ).
- * Replace references by 10-byte raw components
- loop at lt_comp assigning <ls_comp> where type->type_kind ca 'gmvhr'.
- * Set length to 10 (why? a reference has only 8 bytes)
- <ls_comp>-type = cl_abap_elemdescr=>get_x( 10 ).
- endloop.
- if sy-subrc eq 0.
- eo_type = cl_abap_structdescr=>get( lt_comp ).
- else.
- * If structure doesn't contain deep components or references, the original type is OK
- eo_type = lo_type_orig.
- endif.
- endform.
Add Comment
Please, Sign In to add comment