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

Locking Program

Former Member
0 Likes
648

Hi All,

I have program called ZLOADFILE and it runs in background. my requirement is when i schedule the program ZLOADFILE in background ,i have to check if this program is already been running in background by any user , if it is already running then my job should be cancelled.

Please help me know if there is any functionality.

Thanks in Advance,

Neha

3 REPLIES 3
Read only

Former Member
0 Likes
607

Hi.

I think, you can create some table and define lock object for it with write mode.

In program you should place code of locking that table.

After attempt of setting lock, check FOREIGN_LOCK exception of

corresponding function module.

If exception is raised, this means that one program already works.

Read only

former_member209217
Active Contributor
0 Likes
607

Hi Neha,

Create a lock entry while running the program so that other users may not be able to run ur program.

Try to create one lock object and using the generated function module which sounds like enqueue_*****

lock the program from being executed by another user while running.

To chk whether ur lock is successful or not goto tcode sm12 and chk the entries.if its successful u will find an entry with program name.

regards,

Lakshman.

Read only

Former Member
0 Likes
607

Use the Following FM to check wether the program is locked or not.


  CALL FUNCTION 'ENQUEUE_READ'
    EXPORTING
      gclient               = ' '
      gname                 = 'TRDIR'
      garg                  = lw_uname
      guname                = ' '
    TABLES
      enq                   = lt_locked
    EXCEPTIONS
      communication_failure = 1
      system_failure        = 2
      OTHERS                = 3.

  IF sy-subrc = 0.

Regards,

Gurpreet