Job Is Active

From MidrangeWiki
Revision as of 21:43, 14 December 2018 by DaveLClarkI (talk | contribs) (Created page with "Category:Sample Code Category:Service Procedures __FORCETOC__ == Summary == The following are the RPG/LE fully free-form definitions and instructions needed for using...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Summary

The following are the RPG/LE fully free-form definitions and instructions needed for using the Job Is Active service procedure. This service procedure simply allows the caller to check if a particular job is active on the system—or not.

Service Prototype

Place the following in a separate copybook for inclusion in both the caller and the service program source members.

**free

//******************************************************************************
// 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
// space pointer which was returned by the GenUtl_GetJobList() procedure.
//******************************************************************************
dcl-pr GenUtl_JobIsActive    ind;
  JobName                    char(10)  const;
  ListPtr                    pointer            options(*nopass:*omit);
  JobDesc                    likeds(QUSL010002) options(*nopass);
end-pr;

Service Procedure

Place the following in a service program source member.

**free
ctl-opt NoMain AlwNull(*UsrCtl) Debug Option(*SrcStmt:*NoDebugIo)
        DatFmt(*ISO) TimFmt(*ISO);

//******************************************************************************
// 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
// space pointer which was returned by the GenUtl_GetJobList() procedure.
//******************************************************************************
dcl-proc GenUtl_JobIsActive  export;
  dcl-pi *n                  ind;
    JobName                  char(10)  const;
    ListPtr                  pointer            options(*nopass:*omit);
    JobDesc                  likeds(QUSL010002) options(*nopass);
  end-pi;

  dcl-s JobIdx               packed(5:0);
  dcl-s JobPtr               pointer;

  if %parms() > %parmnum(JobName)      // if space pointer passed
  and %addr(ListPtr) <> *null;         // and was not omitted
    JobPtr = ListPtr;                  // use it
  else;                                // else, get a job list
    if GenUtl_GetJobList(JobName: 10: PROC_NAME: JobPtr) = *zero;
      callp GenUtl_GetJobList('*RESET': 10: PROC_NAME: JobPtr);
      return *off;                     // return if job not found
    endif;
  endif;

  GenUtl_JobL_Gen_Ptr = JobPtr + 0;    // map space header areas
  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 ); // search list

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

  if %parms() < %parmnum(ListPtr)      // if space pointer not passed
  or %addr(ListPtr) = *null;           // or was omitted, reset new list
    callp GenUtl_GetJobList('*RESET': 10: PROC_NAME: JobPtr);
  endif;

  return (JobIdx <> *zero);            // indicate if job was found
end-proc;

References