1. 程式人生 > >ABAP 如何暫停其他程序的處理 加速當前程式的處理速度

ABAP 如何暫停其他程序的處理 加速當前程式的處理速度

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow

也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!

               

REPORT ZHGUPALL NO STANDARD PAGE HEADING.
************************************************************************
* This is a test program to measure - how much faster a program can
* process it's job if all the other workprocesses are halted.
* The program identifies the dialog and batch workprocesses that are
* running other abaps and sends them a UNIX 24 (halt) signal.
* When it has finished the job, it releases the other workprocesses
* by sending them a signal 26. This method can be hazardous too.
* One such situation can be a deadlock, when the program requires a
* resource, that is locked by an abap that has been paused.
************************************************************************
PARAMETERS: SELFISH.
TABLES: TRDIR.
DATA: T1 TYPE I,
      T2 TYPE I,
      STRING(20) VALUE 'load',
      LOCK(30) VALUE 'kill -24',
      ULOCK(30) VALUE 'kill -26',
      OPCODE TYPE X VALUE 2.
DATA: BEGIN OF LIST OCCURS 10.
        INCLUDE STRUCTURE MSXXLIST.
DATA: END OF LIST.
DATA: BEGIN OF WPLIST OCCURS 10.
        INCLUDE STRUCTURE WPINFO.
DATA: END OF WPLIST.
DATA: BEGIN OF TABL OCCURS 0,
      LINE(200),
END OF TABL.
DATA: BEGIN OF ITAB OCCURS 500,
      LINE(72),
END OF ITAB.
*
* Get the list of dialog workprocesses
CALL FUNCTION 'TH_SERVER_LIST'
     TABLES
          LIST = LIST.
READ TABLE LIST WITH KEY HOST = SY-HOST.
CALL FUNCTION 'TH_WPINFO'
     EXPORTING
          SRVNAME = LIST-NAME
     TABLES
          WPLIST  = WPLIST.
*
* Lock all the DIA and BTC but mine
IF SELFISH = 'Y'.
  LOOP AT WPLIST.
    IF WPLIST-WP_TYP = 'DIA' OR WPLIST-WP_TYP = 'BTC'.
      IF WPLIST-WP_BNAME <> SY-UNAME.
        LOCK+11(8) = WPLIST-WP_PID.
        WRITE: / LOCK.
        CALL 'SYSTEM' ID 'COMMAND' FIELD LOCK
        ID 'TAB'     FIELD TABL-*SYS*.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDIF.
SKIP.
*
* Measure runtime
GET RUN TIME FIELD T1.
*
* This is my processing section VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
SELECT * FROM TRDIR WHERE NAME LIKE 'I%'.
  READ REPORT TRDIR-NAME INTO ITAB.
  LOOP AT ITAB.
    IF ITAB-LINE CS STRING.
      WRITE: / TRDIR-NAME.
      EXIT.
    ENDIF.
  ENDLOOP.
ENDSELECT.
* End of processing ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
************************************************************************
*
* Measure runtime
GET RUN TIME FIELD T2.
T2 = T2 - T1.
SKIP.
WRITE: 'runtime:', T2.
SKIP.
*
* Unock the other guys
IF SELFISH = 'Y'.
  LOOP AT WPLIST.
    IF WPLIST-WP_TYP = 'DIA' OR WPLIST-WP_TYP = 'BTC'.
      IF WPLIST-WP_BNAME <> SY-UNAME.
        ULOCK+11(8) = WPLIST-WP_PID.
        WRITE: / ULOCK.
        CALL 'SYSTEM' ID 'COMMAND' FIELD ULOCK
        ID 'TAB'     FIELD TABL-*SYS*.
      ENDIF.
    ENDIF.
  ENDLOOP.
ENDIF.

 

Sourcelink: http://www.kabai.com/abaps/z101.htm

           

給我老師的人工智慧教程打call!http://blog.csdn.net/jiangjunshow

這裡寫圖片描述