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: 

how to restrict the no of times same running?

Former Member
0 Kudos

Hi Experts,

I have submitted the job as same program in the background.

but it is creating lot of spool requests....

how to restrict it..

if any example it will be more helpful.

Thanks in Advance,

venkat

3 REPLIES 3

Former Member
0 Kudos

Set a flag in the end of the program . and check it before executing the same thing. If it is set, exit

0 Kudos

Hi Rajiv,

Thanks for your reply,

but i want to execute my program in the background.

so i used SUBMIT stmt to schedule background by calling job_open, job_close.

between job_open and job_close i submited the program with job name and job count.

when i open the sm37..there it is showing lot of spool requests..

what is the problem i couldn't understand..can anybody tell me.

Thanks in Advance,

venkat

0 Kudos

Hi Venkat,

try to look at this solution:


*Prevent the program from having more   
*the one instance running the same time.
*Create this macro in TRMAC using SM31  
*Insert the following single line in the
*program right after the REPORT state-  
*ment:   

ZCHK_MYSELF_RUNNING SY-REPID.  

DATA: PRG LIKE INDX-SRTFD. 
PRG = &1  .   
CALL FUNCTION 'ENQUEUE_ESINDX'         *
     EXPORTING RELID = 'ZZ'            *
          SRTFD = PRG                  *
          SRTF2 = 0                    *
     EXCEPTIONS FOREIGN_LOCK = 1       *
           SYSTEM_FAILURE = 2          .   

IF SY-SUBRC NE 0.     
  WRITE: 'ERROR:',PRG,'is already running'.
  EXIT. 
ENDIF.    

I once found it on the web but I didn't test it yet.

Regards,

Karol