1.界面
2.代码
*&---------------------------------------------------------------------*
*& Report ZRICO_TEST21
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report zrico_test21.
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 sy-repid.
data: x_docking type ref to cl_gui_docking_container,
x_editor type ref to cl_gui_textedit.
parameters:p_report() default 'REPORT zrico_test23.'.
selection-screen skip .
selection-screen begin of line.
selection-screen comment () v_text.
selection-screen end of line.
selection-screen begin of line.
selection-screen comment () v_text1.
selection-screen end of line.
selection-screen function key . 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 = .
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 = ''
exceptions
cntl_error =
cntl_system_error =
create_error =
lifetime_error =
lifetime_dynpro_dynpro_link = .
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 =
max_number_chars = .
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 <> .
message i398() with 'Errors in generating'.
leave list-processing.
endif.
generate report 'Z_TEST_REPORT_11'.
if sy-subrc <> .
message i398() with 'Errors in generating'.
leave list-processing.
else.
message s398() 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 =
error_cntl_call_method =
error_dp_create =
potential_data_loss =
others = .
if sy-subrc <> .
message i398() with 'Error in getting the code'.
leave program.
endif.
insert p_report into itab_code index .
syntax-check for itab_code message s_message line v_line word v_word.
if sy-subrc <> .
message i398() with s_message-msgtext 'Line' v_line.
leave list-processing.
else.
message s398() with 'No syntax errors'.
endif.
endform. " code_and_syntax_check