Skip to Content
author's profile photo Former Member
Former Member

How to run a job in 1 session only?

Hi,

although I searched the forum and found some proposals close to my issue, I would like to ask just in case to be sure I have correct answer:

[Q] I have a program (with attached transaction code) which usualy runs as a task in background job, but may be started in foreground also. What I need is to prevent possiblity to start it in two paralel sessions (as per server context, not per frontend).

Is it possible and what is the proper way to do that?

Many thanks in advance.

Regards,

Ivaylo Mutafchiev

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Feb 14, 2005 at 04:33 PM

    Yes, I believe that this is achieved by placing a lock on the program name during execution. Here is a sample.

    
    report zrich_0001 .
    
    call function 'ENQUEUE_E_TRDIR'
     exporting
    *   MODE_TRDIR           = 'X'
       name                 = sy-repid
    *   X_NAME               = ' '
    *   _SCOPE               = '2'
    *   _WAIT                = ' '
    *   _COLLECT             = ' '
    * 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.
    
    
    check sy-subrc = 0.
    
    

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 14, 2005 at 04:32 PM

    Hi Ivaylo Mutafchiev,

    I have a couple of questions in regards to your requirement.

    By "prevent possibility to start in two parallel sessions(as per server context, not per frontend)", do you mean

    that multiple users can run it, but no two users run it on the same server(in a multi-server environment)?

    or do you want to prevent from one user executing the program in the foreground at the same time when the program is running in the background?

    Please give some more details around your requirement.

    Thanks,

    Srinivas

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      I'm sorry I was misleading - wrote that in a hurry.

      Well, what I meant was:

      to prevent 2 users to run it on the same server. We have ordinary configuration with DEV, QAS & PS systems, and I would like to have only 1 instance (sesstion) of the program running per server at particular moment, no matter foreground or background.

      I believe Rich gave me the solution I was searching for - tested and implemented it already.

      Thanks again.

      Ivaylo

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.