ibm-information-center/dist/eclipse/plugins/i5OS.ic.apiref_5.4.0.1/apiexchnjob.htm

330 lines
17 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?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(&amp;USER *EQ *ALL) PARM((&amp;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(&amp;JOB &amp;USER &amp;RUNPTY)
/* */
/* Input parameters */
/* */
DCL VAR(&amp;JOB) TYPE(*CHAR) LEN(10) +
/* Input job name */
DCL VAR(&amp;USER) TYPE(*CHAR) LEN(10) +
/* Input user name */
DCL VAR(&amp;RUNPTY) TYPE(*DEC) LEN(5 0) +
/* Input run priority */
/* */
/* Local variables */
/* */
DCL VAR(&amp;RJOB) TYPE(*CHAR) LEN(10) +
/* Retrieve job name */
DCL VAR(&amp;RUSER) TYPE(*CHAR) LEN(10) +
/* Retrieve user name */
DCL VAR(&amp;RNBR) TYPE(*CHAR) LEN(6) +
/* Retrieve job number */
DCL VAR(&amp;RUNPTYC) TYPE(*CHAR) LEN(5) +
/* Input run priority in character form */
DCL VAR(&amp;RUNPTY8) TYPE(*DEC) LEN(8 0) +
/* Retrieve run priority after convert from +
binary 4 */
DCL VAR(&amp;RUNPTY5) TYPE(*DEC) LEN(5 0) +
/* Retrieve run priority in decimal 5,0 +
form */
DCL VAR(&amp;RUNPTY5C) TYPE(*CHAR) LEN(5) +
/* Retrieve run priority in character form */
DCL VAR(&amp;RUNPTY4) TYPE(*CHAR) LEN(4) +
/* Retrieve run priority in binary 4 form */
DCL VAR(&amp;NUMBER) TYPE(*CHAR) LEN(6) +
/* Current job number */
DCL VAR(&amp;USRSPC) TYPE(*CHAR) LEN(20) +
VALUE('CHGA QTEMP ') +
/* User space name for APIs */
DCL VAR(&amp;EUSRSPC) TYPE(*CHAR) LEN(10) +
/* User space name for commands */
DCL VAR(&amp;JOBNAME) TYPE(*CHAR) LEN(26) +
VALUE(' *ALL ') +
/* Full job name for list job */
DCL VAR(&amp;BIN4) TYPE(*CHAR) LEN(4) +
/* Number of jobs for list job and +
User space offset in binary 4 form */
DCL VAR(&amp;LOOP) TYPE(*DEC) LEN(8 0) +
/* Number of jobs from list job */
DCL VAR(&amp;DEC8) TYPE(*DEC) LEN(8 0) +
/* User space offset in decimal 8,0 form */
DCL VAR(&amp;ELEN) TYPE(*DEC) LEN(8 0) +
/* List job entry length in decimal 8,0 +
form */
DCL VAR(&amp;ELENB) TYPE(*CHAR) LEN(4) +
/* List job entry length in binary 4 +
form */
DCL VAR(&amp;LJOBE) TYPE(*CHAR) LEN(52) +
/* Retrieve area for list job entry */
DCL VAR(&amp;INTJOB) TYPE(*CHAR) LEN(16) +
/* Retrieve area for internal job id */
DCL VAR(&amp;JOBI) TYPE(*CHAR) LEN(104) +
/* Retrieve area for job information */
DCL VAR(&amp;JOBTYPE) TYPE(*CHAR) LEN(1) +
/* Job type */
/* */
/* Start of executable code */
/* */
/* */
/* Retrieve job number to use for local user space name */
/* */
RTVJOBA NBR(&amp;NUMBER)
CHGVAR VAR(%SST(&amp;USRSPC 5 6)) VALUE(&amp;NUMBER)
CHGVAR VAR(&amp;EUSRSPC) VALUE(%SST(&amp;USRSPC 1 10))
/* */
/* Delete user space if it already exists */
/* */
DLTUSRSPC USRSPC(QTEMP/&amp;EUSRSPC)
MONMSG CPF0000
/* */
/* Create user space */
/* */
CALL QUSCRTUS (&amp;USRSPC 'CHGACTJOB ' X'00000100' ' ' +
'*ALL ' +
'CHGACTJOB TEMPORARY USER SPACE-
')
/* */
/* Set up job name for list jobs */
/* */
CHGVAR VAR(%SST(&amp;JOBNAME 1 10)) VALUE(&amp;JOB)
CHGVAR VAR(%SST(&amp;JOBNAME 11 10)) VALUE(&amp;USER)
/* */
/* List active jobs with job name specified */
/* */
CALL QUSLJOB (&amp;USRSPC 'JOBL0100' &amp;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 (&amp;USRSPC X'00000085' X'00000004' +
&amp;BIN4)
CHGVAR &amp;LOOP %BINARY(&amp;BIN4)
IF COND(&amp;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 (&amp;USRSPC X'00000089' X'00000004' +
&amp;ELENB)
CHGVAR &amp;ELEN %BINARY(&amp;ELENB)
CALL QUSRTVUS (&amp;USRSPC X'0000007D' X'00000004' +
&amp;BIN4)
CHGVAR &amp;DEC8 %BINARY(&amp;BIN4)
CHGVAR VAR(&amp;DEC8) VALUE(&amp;DEC8 + 1)
/* */
/* Loop for the number of jobs until no more jobs then go to */
/* ALLDONE label */
/* */
STARTLOOP: IF (&amp;LOOP = 0) THEN(GOTO ALLDONE)
/* */
/* Convert decimal position to binary 4 and retrieve list job entry */
/* */
CHGVAR %BINARY(&amp;BIN4) &amp;DEC8
CALL QUSRTVUS (&amp;USRSPC &amp;BIN4 &amp;ELENB +
&amp;LJOBE)
/* */
/* Copy internal job identifier and retrieve job information for */
/* basic performance information. */
/* */
CHGVAR VAR(&amp;INTJOB) VALUE(%SST(&amp;LJOBE 27 16))
CALL QUSRJOBI (&amp;JOBI X'00000068' 'JOBI0100' +
'*INT ' +
&amp;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(&amp;JOBTYPE) VALUE(%SST(&amp;JOBI 61 1))
IF COND((&amp;JOBTYPE = 'M') *OR (&amp;JOBTYPE = 'R') +
*OR (&amp;JOBTYPE = 'S') *OR (&amp;JOBTYPE = 'W') +
*OR (&amp;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(&amp;RUNPTY4) VALUE(%SST(&amp;JOBI 65 4))
CHGVAR &amp;RUNPTY8 %BINARY(&amp;RUNPTY4)
CHGVAR VAR(&amp;RUNPTY5) VALUE(&amp;RUNPTY8)
IF COND(&amp;RUNPTY5 *GE &amp;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(&amp;RJOB) VALUE(%SST(&amp;JOBI 9 10))
CHGVAR VAR(&amp;RUSER) VALUE(%SST(&amp;JOBI 19 10))
CHGVAR VAR(&amp;RNBR) VALUE(%SST(&amp;JOBI 29 6))
CHGVAR VAR(&amp;RUNPTYC) VALUE(&amp;RUNPTY)
CHGVAR VAR(&amp;RUNPTY5C) VALUE(&amp;RUNPTY5)
CHGJOB JOB(&amp;RNBR/&amp;RUSER/&amp;RJOB) RUNPTY(&amp;RUNPTYC)
MONMSG MSGID(CPF1343) EXEC(GOTO CMDLBL(ENDLOOP))
SNDPGMMSG MSG('Job' *BCAT &amp;RNBR *TCAT '/' *TCAT +
&amp;RUSER *TCAT '/' *TCAT &amp;RJOB *BCAT 'run +
priority was change from' *BCAT &amp;RUNPTY5C +
*BCAT 'to' *BCAT &amp;RUNPTYC *TCAT '.')
/* */
/* At end of loop set new decimal position to next entry and */
/* decrement loop counter by one. */
/* */
ENDLOOP: CHGVAR VAR(&amp;DEC8) VALUE(&amp;DEC8 + &amp;ELEN)
CHGVAR VAR(&amp;LOOP) VALUE(&amp;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/&amp;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>