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



"MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx> wrote on 09/27/2016
01:31:54 PM:
I need to be sure that a particular batch job is always active; is there
any
system service that can I use to check that ?

I developed a subsystem containing over 500 long-running jobs that
each serve a unique data queue. So, I also wrote a monitor job to run in
this subsystem and manage everything involved. Thus, a service procedure
to do just what you asked for was also something I developed. But, mine
is based off of the job list API so the setup is a bit involved. So, to
give you an idea....

* data structures to map the job list user space
D GenUtl_JobL_Gen_Ptr...
D S *
D GenUtl_JobL_Gen_DS...
D DS likeds(QUSH0100)
D based(GenUtl_JobL_Gen_Ptr)
D GenUtl_JobL_Inp_Ptr...
D S *
D GenUtl_JobL_Inp_DS...
D DS likeds(QUSLI)
D based(GenUtl_JobL_Inp_Ptr)
D GenUtl_JobL_Hdr_Ptr...
D S *
D GenUtl_JobL_Hdr_DS...
D DS likeds(QUSLH)
D based(GenUtl_JobL_Hdr_Ptr)
D GenUtl_JobL_Lst_Ptr...
D S *
D GenUtl_JobL_Lst_DS...
D DS qualified
D based(GenUtl_JobL_Lst_Ptr)
D JobL_Entry dim(999) likeds(QUSL010002)
D JobL_QJobNam 26a overlay(JobL_Entry: 1)
D JobL_JobName 10a overlay(JobL_Entry: 1)

* ============================================================== *
* Determines if a specific job name is active on the system. *
* For performance reasons, the GenUtl_GetJobList procedure may *
* be used to obtain a generic list of job names which this *
* service procedure will search by supplying the list pointer *
* which was returned by the GenUtl_GetJobList procedure. *
* ============================================================== *
P GenUtl_JobIsActive...
P B Export
D PI n
D JobName 10a Const
D ListPtr * Options(*Nopass:*Omit)
D JobDesc likeds(QUSL010002) Options(*Nopass)
* -------------------------------------------------------------- *
D JobIdx S 5p 0
D JobPtr S *
/free
if (%parms > 1
and %addr(ListPtr) <> *null);
JobPtr = ListPtr;
else;
if (GenUtl_GetJobList(JobName: 10: PROC_PGM: JobPtr) = *zero);
callp GenUtl_GetJobList('*RESET': 10: PROC_PGM: JobPtr);
return *off;
endif;
endif;

GenUtl_JobL_Gen_Ptr = JobPtr + 0;
GenUtl_JobL_Inp_Ptr = JobPtr + GenUtl_JobL_Gen_DS.QUSOIP;
GenUtl_JobL_Hdr_Ptr = JobPtr + GenUtl_JobL_Gen_DS.QUSOHS;
GenUtl_JobL_Lst_Ptr = JobPtr + GenUtl_JobL_Gen_DS.QUSOLD;

JobIdx = %lookup(JobName: GenUtl_JobL_Lst_DS.JobL_JobName
: 1: GenUtl_JobL_Gen_DS.QUSNBRLE);

if (JobIdx <> *zero // if job name found in list
and %parms > 2); // and job description requested
JobDesc = GenUtl_JobL_Lst_DS.JobL_Entry(JobIdx); // pass it back
endif;

if (%parms < 2
or %addr(ListPtr) = *null);
callp GenUtl_GetJobList('*RESET': 10: PROC_PGM: JobPtr);
endif;
return (JobIdx <> *zero);
/end-free
* -------------------------------------------------------------- *
P GenUtl_JobIsActive...
P E
* ============================================================== *

* ============================================================== *
* Uses IBM APIs to get a list of active jobs on the system. A *
* userspace in QTEMP is used so its name and a pointer to it is *
* returned and must be re-used on each subsequent call until a *
* job name of *RESET is specified to release the userspace when *
* the current job list is no longer needed. *
* ============================================================== *
P GenUtl_GetJobList...
P B Export
D PI 10i 0
D JobName 10a Const
D MaxJobs 10i 0 Const
D ListName 10a
D ListPtr *
* -------------------------------------------------------------- *
D UserSpaceName S 20a
D UserSpaceSize S 10i 0
/free
UserSpaceName = ListName + 'QTEMP';

if (JobName = '*RESET' // request to delete user space?
or GenUtl_ObjectExists(ListName: '*USRSPC': 'QTEMP'));
callp IBMAPI_DltUsrSpace( UserSpaceName: ApiErrC);
ListPtr = *null;
if (JobName = '*RESET'); // if specifically requested
return *zero; // exit immediately
endif;
endif;
// create user space
UserSpaceSize = %size(QUSH0100) + %size(QUSLI) + %size(QUSLH)
+ (%size(QUSL010002) * (MaxJobs + 1));
callp IBMAPI_CrtUsrSpace( UserSpaceName: 'JOBLIST'
: UserSpaceSize: x'00': '*EXCLUDE'
: 'List of Active Jobs in the System'
: '*YES': ApiErrC);
if (ApiErrC.BytAvail > *zero);
GenUtl_Escape(*omit : 'Message ' + ApiErrC.MsgId + ' occurred in '
+ %trim(PROC_NAME)
+ ' while creating a user space in QTEMP.');
endif;
// fill it with list of active jobs
callp IBMAPI_RtvUsrJobs( UserSpaceName: 'JOBL0100'
: JobName + '*ALL *ALL'
: '*ACTIVE': ApiErrC);
if (ApiErrC.BytAvail > *zero);
GenUtl_Escape(*omit : 'Message ' + ApiErrC.MsgId + ' occurred in '
+ %trim(PROC_PGM)
+ ' while retrieving a list of '
+ %trim(JobName) + ' jobs.');
endif;
// get pointer to user space
callp IBMAPI_RtvPtrUsrSpace( UserSpaceName: ListPtr: ApiErrC);
if (ApiErrC.BytAvail > *zero);
GenUtl_Escape(*omit : 'Message ' + ApiErrC.MsgId + ' occurred in '
+ %trim(PROC_PGM)
+ ' while retrieving a user space pointer.');
endif;

GenUtl_JobL_Gen_Ptr = ListPtr + 0;
GenUtl_JobL_Inp_Ptr = ListPtr + GenUtl_JobL_Gen_DS.QUSOIP;
GenUtl_JobL_Hdr_Ptr = ListPtr + GenUtl_JobL_Gen_DS.QUSOHS;
GenUtl_JobL_Lst_Ptr = ListPtr + GenUtl_JobL_Gen_DS.QUSOLD;

return GenUtl_JobL_Gen_DS.QUSNBRLE;
/end-free
* -------------------------------------------------------------- *
P GenUtl_GetJobList...
P E
* ============================================================== *

Sincerely,

Dave Clark

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.