Application Development 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: 

Locking a Report

Former Member
0 Kudos

hey can any one tell me how can i lock the Z Report, means i have mad report on MSEG and MKPF table, i want that if one user is processing that report at the same time other user shud not be able to process the same report, i hope i have cleared my query.

abhishek

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate

Here some code that works for me.



* Make sure that no one else is running this program
* This is the locking mechanism for this program.
  PROGRAM = SY-REPID.
  CALL FUNCTION 'ENQUEUE_ESINDX'
       EXPORTING
            SRTFD          = PROGRAM_NAME
            SRTF2          = 0
            _WAIT          = 2
       EXCEPTIONS
            FOREIGN_LOCK   = 1
            SYSTEM_FAILURE = 2.
  IF SY-SUBRC <> 0.
* Give message that someone is running the program
  ENDIF.

Regards,

Rich Heilman

9 REPLIES 9

RichHeilman
Developer Advocate
Developer Advocate

Here some code that works for me.



* Make sure that no one else is running this program
* This is the locking mechanism for this program.
  PROGRAM = SY-REPID.
  CALL FUNCTION 'ENQUEUE_ESINDX'
       EXPORTING
            SRTFD          = PROGRAM_NAME
            SRTF2          = 0
            _WAIT          = 2
       EXCEPTIONS
            FOREIGN_LOCK   = 1
            SYSTEM_FAILURE = 2.
  IF SY-SUBRC <> 0.
* Give message that someone is running the program
  ENDIF.

Regards,

Rich Heilman

0 Kudos

thanx rich

regards

abhishek suppal

0 Kudos

dear rich

this function i working fine where name of programe is less than 22 chars but gives dump when it crosses 22 chars.

abhishek

0 Kudos

Hi abhishek,

import-parameter SRTFD of fm is defined

as INDX-SRTFD (= char 22)

i don't know if it's useful to copy and modify fm (?)

can't you rename your program ?

regards Andreas

0 Kudos

ya i can do that renaming programe name but i have to again assign to the same t-code renaming the programe option is there but can't we do it for more than 22 chars.

abhishek

0 Kudos

Hi

Don't copy the function module! It's a generated lock object one.

The technique being used here is to re-use a lock object that relates to a generic system table.

As SAP locking is logical, not physical, it doesn't really matter that a generic system table is used here,

as there is very low likelihood of people conflicting with the lock argument.

However, the INDX table has only a 22 character key.

Why don't you create your own 'Z' lock object. Do a where-used list on view TRDIR for other

lock objects using it. Use one of them as a template.

It'll take you 15 minutes and you'll learn all about locking.

Then just call your new generated lock function module as above.

Cheers

Dom

Reference:

http://help.sap.com/saphelp_nw04/helpdata/en/a2/3547360f2ea61fe10000009b38f839/frameset.htm

FredericGirod
Active Contributor
0 Kudos

Hi,

Just use the standard Lock object : http://help.sap.com/saphelp_nw04/helpdata/en/cf/21eea5446011d189700000e8322d00/frameset.htm

(see also The SAP Lock Concept (BC-CST-EQ) )

Regards

Frédéric

0 Kudos

Hello Judith,

Please do spend some time reading and understanding the question. Editor Lock has got a different functionality. It allows only the creator of the program to modify it. Which is certainly not what is being asked.

And further it is not a good idea to mainuplate the TADIR/TRDIR and other such tables directly.

Once again, I must tell you to make sure that your response is relevant. Irrelevant and misleading answers may be subject to censoring. And I don't generally want to do that.

Regards,

Anand Mandalika.