Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7133941
  • 博文数量: 655
  • 博客积分: 10264
  • 博客等级: 上将
  • 技术积分: 8278
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-04 17:47
个人简介

ABAP顾问

文章分类

全部博文(655)

文章存档

2017年(2)

2014年(8)

2013年(3)

2012年(2)

2011年(18)

2010年(102)

2009年(137)

2008年(274)

2007年(134)

分类:

2007-06-24 14:24:19

*&---------------------------------------------------------------------*
*& 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
阅读(4541) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

qdbarry2011-10-08 23:04:32

zhj198906122011-10-06 16:27:11

老白,我把你上面代码里面的Z_TEST_REPORT_11改成我自己的程序名,结果程序清空了 , 你赔。