× 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.



Personally, if for some reason it's important that only one job be able to run a given program at a time, I have THAT program do an ALCOBJ to the *PGM object.  (I.e. the program allocates itself.)  with *EXCL.  This way, two copies cannot run at the same time because of the ALCOBJ.

(To whomever commented that allocating the program object won't prevent someone from running that program -- you're right -- because you don't need to lock the program to run it. You'd have to get all callers to do an ALCOBJ on the program before calling it -- which is why I put the ALCOBJ in the program itself.)

As for the original topic -- checking to see if a job with that name is active is poor programming, and a kludge.  What you should be doing is checking for whatever RESOURCE the program needs exclusive use of...  otherwise you end up with something like (and even worse than) the awful old "IF ACTIVE" feature of OCL.

Do it properly... the reason you want only one copy to run is because there's something underneath that you don't want someone else to use.   So check for THAT rather than if the same program is running.

And no.. IBM absolutely should NOT add this ability to the OS.

On 5/15/2024 11:51 PM, Roger Harman wrote:
Vern,

Just to comment on your lock test noted below....
The intent is not to exclude someone from using the program. Just to use the lock on that particular program as an indicator that a job is using that program.

To the topic at hand...
Allocating the program object may or may not be a useful technique. If the program is ONLY used by that particular job, it works as the second invocation will fail on the attempt to ALCOBJ on the program. Obviously, that needs to be monitored for and handled appropriately. If the program is used by other jobs/job streams, this method is not appropriate.

My opinion is that checking for a particular job "name" is not precise enough and a particular "job stream" is better off using the semaphore technique.
There is nothing to stop the same "job" from being submitted under different names. Of course, being handled programmatically gives you some semblance of control - until something changes

As you're fond of saying... "Just my $0.02 worth".

FWIW... I haven't written production code in almost 2-1/2 years now.
Writing a little 10-line CL to confirm my recollection of the ALCOBJ technique is the most code I've done since retiring!


Roger Harman
COMMON Certified Application Developer - ILE RPG on IBM i on Power




-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of VERNON HAMBERG Owner via MIDRANGE-L
Sent: Wednesday, May 15, 2024 10:31 AM
To: midrange-l@xxxxxxxxxxxxxxxxxx
Cc: VERNON HAMBERG Owner <vhamberg@xxxxxxxxxxxxxxx>; midrange-l@xxxxxxxxxxxxxxxxxx
Subject: RE: CL command to check whether an active job of a given name exists?

Hi Roger


I like that idea - I haven't checked enough code here to know, but I think we depend on existence only.


Regards
Vern

On Wed, 15 May, 2024 at 9:57 AM, Roger Harman <roger.harman@xxxxxxxxxxx> wrote:

To: midrange systems technical discussion

When I did a semaphore data area, I'd always populate it with the current job info - name, #, user, and any other pertinent info - maybe some parm/key value if applicable.

Just in case I needed to troubleshoot some conflict.

Roger Harman
COMMON Certified Application Developer - ILE RPG on IBM i on Power



-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx<mailto:midrange-l-bounces@xxxxxxxxxxxxxxxxxx>> On Behalf Of VERNON HAMBERG Owner via MIDRANGE-L
Sent: Wednesday, May 15, 2024 7:32 AM
To: midrange-l@xxxxxxxxxxxxxxxxxx<mailto:midrange-l@xxxxxxxxxxxxxxxxxx>
Cc: VERNON HAMBERG Owner <vhamberg@xxxxxxxxxxxxxxx<mailto:vhamberg@xxxxxxxxxxxxxxx>>; midrange-l@xxxxxxxxxxxxxxxxxx<mailto:midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: CL command to check whether an active job of a given name exists?

Perzackly, Jim - that's why I suggested QUSLJOB with a specific job name in the parameter - have know James too long, right?

Putting an *EXCL on a *PGM was suggested - I've never seen that work - just tried it with a simple program that sent an *INQ message in it, then locked it and called it. While waiting for a reply, I went to another job under my name in the same system, called the program, and i got the same *INQ message.


So locking the program didn't stop me from using it in a different job - would it block a different user? I can't test that here at the moment.



