Ниже пример того как можно посмотреть шестнадцатеричное представление файла с помощью текстового редактора реализованного через класс cl_gui_textedit. Обратите внимание что в качестве контейнера для редактора служит экран выбора программы, а ссылку на него можно получить через статическую переменную screen0 класса cl_gui_container.
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 |
REPORT zhex_view. DATA: go_textedit TYPE REF TO cl_gui_textedit, gt_exclude TYPE TABLE OF rsexfcode, gs_exclude TYPE rsexfcode. PARAMETER: DUMMY(1). INITIALIZATION. gs_exclude-fcode = 'ONLI'. APPEND gs_exclude TO gt_exclude. AT SELECTION-SCREEN OUTPUT. PERFORM s1000_pbo. *&---------------------------------------------------------------------* *& Form S1000_PBO *&---------------------------------------------------------------------* FORM s1000_pbo. IF go_textedit IS INITIAL. DATA lt_filetable TYPE filetable. DATA ls_filetable TYPE LINE OF filetable. DATA l_rc TYPE I. DATA l_action TYPE I. CALL FUNCTION 'RS_SET_SELSCREEN_STATUS' EXPORTING p_status = '%_00' p_program = 'RSSYSTDB' TABLES p_exclude = gt_exclude. CALL METHOD cl_gui_frontend_services=>file_open_dialog CHANGING file_table = lt_filetable rc = l_rc user_action = l_action EXCEPTIONS file_open_dialog_failed = 1 cntl_error = 2 error_no_gui = 3 not_supported_by_gui = 4 OTHERS = 5. IF sy-subrc NE 0. LEAVE PROGRAM. ELSEIF l_action NE cl_gui_frontend_services=>action_ok. LEAVE PROGRAM. ELSE. READ TABLE lt_filetable INDEX 1 INTO ls_filetable. ASSERT sy-subrc = 0. DATA l_xstring TYPE XSTRING. DATA l_string TYPE STRING. DATA lt_textedit TYPE abaptxt255_tab. PERFORM read_bin_file USING ls_filetable-filename CHANGING l_xstring. l_string = l_xstring. CALL FUNCTION 'SWA_STRING_TO_TABLE' EXPORTING character_string = l_string IMPORTING character_table = lt_textedit[]. CREATE OBJECT go_textedit EXPORTING parent = cl_gui_container=>screen0. CALL METHOD go_textedit->set_wordwrap_behavior EXPORTING wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position wordwrap_position = 120. CALL METHOD go_textedit->set_text_as_stream EXPORTING text = lt_textedit. CALL METHOD go_textedit->set_readonly_mode EXPORTING readonly_mode = 1. ENDIF. ENDIF. SET TITLEBAR 'TIT' OF PROGRAM 'SAPLDSYP' WITH 'File Hex Viewer'(001). ENDFORM. "s1000_pbo FORM read_bin_file USING i_filename TYPE CLIKE CHANGING e_file_xstring TYPE XSTRING. DATA l_filename TYPE STRING. DATA l_length TYPE I. DATA lt_x255 TYPE TABLE OF x255. l_filename = i_filename. CALL METHOD cl_gui_frontend_services=>gui_upload EXPORTING filename = l_filename filetype = 'BIN' IMPORTING filelength = l_length CHANGING data_tab = lt_x255 EXCEPTIONS OTHERS = 1. IF sy-subrc = 0. CALL METHOD cl_swf_utl_convert_xstring=>table_to_xstring EXPORTING i_table = lt_x255 i_size = l_length RECEIVING r_stream = e_file_xstring EXCEPTIONS OTHERS = 3. ENDIF. ENDFORM. "read_bin_file |