Skip to Content
0
Former Member
Dec 11, 2006 at 03:01 PM

Issue with Program lock

77 Views

I have a requirement to lock the Program if it is already running with the same variant. My program is scheduled to run every 5 minutes for each variant. So if the program finds the Previous Job still under execution then it should throw an error saying 'The program is still Running with the same Variant xxxx".

I am using the Lock Object 'ESVARIANT' to the lock the Program using the same

variant.

CALL FUNCTION 'ENQUEUE_ESVARIANT'

EXPORTING

MODE_VARI = C_E "E

MANDT = SY-MANDT

RELID = C_RELID "VA

REPORT = SY-CPROG

VARIANT = SY-SLSET

EXCEPTIONS

FOREIGN_LOCK = 1

SYSTEM_FAILURE = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

This lock object works fine most of the times but for some reason it fails sometimes, i.e It does not get locked even if it finds a Job executing with the same variant?. It is not reliable using this Lock object 'ESVARIANT'.

Can any of you suggest me any other solution for this? .

Any solutions is appreciated and rewarded.

Thanks

Sekhar

Message was edited by:

Nagasekhar Reddy.K

Message was edited by:

Nagasekhar Reddy.K