실무에 적용된 소스이며, 재밌는 예제인것같습니다.
( 자재 실사처리시 MARD테이블 Lock처리해서 이중실사처리하지 못하도록 할경우 사용)
===================================================================
MARD 테이블 Lock
===================================================================
FUNCTION ENQUEUE_EZ_MARD.
DATA: __seqta_tab TYPE SEQTA OCCURS 01 WITH HEADER LINE,
__scope TYPE DDENQSCOPE,
__wait TYPE DDENQWAIT.
__wait = _wait.
__scope = _scope.
DATA: BEGIN OF %a_MARD,
* 테이블 MARD 에 대한 잠금인수
MANDT TYPE MARD-MANDT,
MATNR TYPE MARD-MATNR,
WERKS TYPE MARD-WERKS,
LGORT TYPE MARD-LGORT,
END OF %a_MARD.
* 잠금인수 초기화:
CALL 'C_ENQ_WILDCARD' ID 'HEX0' FIELD %a_MARD.
* 잠금필드에 잠금매개변수 지정:
IF NOT MANDT IS INITIAL.
MOVE MANDT TO:
%a_MARD-MANDT.
ENDIF.
IF NOT MATNR IS INITIAL OR
NOT x_MATNR IS INITIAL.
MOVE MATNR TO:
%a_MARD-MATNR.
ENDIF.
IF NOT WERKS IS INITIAL OR
NOT x_WERKS IS INITIAL.
MOVE WERKS TO:
%a_MARD-WERKS.
ENDIF.
IF NOT LGORT IS INITIAL OR
NOT x_LGORT IS INITIAL.
MOVE LGORT TO:
%a_MARD-LGORT.
ENDIF.
* 잠금테이블채우기:
__seqta_tab-gname = 'MARD'.
__seqta_tab-gmode = MODE_MARD.
__seqta_tab-garg = %a_MARD.
APPEND __seqta_tab.
* 잠금 지정:
PERFORM send_enqueue(saplsena)
TABLES __seqta_tab
USING '1' __scope __wait ' ' 'EZ_MARD' _collect.
ENDFUNCTION.
===================================================================
MARD 테이블 UnLock
===================================================================
FUNCTION DEQUEUE_EZ_MARD.
DATA: __seqta_tab TYPE SEQTA OCCURS 01 WITH HEADER LINE,
__scope TYPE DDENQSCOPE,
__synchron TYPE DDENQSYNC.
__synchron = _synchron.
__scope = _scope.
DATA: BEGIN OF %a_MARD,
* 테이블 MARD 에 대한 잠금인수
MANDT TYPE MARD-MANDT,
MATNR TYPE MARD-MATNR,
WERKS TYPE MARD-WERKS,
LGORT TYPE MARD-LGORT,
END OF %a_MARD.
* 잠금인수 초기화:
CALL 'C_ENQ_WILDCARD' ID 'HEX0' FIELD %a_MARD.
* 잠금필드에 잠금매개변수 지정:
IF NOT MANDT IS INITIAL.
MOVE MANDT TO:
%a_MARD-MANDT.
ENDIF.
IF NOT MATNR IS INITIAL OR
NOT x_MATNR IS INITIAL.
MOVE MATNR TO:
%a_MARD-MATNR.
ENDIF.
IF NOT WERKS IS INITIAL OR
NOT x_WERKS IS INITIAL.
MOVE WERKS TO:
%a_MARD-WERKS.
ENDIF.
IF NOT LGORT IS INITIAL OR
NOT x_LGORT IS INITIAL.
MOVE LGORT TO:
%a_MARD-LGORT.
ENDIF.
* 잠금테이블채우기:
__seqta_tab-gname = 'MARD'.
__seqta_tab-gmode = MODE_MARD.
__seqta_tab-garg = %a_MARD.
APPEND __seqta_tab.
* 잠금 지정:
PERFORM send_enqueue(saplsena)
TABLES __seqta_tab
USING '2' __scope ' ' __synchron 'EZ_MARD' _collect.
ENDFUNCTION.
감사합니다.