‎2006 Dec 11 3:01 PM
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
‎2006 Dec 12 9:51 AM
Use FM TH_WPINFO.
It will returns the work-processes of the application server, distinguished by Program name, user, etc...
Loop at the returning table searching for your program, and if found do whatever you need in the code.
Hope this helps,
Roby.
‎2006 Dec 11 6:18 PM
I'm wondering if you shouldn't be passing variables instead of system fields here. At least the sy-cprog may be a problem.
data: v_cprog type sy-cprog,
v_slset type sy-slset.
v_cprog = sy-cprog.
v_slset = sy-slset.
CALL FUNCTION 'ENQUEUE_ESVARIANT'
EXPORTING
MODE_VARI = C_E "E
MANDT = SY-MANDT
RELID = C_RELID "VA
REPORT = v_CPROG
VARIANT = v_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.Regards,
Rich Heilman
‎2006 Dec 11 10:45 PM
Hi,
I would suggest the following as an alternate
1) to look for the tables TBTCO and TBTCP which holds all job names and it's status.
2) Or there are lot of function modules to check the status of the batch job, refer the function group BDL3 (sample: BDL_CHECK_FOR_RUNNING_BATCHJOB).
Hope, it helps.
Thanks
Viswa
(Assign points if helpful)
‎2006 Dec 11 11:28 PM
In addition, check this function module also BP_JOB_SELECT_SM37C.
Thanks
Viswa
‎2006 Dec 12 9:51 AM
Use FM TH_WPINFO.
It will returns the work-processes of the application server, distinguished by Program name, user, etc...
Loop at the returning table searching for your program, and if found do whatever you need in the code.
Hope this helps,
Roby.