SAP ABAP plus lock and unlock

Source: Internet
Author: User
Tags table name

Specific procedures:

1. Using TCODE:SE11, select the last item [lock Object], enter the object name (note that it must start with the letter ' E ', which is defined internally by SAP, such as EZ_FI_CSTM_001)

2. After entering the name, press Add, enter the interface after entering the table name to be locked, and the lock type (E: dedicated, Cumulative; S: Shared; X: private, not cumulative).

Once saved, the system automatically generates two functions: enqueue_ez_fi_cstm_001 (Locking) and dequeue_ez_fi_cstm_001 (unlocked).

3. Then call the lock function to lock the record before changing the record, and make sure to unlock the record after the modification is complete or when you exit the modification.



Enter the lock table:



Enter the fields for the locked table:




Then call it in the program:

PERFORM frm_unlock_0100 USING p_inv p_cntr p_doc_ty.


*&---------------------------------------------------------------------*
*& Form frm_unlock_0100
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
*-->P_P_INV Text
*-->P_P_CNTR Text
*-->p_p_doc_ty Text
*----------------------------------------------------------------------*
FORM frm_unlock_0100 USING P_INV
P_cntr
P_doc_ty.
Call FUNCTION ' dequeue_ez_fi_cstm_001 '
Exporting
* mode_ztbl_fi_cstm_001 = ' E '
* Mandt = Sy-mandt
Invoice = P_INV
Contract = P_cntr
Doc_type = P_doc_ty
* X_invoice = "
* X_contract = "
* X_doc_type = "
* _scope = ' 3 '
* _synchron = "
* _collect = "
.
EndForm. "Frm_unlock_0100




Refer to automatically generated functions:


FUNCTION dequeue_ez_fi_cstm_001.
*"--------------------------------------------------------------------
* "*" Local Interface:
* "Importing
* "VALUE (mode_ztbl_fi_cstm_001) TYPE enqmode DEFAULT ' E '
* "VALUE (Mandt) TYPE Ztbl_fi_cstm_001-mandt DEFAULT Sy-mandt
* "VALUE (INVOICE) TYPE Ztbl_fi_cstm_001-invoice OPTIONAL
* "VALUE (contract) TYPE Ztbl_fi_cstm_001-contract OPTIONAL
* "VALUE (doc_type) TYPE Ztbl_fi_cstm_001-doc_type OPTIONAL
* "VALUE" (x_invoice) DEFAULT SPACE
* "VALUE" (x_contract) DEFAULT SPACE
* "VALUE" (x_doc_type) DEFAULT SPACE
* "VALUE (_scope) DEFAULT ' 3 '
* "VALUE" (_synchron) DEFAULT SPACE
* "VALUE (_collect) TYPE ddenqcoll DEFAULT"
*"--------------------------------------------------------------------
* Generate function Module for locking object ez_fi_cstm_001
* Please do not modify or copy the function module
* See the ABAP Help for SAP lock-in content
* For keyword "ENQUEUE"


DATA: __seqta_tab TYPE seqta occurs and HEADER line,
__scope TYPE Ddenqscope,
__synchron TYPE Ddenqsync.
__synchron = _synchron.
__scope = _scope.


Data:begin of%a_ztbl_fi_cstm_001,
* Function to lock table ztbl_fi_cstm_001
Mandt TYPE Ztbl_fi_cstm_001-mandt,
INVOICE TYPE Ztbl_fi_cstm_001-invoice,
Contract TYPE Ztbl_fi_cstm_001-contract,
Doc_type TYPE Ztbl_fi_cstm_001-doc_type,
END of%a_ztbl_fi_cstm_001.
* Lock function initialization:
Call ' C_enq_wildcard ' ID ' HEX0 ' FIELD%a_ztbl_fi_cstm_001.


* Lock the assignment of the field lock parameter:

IF not Mandt is INITIAL.
MOVE Mandt to:
%a_ztbl_fi_cstm_001-mandt.
ENDIF.

IF not INVOICE is INITIAL OR
Not X_invoice is INITIAL.
MOVE INVOICE to:
%a_ztbl_fi_cstm_001-invoice.
ENDIF.

IF not contract is INITIAL OR
Not X_contract is INITIAL.
MOVE contract to:
%a_ztbl_fi_cstm_001-contract.
ENDIF.

IF not Doc_type is INITIAL OR
Not X_doc_type is INITIAL.
MOVE Doc_type to:
%a_ztbl_fi_cstm_001-doc_type.
ENDIF.


* Fill in the Lock table:

__seqta_tab-gname = ' ztbl_fi_cstm_001 '.
__seqta_tab-gmode = mode_ztbl_fi_cstm_001.
__seqta_tab-garg =%a_ztbl_fi_cstm_001.
APPEND __seqta_tab.


* The specified Lock:
PERFORM Send_enqueue (Saplsena)
TABLES __seqta_tab
USING ' 2 ' __scope ' __synchron ' ez_fi_cstm_001 ' _collect.

Endfunction.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.