ABAP-语法检查

1.界面

2.代码

  1 *&---------------------------------------------------------------------*
  2 *& Report  ZRICO_TEST21
  3 *&
  4 *&---------------------------------------------------------------------*
  5 *&
  6 *&
  7 *&---------------------------------------------------------------------*
  8 report zrico_test21.
  9 tables: sscrfields.
 10 data: itab_code    type standard table of char72.
 11 data: v_line    type i.
 12 data: s_message type trmsg.
 13 data: v_word    type char72.
 14 data: v_report type syrepid value 'Z_TEST_REPORT_11'.
 15 data: v_time1   type i.
 16 data: v_time2   type i.
 17 data: v_repid   type sy-repid.
 18 data: x_docking type ref to cl_gui_docking_container,
 19       x_editor  type ref to cl_gui_textedit.
 20 parameters:p_report(72) default 'REPORT zrico_test23.'.
 21 selection-screen skip 1.
 22 selection-screen begin of line.
 23 selection-screen comment 1(60) v_text.
 24 selection-screen end of line.
 25 selection-screen begin of line.
 26 selection-screen comment 1(80) v_text1.
 27 selection-screen end of line.
 28 selection-screen function key 1.
 29 
 30 initialization.
 31   v_repid = sy-repid.
 32   v_text = 'Report Z_TEST_REPORT_11 will be generated'.
 33   v_text1 = 'This is a small utility program to get the run time for the given code.'.
 34   sscrfields-functxt_01 = 'Check syntax'.
 35 
 36 at selection-screen output.
 37   loop at screen.
 38     if screen-name = 'REPORT'.
 39       screen-input = 0.
 40       modify screen.
 41     endif.
 42   endloop.
 43   if x_docking is initial .
 44     create object x_docking
 45       exporting
 46         repid                       = v_repid
 47         dynnr                       = sy-dynnr
 48         side                        = cl_gui_docking_container=>dock_at_bottom
 49         extension                   = '235'
 50       exceptions
 51         cntl_error                  = 1
 52         cntl_system_error           = 2
 53         create_error                = 3
 54         lifetime_error              = 4
 55         lifetime_dynpro_dynpro_link = 5.
 56   endif .
 57   if x_editor is initial.
 58     create object x_editor
 59       exporting
 60         parent            = x_docking
 61         wordwrap_mode     = cl_gui_textedit=>wordwrap_at_fixed_position
 62         wordwrap_position = 72
 63         max_number_chars  = 100000.
 64   endif .
 65 
 66 at selection-screen.
 67   check sy-ucomm = 'FC01'.
 68   perform code_and_syntax_check.
 69 
 70 start-of-selection.
 71   perform code_and_syntax_check.
 72   insert report 'Z_TEST_REPORT_11' from itab_code.
 73   if sy-subrc <> 0.
 74     message i398(00) with 'Errors in generating'.
 75     leave list-processing.
 76   endif.
 77   generate report 'Z_TEST_REPORT_11'.
 78   if sy-subrc <> 0.
 79     message i398(00) with 'Errors in generating'.
 80     leave list-processing.
 81   else.
 82     message s398(00) with 'Code generated successfully'.
 83   endif.
 84   get run time field v_time1.
 85   submit (v_report) and return.
 86   get run time field v_time2.
 87   v_time2 = v_time2 - v_time1.
 88   write: / 'Run time in micro seconds = ', v_time2.
 89 *&---------------------------------------------------------------------*
 90 *&      Form code_and_syntax_check
 91 *&---------------------------------------------------------------------*
 92 form code_and_syntax_check.
 93   refresh: itab_code.
 94   call method x_editor->get_text_as_r3table
 95     importing
 96       table                  = itab_code
 97     exceptions
 98       error_dp               = 1
 99       error_cntl_call_method = 2
100       error_dp_create        = 3
101       potential_data_loss    = 4
102       others                 = 5.
103   if sy-subrc <> 0.
104     message i398(00) with 'Error in getting the code'.
105     leave program.
106   endif.
107   insert p_report into itab_code index 1.
108   syntax-check for itab_code message s_message line v_line word v_word.
109   if sy-subrc <> 0.
110     message i398(00) with s_message-msgtext 'Line' v_line.
111     leave list-processing.
112   else.
113     message s398(00) with 'No syntax errors'.
114   endif.
115 endform.                    " code_and_syntax_check
View Code

猜你喜欢

转载自www.cnblogs.com/ricoo/p/10184255.html