We often lock something like a *DTAARA to act as that semaphore, sometimes *EXCL, sometimes *EXCLRD, it appears in a quick iSphere search.


Cheers
Vern


On Wed, 15 May, 2024 at 9:02 AM, Jim Oberholtzer <midrangel@xxxxxxxxxxxxxxxxx<mailto:midrangel@xxxxxxxxxxxxxxxxx>> wrote:


To: midrange systems technical discussion

All good stuff, however remember that James is sometimes running systems
that are not real current, so the SQL helpers that IBM has built may not be
available. Hence the semaphore.

--
Jim Oberholtzer
Chief Technical Architect
Agile Technology Architects


On Wed, May 15, 2024 at 8:51 AM Sean Courtney <scourtney@xxxxxxxxxxx<mailto:scourtney@xxxxxxxxxxx><mailto:scourtney@xxxxxxxxxxx<mailto:scourtney@xxxxxxxxxxx>>> wrote:

Hi,

You could also execute the following SQL within CL

SELECT count(*) into :jobcount
FROM TABLE(QSYS2.ACTIVE_JOB_INFO()) B
WHERE JOB_NAME like '%Jobname%'

If you get jobcount = 0 then you are good ..

Seán

-----Ursprüngliche Nachricht-----
Von: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx<mailto:midrange-l-bounces@xxxxxxxxxxxxxxxxxx><mailto:midrange-l-bounces@xxxxxxxxxxxxxxxxxx<mailto:midrange-l-bounces@xxxxxxxxxxxxxxxxxx>>> Im Auftrag von Dan
Bale
Gesendet: Wednesday, 15 May 2024 14:49
An: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx<mailto:midrange-l@xxxxxxxxxxxxxxxxxx><mailto:midrange-l@xxxxxxxxxxxxxxxxxx<mailto:midrange-l@xxxxxxxxxxxxxxxxxx>>>
Betreff: RE: CL command to check whether an active job of a given name
exists?

This won't work if the jobs that are no longer active still have spool
files.

- Dan Bale

-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx<mailto:midrange-l-bounces@xxxxxxxxxxxxxxxxxx><mailto:midrange-l-bounces@xxxxxxxxxxxxxxxxxx<mailto:midrange-l-bounces@xxxxxxxxxxxxxxxxxx>>> On Behalf Of Sean
Courtney
Sent: Wednesday, May 15, 2024 7:56 AM
To: 'Midrange Systems Technical Discussion' <midrange-l@xxxxxxxxxxxxxxxxxx<mailto:midrange-l@xxxxxxxxxxxxxxxxxx><mailto:midrange-l@xxxxxxxxxxxxxxxxxx<mailto:midrange-l@xxxxxxxxxxxxxxxxxx>>
Subject: AW: CL command to check whether an active job of a given name
exists?

Hi ,

I just do a WRKJOB jobname and then monmsg CPF1070

If the MONMSG catches CPF1070 (job not found) then I continue to submit the
new job...

Seán
*** CONFIDENTIALITY NOTICE: The information contained in this communication
may be confidential, and is intended only for the use of the recipients
named above. If the reader of this message is not the intended recipient,
you are hereby notified that any dissemination, distribution, or copying of
this communication, or any of its contents, is strictly prohibited. If you
have received this communication in error, please return it to the sender
immediately and delete the original message and any copy of it from your
computer system. If you have any questions concerning this message, please
contact the sender. ***
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L@xxxxxxxxxxxxxxxxxx><mailto:MIDRANGE-L@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L@xxxxxxxxxxxxxxxxxx>> To subscribe,
unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx><mailto:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx>>
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx><mailto:support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx>> for any subscription related
questions.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L@xxxxxxxxxxxxxxxxxx><mailto:MIDRANGE-L@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L@xxxxxxxxxxxxxxxxxx>>
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx><mailto:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx>>
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx><mailto:support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx>> for any subscription related
questions.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L@xxxxxxxxxxxxxxxxxx><mailto:MIDRANGE-L@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L@xxxxxxxxxxxxxxxxxx>>
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx><mailto:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx>>
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx><mailto:support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx>> for any subscription related questions.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L@xxxxxxxxxxxxxxxxxx>
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx>
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx> for any subscription related questions.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.