*&---------------------------------------------------------------------*
*& Report Z_BARRY_RUN_TIME_ANALYSIS *
*& *
*&---------------------------------------------------------------------*
*& 选择屏幕如何添加按钮、cl_gui_docking_container、cl_gui_textedit用法、 *
*& 动态生成和检查Report、获取程序运行时间 *
*&---------------------------------------------------------------------*
REPORT z_barry_run_time_analysis .
TABLES: sscrfields.
DATA: itab_code TYPE STANDARD TABLE OF char72.
DATA: v_line TYPE i.
DATA: s_message TYPE trmsg.
DATA: v_word TYPE char72.
DATA: v_report TYPE syrepid VALUE 'Z_TEST_REPORT_11'.
DATA: v_time1 TYPE i.
DATA: v_time2 TYPE i.
DATA: v_repid TYPE syrepid.
DATA: x_docking TYPE REF TO cl_gui_docking_container,
x_editor TYPE REF TO cl_gui_textedit.
PARAMETERS:p_report(72) DEFAULT 'REPORT z_test_report_11.'.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(60) v_text.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(80) v_text1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN FUNCTION KEY 1.
INITIALIZATION.
v_repid = sy-repid.
v_text = 'Report Z_TEST_REPORT_11 will be generated'.
v_text1 = 'This is a small utility program to get the run time for the given code.'.
sscrfields-functxt_01 = 'Check syntax'.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-name = 'REPORT'.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
IF x_docking IS INITIAL .
CREATE OBJECT x_docking
EXPORTING
repid = v_repid
dynnr = sy-dynnr
side = cl_gui_docking_container=>dock_at_bottom
extension = '235'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
ENDIF .
IF x_editor IS INITIAL.
CREATE OBJECT x_editor
EXPORTING
parent = x_docking
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = 72
max_number_chars = 100000.
ENDIF .
AT SELECTION-SCREEN.
CHECK sy-ucomm = 'FC01'.
PERFORM code_and_syntax_check.
START-OF-SELECTION.
PERFORM code_and_syntax_check.
INSERT REPORT 'Z_TEST_REPORT_11' FROM itab_code.
IF sy-subrc <> 0.
MESSAGE i398(00) WITH 'Errors in generating'.
LEAVE LIST-PROCESSING.
ENDIF.
GENERATE REPORT 'Z_TEST_REPORT_11'.
IF sy-subrc <> 0.
MESSAGE i398(00) WITH 'Errors in generating'.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE s398(00) WITH 'Code generated successfully'.
ENDIF.
GET RUN TIME FIELD v_time1.
SUBMIT (v_report) AND RETURN.
GET RUN TIME FIELD v_time2.
v_time2 = v_time2 - v_time1.
WRITE: / 'Run time in micro seconds = ', v_time2.
*&---------------------------------------------------------------------*
*& Form code_and_syntax_check
*&---------------------------------------------------------------------*
FORM code_and_syntax_check.
REFRESH: itab_code.
CALL METHOD x_editor->get_text_as_r3table
IMPORTING
table = itab_code
EXCEPTIONS
error_dp = 1
error_cntl_call_method = 2
error_dp_create = 3
potential_data_loss = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE i398(00) WITH 'Error in getting the code'.
LEAVE PROGRAM.
ENDIF.
INSERT p_report INTO itab_code INDEX 1.
SYNTAX-CHECK FOR itab_code MESSAGE s_message LINE v_line WORD v_word.
IF sy-subrc <> 0.
MESSAGE i398(00) WITH s_message-msgtext 'Line' v_line.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE s398(00) WITH 'No syntax errors'.
ENDIF.
ENDFORM. " code_and_syntax_check
阅读(4591) | 评论(2) | 转发(0) |