当然可以用程序锁来实现了,系统标准的有一些,可以从SE11查一下.
REPORT ZTEST.
START-OF-SELECTION.
PERFORM CHECK.
*&--------------------------------------------------------------------*
*& Form check
*&--------------------------------------------------------------------*
FORM CHECK.
DATA:L_NAME TYPE INDX-SRTFD.
MOVE SY-REPID TO L_NAME.
CALL FUNCTION 'ENQUEUE_ESINDX'
EXPORTING
* MODE_INDX = 'E'
* MANDT = SY-MANDT
* RELID =
SRTFD = L_NAME
SRTF2 = 0
* X_RELID = ' '
* X_SRTFD = ' '
* X_SRTF2 = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3 .
IF SY-SUBRC <> 0.
WRITE: / 'Program is already running!'.
ENDIF.
ENDFORM.
另外一种方法:
首先,获得系统当前所有登陆的用户,用TH_USER_LIST
然后,获得每个用户的会话,用TH_LONG_USR_INFO
如果发现当前有人用事务代码,则不运行事务,并且给个提示.
阅读(893) | 评论(0) | 转发(0) |