Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problems with ENQUEUE_E_TABLE/DEQUEUE_E_TABLE

Former Member
0 Likes
3,058

Hi all,

i use the above FMs in this case.

REPORT ZGRO_TEST1 MESSAGE-ID ZZ.

*

PARAMETERS: P_LOCK RADIOBUTTON GROUP PRI1 DEFAULT 'X',

P_UNLOCK RADIOBUTTON GROUP PRI1.

*

DATA: TABLE LIKE RSTABLE-TABNAME VALUE 'MSEG'.

START-OF-SELECTION.

*

CASE P_LOCK.

*

WHEN 'X'.

CALL FUNCTION 'ENQUEUE_E_TABLE'

EXPORTING

TABNAME = TABLE

EXCEPTIONS

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

OTHERS = 3.

*

IF SY-SUBRC <> 0.

WRITE: / 'P_LOCK', SY-SUBRC.

EXIT.

ENDIF.

*

WHEN OTHERS.

*

CALL FUNCTION 'DEQUEUE_E_TABLE'

EXPORTING

TABNAME = TABLE

EXCEPTIONS

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

OTHERS = 3.

*

IF SY-SUBRC <> 0.

WRITE: / 'P_UNLOCK', SY-SUBRC.

EXIT.

ENDIF.

*

ENDCASE.

*

END-OF-SELECTION.

When i run with P_LOCK = 'X' and look in SM12 nothing is locked.

What mistake is in my report?

Regards, Dieter

7 REPLIES 7
Read only

Former Member
0 Likes
1,885

Hello Dieter,

The problem is that SAP will automatically release all the locks if the program/transaction has terminated sucessfully. So by the time you look in transaction SM12, ZGRO_TEST1 has ended and the locks are released.

Regards,

Manoj

Read only

0 Likes
1,885

Hi Manoj,

thanks for your answer.

Do you see another possibility to lock/unlock a table

after the report ends?

Regards, Dieter

Read only

0 Likes
1,885

Hello Dieter,

I didnt understand your question.

Manoj

Read only

0 Likes
1,885

Hi Manoj,

what i want is this.

We have our Inventory. I don't whant to lock Tcodes via SM01.

I will lock MKPF and MSEG for about 12 hours.

Therefor i tried it via a report.

Your answer show to me, that this isn't possible.

Therefore i look for another possibility to lock MKPF/MSEG.

Regards, Dieter

Read only

0 Likes
1,885

Hello Dieter,

Your tables (In this case MKPF/MSEG) can be locked only for the duration of your program. If your program is running for 12 hours (say a monthly report or so), then you can lock your tables at the beginning of your program and they will remain locked till the program ends. But once the program ends the locks will be released and the tables will be accessible to other programs/users. If you want to lock your tables even after the program ends, then you have to lock the transaction with SM01.

Regards,

Manoj

Read only

Former Member
0 Likes
1,885

As soon as program execution is finished all locks will be realeased..

You debug the program and check in sm12 simultaneously , at one point of program table will be locked and it will be released as soon as program execution is finished..

Reward if usefull..

Let me know if you want more clarification..

Read only

Former Member
0 Likes
1,885

Hi

i executed ur program and checked the entries in sm12.

there exists an entry in sm12 for the program code in TRDIR table .

it shows an exclusive lock placed on the table which could be deleted as well

by checking the other radiobutton.

i suggest you to check the locked entry in TRDIR table , by entering your program name in the selection screen .

plz revert if the issue persists

Regards

Pankaj