× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Luis,

Here's some code I use to do exactly what you're trying to do. The trick
is that locking a program will not prevent another program from calling
it, what you need to do is have the program itself lock itself. In my
case the program name is RUNUPD.

/*CAN WE GET A LOCK ON OURSELVES -- IF SO WE'RE NOT RUNNING*/ 
             ALCOBJ     OBJ((RUNUPD *PGM *EXCL)) WAIT(1)      
             MONMSG CPF1002 EXEC(DO)                          
                RCVMSG RMV(*YES)                              
                RETURN                                        
             ENDDO                                            
                                                              
/*BACK OFF LOCK TO A MORE "FRIENDLY" STATUS                   
             ALCOBJ     OBJ((RUNUPD *PGM *SHRRD)) WAIT(1)     
             DLCOBJ     OBJ((RUNUPD *PGM *EXCL))              


The backoff lock is used so that nightly backups won't have a problem.
They couldn't backup through an EXCL, but they can backup through a
SHRRD. However, if a job has a SHRRD then the initial ALCOBJ w/EXCL will
fail. 

The nice thing about the lock over a data area is that it's
self-resetting. If the job dies the lock is gone -- no need to reset the
data area. Of course if you _want_ to make sure that the job completed
successfully then the data area is a better idea.

-Walden                                                              

 


------------
Walden H Leverich III
Tech Software
(516) 627-3800 x11
WaldenL@xxxxxxxxxxxxxxx
http://www.TechSoftInc.com

Quiquid latine dictum sit altum viditur.
(Whatever is said in Latin seems profound.)


-----Original Message-----
From: midrange-l-bounces+waldenl=techsoftinc.com@xxxxxxxxxxxx
[mailto:midrange-l-bounces+waldenl=techsoftinc.com@xxxxxxxxxxxx] On
Behalf Of Luis Rodriguez
Sent: Wednesday, October 26, 2005 11:14 AM
To: Midrange
Subject: Re: Allocating a *PGM object

Jeff,

Thanks for your message. As per the manual (Infamous Center...):

..."When ALCOBJ is executed to get an EXCL lock on a program (*PGM),
only the program object description is locked. The program code is not
locked exclusively. Therefore, the program may still be run by another
user. Changes are not allowed for the program object description while
the actual program can still be used."

I have received (off-site) the idea of creating a *DTAARA in the process
that I'm trying to protect and trying to lock it. That should work (I
hope :-) )

Thanks again for your help,

Luis Rodriguez

> ------------------------------
> 
> message: 6
> date: Wed, 26 Oct 2005 06:21:37 -0700 (PDT)
> from: Jeff Young <cooljeff913@xxxxxxxxx>
> subject: Re: Allocating a *PGM object
> 
> You can use the ALCOBJ command in the CL that runs the pgm.
> In the pgm that wants to test if Pgm A is running, use the ALCOBJ
> command.  If Pgm A is running and allocated to CL Pgm A, the ALCOBJ
will
> fail.
> You can monitor for the failure and take appropiate action.
> 
> 
> Luis Rodriguez <luisrodriguez@xxxxxxxxxxx> wrote:
> Hi all,
> 
> Does anybody know how to check if a program is being used for another
> job? I had thought of using ALCOBJ, but it only protects the program
of
> being deleted.
> 
> Thanks for your help,
> 
> Luis Rodriguez
----------------
  Luis Rodriguez


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.