330 lines
17 KiB
HTML
330 lines
17 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html lang="en-us" xml:lang="en-us">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta name="security" content="public" />
|
||
|
<meta name="Robots" content="index,follow" />
|
||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
||
|
<meta name="DC.Type" content="reference" />
|
||
|
<meta name="DC.Title" content="Example: Changing an active job" />
|
||
|
<meta name="abstract" content="This program will reduce the run priority of active jobs with the same name." />
|
||
|
<meta name="description" content="This program will reduce the run priority of active jobs with the same name." />
|
||
|
<meta name="DC.Relation" scheme="URI" content="apiexmp.htm" />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="apiexchnjob" />
|
||
|
<meta name="DC.Language" content="en-us" />
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
||
|
<title>Example: Changing an active job</title>
|
||
|
</head>
|
||
|
<body id="apiexchnjob"><a name="apiexchnjob"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Example: Changing an active job</h1>
|
||
|
<div><p>This program will reduce the run priority of active jobs with the
|
||
|
same name.</p>
|
||
|
<div class="section"><div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm">Code license and disclaimer information</a> for important
|
||
|
legal information.</div>
|
||
|
<p>This command interface to the Change Active Jobs
|
||
|
(CHGACTJOB) program can reduce the run priority of active jobs with the same
|
||
|
name. You can also reduce the run priority of jobs using a specified user
|
||
|
name. You may:</p>
|
||
|
<ul><li>Specify a job name or the *ALL value.</li>
|
||
|
<li>Specify the user name as the *ALL value.</li>
|
||
|
<li>Use the default run priority of 99.</li>
|
||
|
</ul>
|
||
|
<p>The CHGACTJOB command ensures that one of the following is true:</p>
|
||
|
<ul><li>Not all jobs were specified.</li>
|
||
|
<li>The *ALL value was not specified for the JOB parameter.</li>
|
||
|
<li>The *ALL value was not specified for the USER parameter.</li>
|
||
|
</ul>
|
||
|
<p>This example uses the following APIs:</p>
|
||
|
<ul><li>Create User Space (QUSCRTUS)</li>
|
||
|
<li>List Job (QUSLJOB)</li>
|
||
|
<li>Retrieve User Space (QUSRTVUS)</li>
|
||
|
<li>Retrieve Job Information (QUSRJOBI)</li>
|
||
|
</ul>
|
||
|
<p>The following is the message description needed for the Change Active
|
||
|
Jobs (CHGACTJOB) command:</p>
|
||
|
<pre>ADDMSGD MSGID(USR3C01) MSGF(QCPFMSG) +
|
||
|
MSG('JOB(*ALL) is not valid with USER(*ALL)') SEV(30)</pre>
|
||
|
<p>The following is the command definition for the CHGACTJOB command:</p>
|
||
|
<pre> CMD PROMPT('Change Active Jobs')
|
||
|
/* CPP CHGACTJOB */
|
||
|
PARM KWD(JOB) TYPE(*NAME) LEN(10) +
|
||
|
SPCVAL((*ALL)) MIN(1) +
|
||
|
PROMPT('Job name:')
|
||
|
PARM KWD(USER) TYPE(*NAME) LEN(10) DFT(*ALL) +
|
||
|
SPCVAL((*ALL) (*CURRENT)) PROMPT('User +
|
||
|
name:')
|
||
|
PARM KWD(RUNPTY) TYPE(*DEC) LEN(5 0) DFT(99) +
|
||
|
RANGE(00 99) PROMPT('Run priority:')
|
||
|
DEP CTL(&USER *EQ *ALL) PARM((&JOB *NE *ALL)) +
|
||
|
NBRTRUE(*EQ 1) MSGID(USR3C01)</pre>
|
||
|
<p>To create the command, specify the following:</p>
|
||
|
<pre>CRTCMD CMD(QGPL/CHGACTJOB) PGM(QGPL/CHGACTJOB) +
|
||
|
SRCFILE(QGPL/CMDSRC)</pre>
|
||
|
<p>The following is the command-processing program that is written
|
||
|
in CL to list the active jobs and reduce the run priority if necessary:</p>
|
||
|
<pre> /* ***************************************************************** */
|
||
|
/* PROGRAM: CHGACTJOB */
|
||
|
/* */
|
||
|
/* LANGUAGE: CL */
|
||
|
/* */
|
||
|
/* DESCRIPTION: THIS PROGRAM WILL REDUCE THE RUN PRIORITY OF ACTIVE */
|
||
|
/* JOBS WITH THE SAME NAME. */
|
||
|
/* */
|
||
|
/* APIs USED: QUSCRTUS, QUSLJOB, QUSRTVUS, QUSRJOBI */
|
||
|
/* */
|
||
|
/* ***************************************************************** */
|
||
|
PGM PARM(&JOB &USER &RUNPTY)
|
||
|
|
||
|
/* */
|
||
|
/* Input parameters */
|
||
|
/* */
|
||
|
|
||
|
DCL VAR(&JOB) TYPE(*CHAR) LEN(10) +
|
||
|
/* Input job name */
|
||
|
DCL VAR(&USER) TYPE(*CHAR) LEN(10) +
|
||
|
/* Input user name */
|
||
|
DCL VAR(&RUNPTY) TYPE(*DEC) LEN(5 0) +
|
||
|
/* Input run priority */
|
||
|
|
||
|
/* */
|
||
|
/* Local variables */
|
||
|
/* */
|
||
|
|
||
|
DCL VAR(&RJOB) TYPE(*CHAR) LEN(10) +
|
||
|
/* Retrieve job name */
|
||
|
DCL VAR(&RUSER) TYPE(*CHAR) LEN(10) +
|
||
|
/* Retrieve user name */
|
||
|
DCL VAR(&RNBR) TYPE(*CHAR) LEN(6) +
|
||
|
/* Retrieve job number */
|
||
|
DCL VAR(&RUNPTYC) TYPE(*CHAR) LEN(5) +
|
||
|
/* Input run priority in character form */
|
||
|
DCL VAR(&RUNPTY8) TYPE(*DEC) LEN(8 0) +
|
||
|
/* Retrieve run priority after convert from +
|
||
|
binary 4 */
|
||
|
DCL VAR(&RUNPTY5) TYPE(*DEC) LEN(5 0) +
|
||
|
/* Retrieve run priority in decimal 5,0 +
|
||
|
form */
|
||
|
DCL VAR(&RUNPTY5C) TYPE(*CHAR) LEN(5) +
|
||
|
/* Retrieve run priority in character form */
|
||
|
DCL VAR(&RUNPTY4) TYPE(*CHAR) LEN(4) +
|
||
|
/* Retrieve run priority in binary 4 form */
|
||
|
DCL VAR(&NUMBER) TYPE(*CHAR) LEN(6) +
|
||
|
/* Current job number */
|
||
|
DCL VAR(&USRSPC) TYPE(*CHAR) LEN(20) +
|
||
|
VALUE('CHGA QTEMP ') +
|
||
|
/* User space name for APIs */
|
||
|
DCL VAR(&EUSRSPC) TYPE(*CHAR) LEN(10) +
|
||
|
/* User space name for commands */
|
||
|
DCL VAR(&JOBNAME) TYPE(*CHAR) LEN(26) +
|
||
|
VALUE(' *ALL ') +
|
||
|
/* Full job name for list job */
|
||
|
DCL VAR(&BIN4) TYPE(*CHAR) LEN(4) +
|
||
|
/* Number of jobs for list job and +
|
||
|
User space offset in binary 4 form */
|
||
|
DCL VAR(&LOOP) TYPE(*DEC) LEN(8 0) +
|
||
|
/* Number of jobs from list job */
|
||
|
DCL VAR(&DEC8) TYPE(*DEC) LEN(8 0) +
|
||
|
/* User space offset in decimal 8,0 form */
|
||
|
DCL VAR(&ELEN) TYPE(*DEC) LEN(8 0) +
|
||
|
/* List job entry length in decimal 8,0 +
|
||
|
form */
|
||
|
DCL VAR(&ELENB) TYPE(*CHAR) LEN(4) +
|
||
|
/* List job entry length in binary 4 +
|
||
|
form */
|
||
|
DCL VAR(&LJOBE) TYPE(*CHAR) LEN(52) +
|
||
|
/* Retrieve area for list job entry */
|
||
|
DCL VAR(&INTJOB) TYPE(*CHAR) LEN(16) +
|
||
|
/* Retrieve area for internal job id */
|
||
|
DCL VAR(&JOBI) TYPE(*CHAR) LEN(104) +
|
||
|
/* Retrieve area for job information */
|
||
|
DCL VAR(&JOBTYPE) TYPE(*CHAR) LEN(1) +
|
||
|
/* Job type */
|
||
|
|
||
|
/* */
|
||
|
/* Start of executable code */
|
||
|
/* */
|
||
|
|
||
|
/* */
|
||
|
/* Retrieve job number to use for local user space name */
|
||
|
/* */
|
||
|
|
||
|
RTVJOBA NBR(&NUMBER)
|
||
|
CHGVAR VAR(%SST(&USRSPC 5 6)) VALUE(&NUMBER)
|
||
|
CHGVAR VAR(&EUSRSPC) VALUE(%SST(&USRSPC 1 10))
|
||
|
|
||
|
/* */
|
||
|
/* Delete user space if it already exists */
|
||
|
/* */
|
||
|
|
||
|
DLTUSRSPC USRSPC(QTEMP/&EUSRSPC)
|
||
|
MONMSG CPF0000
|
||
|
|
||
|
/* */
|
||
|
/* Create user space */
|
||
|
/* */
|
||
|
|
||
|
CALL QUSCRTUS (&USRSPC 'CHGACTJOB ' X'00000100' ' ' +
|
||
|
'*ALL ' +
|
||
|
'CHGACTJOB TEMPORARY USER SPACE-
|
||
|
')
|
||
|
|
||
|
/* */
|
||
|
/* Set up job name for list jobs */
|
||
|
/* */
|
||
|
|
||
|
CHGVAR VAR(%SST(&JOBNAME 1 10)) VALUE(&JOB)
|
||
|
CHGVAR VAR(%SST(&JOBNAME 11 10)) VALUE(&USER)
|
||
|
|
||
|
/* */
|
||
|
/* List active jobs with job name specified */
|
||
|
/* */
|
||
|
|
||
|
CALL QUSLJOB (&USRSPC 'JOBL0100' &JOBNAME +
|
||
|
'*ACTIVE ')
|
||
|
|
||
|
/* */
|
||
|
/* Retrieve number of entries returned. Convert to decimal and */
|
||
|
/* if zero go to NOJOBS label to send out 'No jobs' message. */
|
||
|
/* */
|
||
|
|
||
|
CALL QUSRTVUS (&USRSPC X'00000085' X'00000004' +
|
||
|
&BIN4)
|
||
|
CHGVAR &LOOP %BINARY(&BIN4)
|
||
|
IF COND(&LOOP = 0) THEN(GOTO CMDLBL(NOJOBS))
|
||
|
|
||
|
/* */
|
||
|
/* Retrieve list entry length, convert to decimal. */
|
||
|
/* Retrieve list entry offset, convert to decimal, and add one */
|
||
|
/* to set the position. */
|
||
|
/* */
|
||
|
|
||
|
CALL QUSRTVUS (&USRSPC X'00000089' X'00000004' +
|
||
|
&ELENB)
|
||
|
CHGVAR &ELEN %BINARY(&ELENB)
|
||
|
CALL QUSRTVUS (&USRSPC X'0000007D' X'00000004' +
|
||
|
&BIN4)
|
||
|
CHGVAR &DEC8 %BINARY(&BIN4)
|
||
|
CHGVAR VAR(&DEC8) VALUE(&DEC8 + 1)
|
||
|
|
||
|
/* */
|
||
|
/* Loop for the number of jobs until no more jobs then go to */
|
||
|
/* ALLDONE label */
|
||
|
/* */
|
||
|
|
||
|
STARTLOOP: IF (&LOOP = 0) THEN(GOTO ALLDONE)
|
||
|
|
||
|
/* */
|
||
|
/* Convert decimal position to binary 4 and retrieve list job entry */
|
||
|
/* */
|
||
|
|
||
|
CHGVAR %BINARY(&BIN4) &DEC8
|
||
|
CALL QUSRTVUS (&USRSPC &BIN4 &ELENB +
|
||
|
&LJOBE)
|
||
|
|
||
|
/* */
|
||
|
/* Copy internal job identifier and retrieve job information for */
|
||
|
/* basic performance information. */
|
||
|
/* */
|
||
|
|
||
|
CHGVAR VAR(&INTJOB) VALUE(%SST(&LJOBE 27 16))
|
||
|
CALL QUSRJOBI (&JOBI X'00000068' 'JOBI0100' +
|
||
|
'*INT ' +
|
||
|
&INTJOB)
|
||
|
|
||
|
/* */
|
||
|
/* Copy job type and if subsystem monitor, spool reader, system job, */
|
||
|
/* spool writer, or SCPF system job then loop to next job */
|
||
|
/* */
|
||
|
|
||
|
CHGVAR VAR(&JOBTYPE) VALUE(%SST(&JOBI 61 1))
|
||
|
IF COND((&JOBTYPE = 'M') *OR (&JOBTYPE = 'R') +
|
||
|
*OR (&JOBTYPE = 'S') *OR (&JOBTYPE = 'W') +
|
||
|
*OR (&JOBTYPE = 'X')) +
|
||
|
THEN(GOTO CMDLBL(ENDLOOP))
|
||
|
|
||
|
/* */
|
||
|
/* Copy run priority, convert to decimal, convert to decimal 5,0, */
|
||
|
/* and if request run priority is less than or equal to the current */
|
||
|
/* run priority then loop to next job. */
|
||
|
/* */
|
||
|
|
||
|
CHGVAR VAR(&RUNPTY4) VALUE(%SST(&JOBI 65 4))
|
||
|
CHGVAR &RUNPTY8 %BINARY(&RUNPTY4)
|
||
|
CHGVAR VAR(&RUNPTY5) VALUE(&RUNPTY8)
|
||
|
IF COND(&RUNPTY5 *GE &RUNPTY) THEN(GOTO +
|
||
|
CMDLBL(ENDLOOP))
|
||
|
|
||
|
/* */
|
||
|
/* Retrieve job name, convert to run priority to character, change */
|
||
|
/* the job run priority and seen message stating the run priority */
|
||
|
/* was changed. */
|
||
|
/* */
|
||
|
|
||
|
CHGVAR VAR(&RJOB) VALUE(%SST(&JOBI 9 10))
|
||
|
CHGVAR VAR(&RUSER) VALUE(%SST(&JOBI 19 10))
|
||
|
CHGVAR VAR(&RNBR) VALUE(%SST(&JOBI 29 6))
|
||
|
CHGVAR VAR(&RUNPTYC) VALUE(&RUNPTY)
|
||
|
CHGVAR VAR(&RUNPTY5C) VALUE(&RUNPTY5)
|
||
|
CHGJOB JOB(&RNBR/&RUSER/&RJOB) RUNPTY(&RUNPTYC)
|
||
|
MONMSG MSGID(CPF1343) EXEC(GOTO CMDLBL(ENDLOOP))
|
||
|
SNDPGMMSG MSG('Job' *BCAT &RNBR *TCAT '/' *TCAT +
|
||
|
&RUSER *TCAT '/' *TCAT &RJOB *BCAT 'run +
|
||
|
priority was change from' *BCAT &RUNPTY5C +
|
||
|
*BCAT 'to' *BCAT &RUNPTYC *TCAT '.')
|
||
|
|
||
|
/* */
|
||
|
/* At end of loop set new decimal position to next entry and */
|
||
|
/* decrement loop counter by one. */
|
||
|
/* */
|
||
|
|
||
|
ENDLOOP: CHGVAR VAR(&DEC8) VALUE(&DEC8 + &ELEN)
|
||
|
CHGVAR VAR(&LOOP) VALUE(&LOOP - 1)
|
||
|
GOTO CMDLBL(STARTLOOP)
|
||
|
|
||
|
/* */
|
||
|
/* Send message that no jobs were found. */
|
||
|
/* */
|
||
|
|
||
|
NOJOBS: SNDPGMMSG MSG('No jobs found.')
|
||
|
|
||
|
/* */
|
||
|
/* All done. Now delete temporary user space that we created. */
|
||
|
/* */
|
||
|
|
||
|
ALLDONE: DLTUSRSPC USRSPC(QTEMP/&EUSRSPC)
|
||
|
MONMSG CPF0000
|
||
|
ENDPGM</pre>
|
||
|
<p>The program can be changed to change the run priority by removing
|
||
|
the IF statement to compare the current and requested run priority.</p>
|
||
|
<p>To
|
||
|
create the CL program, specify the following:</p>
|
||
|
<pre>CRTCLPGM PGM(QGPL/CHGACTJOB) SRCFILE(QGPL/QCLSRC)</pre>
|
||
|
<p>You
|
||
|
can change the command to:</p>
|
||
|
<ul><li>Specify a different printer device.</li>
|
||
|
<li>Specify a different output queue.</li>
|
||
|
<li>Specify different job attributes that the Change Job (CHGJOB) command
|
||
|
can change.</li>
|
||
|
<li>List only jobs on an output queue and remove the spooled files.</li>
|
||
|
<li>Provide a menu to select jobs to be changed.</li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="apiexmp.htm" title="Contains example programs that use APIs and exit programs.">Examples: APIs</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|