2011年6月14日 星期二

[Code] Lock Mechanism


Lock:
CALL FUNCTION 'ENQUEUE_E_TRDIR'
  EXPORTING
    name           = 'PROGRAM_RUNNING'
    _scope         = '1'
  EXCEPTIONS
    foreign_lock   = 1
    system_failure = 2
    OTHERS         = 3.
IF sy-subrc <> 0.
  CALL FUNCTION 'DEQUEUE_ALL'.
  MESSAGE e000(zsd01) WITH 'Err: Program running!'.
ENDIF.
Unlock:
CALL FUNCTION 'DEQUEUE_ALL'.

Reference Manual: