315 lines
17 KiB
HTML
315 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 a job schedule entry" />
|
|
<meta name="abstract" content="This program will change the user for a list of job schedule entries." />
|
|
<meta name="description" content="This program will change the user for a list of job schedule entries." />
|
|
<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="apiexchnent" />
|
|
<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 a job schedule entry</title>
|
|
</head>
|
|
<body id="apiexchnent"><a name="apiexchnent"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Example: Changing a job schedule entry</h1>
|
|
<div><p>This program will change the user for a list of job schedule entries.</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 Job Schedule
|
|
Entry User (CHGSCDEUSR) program can change the USER parameter in the job schedule
|
|
entry. You may:</p>
|
|
<ul><li>Specify a job schedule entry name </li>
|
|
<li>Specify a generic job schedule entry name </li>
|
|
<li>Specify the *ALL value</li>
|
|
</ul>
|
|
<p>This example uses the following APIs:</p>
|
|
<ul><li>Create User Space (QUSCRTUS) </li>
|
|
<li>List Job Schedule Entries (QWCLSCDE) </li>
|
|
<li>Retrieve User Space (QUSRTVUS)</li>
|
|
</ul>
|
|
<p>The following is the command definition for the CHGSCDEUSR command:</p>
|
|
<pre> CMD PROMPT('Change Job Schedule Entry User')
|
|
/* CPP CHGSCDEUSR */
|
|
PARM KWD(JOB) TYPE(*GENERIC) LEN(10) +
|
|
SPCVAL((*ALL)) +
|
|
MIN(1) PROMPT('Job name:')
|
|
PARM KWD(OLDUSER) TYPE(*NAME) LEN(10) +
|
|
MIN(1) PROMPT('Old user name:')
|
|
PARM KWD(NEWUSER) TYPE(*NAME) LEN(10) +
|
|
MIN(1) PROMPT('New user name:')</pre>
|
|
<p>To create the command, specify the following:</p>
|
|
<pre>CRTCMD CMD(QGPL/CHGSCDEUSR) PGM(QGPL/CHGSCDEUSR) +
|
|
SRCFILE(QGPL/QCMDSRC)</pre>
|
|
<p>The following is the command-processing
|
|
program that is written in CL to list the job schedule entries and change
|
|
the user if necessary:</p>
|
|
<pre> /* **************************************************************** */
|
|
/* PROGRAM: CHGSCDEUSR */
|
|
/* */
|
|
/* LANGUAGE: CL */
|
|
/* */
|
|
/* DESCRIPTION: THIS PROGRAM WILL CHANGE THE USER FOR A LIST OF */
|
|
/* JOB SCHEDULE ENTRIES. */
|
|
/* */
|
|
/* APIs USED: QUSCRTUS, QWCLSCDE, QUSRTVUS */
|
|
/* */
|
|
/* **************************************************************** */
|
|
PGM PARM(&JOBNAME &OLDUSER &NEWUSER)
|
|
|
|
/* */
|
|
/* Input parameters are as follows: */
|
|
/* */
|
|
|
|
DCL VAR(&JOBNAME) TYPE(*CHAR) LEN(10) /* Input +
|
|
job name */
|
|
DCL VAR(&OLDUSER) TYPE(*CHAR) LEN(10) /* Input +
|
|
old user name */
|
|
DCL VAR(&NEWUSER) TYPE(*CHAR) LEN(10) /* Input +
|
|
new user name */
|
|
|
|
/* */
|
|
/* Local variables are as follows: */
|
|
/* */
|
|
|
|
DCL VAR(&USRSPC) TYPE(*CHAR) LEN(20) +
|
|
VALUE('CHGSCDEUSRQTEMP ') /* User +
|
|
space name for APIs */
|
|
DCL VAR(&CNTHDL) TYPE(*CHAR) LEN(16) +
|
|
VALUE(' ') /* Continuation +
|
|
handle */
|
|
DCL VAR(&NUMENTB) TYPE(*CHAR) LEN(4) /* Number +
|
|
of entries from list job schedule entries +
|
|
in binary form */
|
|
DCL VAR(&NUMENT) TYPE(*DEC) LEN(8 0) /* Number +
|
|
of entries from list job schedule entries +
|
|
in decimal form */
|
|
DCL VAR(&HDROFFB) TYPE(*CHAR) LEN(4) /* Offset +
|
|
to the header portion of the user space in +
|
|
binary form */
|
|
DCL VAR(&HDRLENB) TYPE(*CHAR) LEN(4) /* Length +
|
|
to the header portion of the user space in +
|
|
binary form */
|
|
DCL VAR(&GENHDR) TYPE(*CHAR) LEN(140) /* Generic +
|
|
header information from the user space */
|
|
DCL VAR(&HDRINFO) TYPE(*CHAR) LEN(26) /* Header +
|
|
information from the user space */
|
|
DCL VAR(&LSTSTS) TYPE(*CHAR) LEN(1) /* Status +
|
|
of the list in the user space */
|
|
DCL VAR(&OFFSETB) TYPE(*CHAR) LEN(4) /* Offset +
|
|
to the list portion of the user space in +
|
|
binary form */
|
|
DCL VAR(&STRPOSB) TYPE(*CHAR) LEN(4) /* Starting +
|
|
position in the user space in binary form */
|
|
DCL VAR(&ELENB) TYPE(*CHAR) LEN(4) /* List job +
|
|
entry length in binary 4 form */
|
|
DCL VAR(&LENTRY) TYPE(*CHAR) LEN(1156) /* +
|
|
Retrieve area for list job schedule entry */
|
|
DCL VAR(&INFOSTS) TYPE(*CHAR) LEN(1) /* Retrieve +
|
|
area for information status */
|
|
DCL VAR(&JOBNAM) TYPE(*CHAR) LEN(10) /* Retrieve +
|
|
area for job name */
|
|
DCL VAR(&ENTRY#) TYPE(*CHAR) LEN(6) /* Retrieve +
|
|
area for entry number */
|
|
DCL VAR(&USERNM) TYPE(*CHAR) LEN(10) /* Retrieve +
|
|
area for user name */
|
|
|
|
/* */
|
|
/* Start of code */
|
|
/* */
|
|
|
|
/* */
|
|
/* You may want to monitor for additional messages here. */
|
|
/* */
|
|
|
|
/* */
|
|
/* This creates the user space. The user space will be 256 bytes */
|
|
/* and will be initialized to blanks. */
|
|
/* */
|
|
|
|
CALL PGM(QUSCRTUS) PARM(&USRSPC 'CHGSCDEUSR' +
|
|
X'00000100' ' ' '*ALL ' 'CHGSCDEUSR +
|
|
TEMPORARY USER SPACE ')
|
|
MONMSG MSGID(CPF3C00) EXEC(GOTO CMDLBL(ERROR))
|
|
|
|
/* */
|
|
/* This lists job schedule entries of the name specified. */
|
|
/* */
|
|
|
|
PARTLIST: CALL PGM(QWCLSCDE) PARM(&USRSPC 'SCDL0200' +
|
|
&JOBNAME &CNTHDL 0)
|
|
|
|
/* */
|
|
/* Retrieve the generic header from the user space. */
|
|
/* */
|
|
|
|
CALL PGM(QUSRTVUS) PARM(&USRSPC X'00000001' +
|
|
X'0000008C' &GENHDR)
|
|
MONMSG MSGID(CPF3C00) EXEC(GOTO CMDLBL(ERROR))
|
|
/* */
|
|
/* Get the information status for the list from the generic header. */
|
|
/* If it is incomplete, go to BADLIST label and send out 'Bad list' */
|
|
/* message. */
|
|
/* */
|
|
|
|
CHGVAR VAR(&LSTSTS) VALUE(%SST(&GENHDR 104 1))
|
|
IF COND(&LSTSTS = 'I') THEN(GOTO CMDLBL(BADLIST))
|
|
|
|
/* */
|
|
/* Get the number of entries returned. Convert to decimal and */
|
|
/* if zero go to NOENTS label to send out 'No entries' message. */
|
|
/* */
|
|
|
|
CHGVAR VAR(&NUMENTB) VALUE(%SST(&GENHDR 133 4))
|
|
CHGVAR VAR(&NUMENT) VALUE(%BIN(&NUMENTB))
|
|
IF COND(&NUMENT = 0) THEN(GOTO CMDLBL(NOENTS))
|
|
|
|
/* */
|
|
/* Get the list entry length and the list entry offset. */
|
|
/* These values are used to set up the starting position. */
|
|
/* */
|
|
|
|
CHGVAR VAR(&ELENB) VALUE(%SST(&GENHDR 137 4))
|
|
CHGVAR VAR(&OFFSETB) VALUE(%SST(&GENHDR 125 4))
|
|
CHGVAR VAR(%BIN(&STRPOSB)) VALUE(%BIN(&OFFSETB) + 1)
|
|
|
|
/* */
|
|
/* This loops for the number of entries until no more entries are */
|
|
/* found and goes to the ALLDONE label. */
|
|
/* */
|
|
|
|
STARTLOOP: IF COND(&NUMENT = 0) THEN(GOTO CMDLBL(PARTCHK))
|
|
|
|
/* */
|
|
/* This retrieves the list entry. */
|
|
/* */
|
|
CALL PGM(QUSRTVUS) PARM(&USRSPC &STRPOSB &ELENB +
|
|
&LENTRY)
|
|
MONMSG MSGID(CPF3C00) EXEC(GOTO CMDLBL(ERROR))
|
|
/* */
|
|
/* This copies the information status, job name, entry number, and */
|
|
/* user name. */
|
|
/* */
|
|
|
|
CHGVAR VAR(&INFOSTS) VALUE(%SST(&LENTRY 1 1))
|
|
CHGVAR VAR(&JOBNAM) VALUE(%SST(&LENTRY 2 10))
|
|
CHGVAR VAR(&ENTRY#) VALUE(%SST(&LENTRY 12 10))
|
|
CHGVAR VAR(&USERNM) VALUE(%SST(&LENTRY 547 10))
|
|
|
|
/* */
|
|
/* This checks to make sure the list entry contains the user name. */
|
|
/* If it does, the user name is compared to the old user name */
|
|
/* passed in. If either of these checks fails, this entry will */
|
|
/* be skipped. */
|
|
/* */
|
|
|
|
IF COND(&INFOSTS *NE ' ') THEN(GOTO +
|
|
CMDLBL(ENDLOOP))
|
|
|
|
IF COND(&USERNM *NE &OLDUSER) THEN(GOTO +
|
|
CMDLBL(ENDLOOP))
|
|
|
|
/* */
|
|
/* This code will issue the CHGJOBSCDE command for the entry. */
|
|
/* */
|
|
|
|
CHGJOBSCDE JOB(&JOBNAM) ENTRYNBR(&ENTRY#) USER(&NEWUSER)
|
|
MONMSG MSGID(CPF1620) EXEC(GOTO CMDLBL(NOCHG))
|
|
SNDPGMMSG MSG('Entry' *BCAT &JOBNAM *BCAT &ENTRY# +
|
|
*BCAT 'was changed.')
|
|
GOTO CMDLBL(ENDLOOP)
|
|
NOCHG: SNDPGMMSG MSG('Entry' *BCAT &JOBNAM *BCAT &ENTRY# +
|
|
*BCAT 'was NOT changed.')
|
|
|
|
/* */
|
|
/* At end of loop, set new decimal position to the next entry and */
|
|
/* decrement the loop counter by one. */
|
|
/* */
|
|
|
|
ENDLOOP: CHGVAR VAR(%BIN(&STRPOSB)) VALUE(%BIN(&STRPOSB) +
|
|
+ %BIN(&ELENB))
|
|
CHGVAR VAR(&NUMENT) VALUE(&NUMENT - 1)
|
|
GOTO CMDLBL(STARTLOOP)
|
|
|
|
/* */
|
|
/* This sends a message that no entries were found. */
|
|
/* */
|
|
|
|
NOENTS: SNDPGMMSG MSG('No entries found.')
|
|
GOTO CMDLBL(ALLDONE)
|
|
|
|
/* */
|
|
/* This sends a message that the list was incomplete. */
|
|
/* */
|
|
|
|
BADLIST: SNDPGMMSG MSG('Incomplete list in the user space. +
|
|
See joblog for details.')
|
|
GOTO CMDLBL(ALLDONE)
|
|
|
|
/* */
|
|
/* This sends a message that an unexpected error occurred. */
|
|
/* */
|
|
|
|
ERROR: SNDPGMMSG MSG('Unexpected error. +
|
|
See joblog for details.')
|
|
GOTO CMDLBL(ALLDONE)
|
|
|
|
/* */
|
|
/* This will check for a partial list in the user space and */
|
|
/* finish processing the rest of the list. */
|
|
/* */
|
|
|
|
PARTCHK: IF COND(&LSTSTS = 'C') THEN(GOTO CMDLBL(ALLDONE))
|
|
/* */
|
|
/* Retrieve the header information from the user space. */
|
|
/* Use this information to get the rest of the list. */
|
|
/* */
|
|
|
|
CHGVAR VAR(&HDROFFB) VALUE(%SST(&GENHDR 121 4))
|
|
CHGVAR VAR(&HDRLENB) VALUE(%SST(&GENHDR 117 4))
|
|
CALL PGM(QUSRTVUS) PARM(&USRSPC &HDROFFB +
|
|
&HDRLENB &HDRINFO)
|
|
MONMSG MSGID(CPF3C00) EXEC(GOTO CMDLBL(ERROR))
|
|
CHGVAR VAR(&CNTHDL) VALUE(%SST(&HDRINFO 11 16))
|
|
GOTO CMDLBL(PARTLIST)
|
|
|
|
|
|
/* */
|
|
/* All done. Now the temporary user space is deleted. */
|
|
/* */
|
|
|
|
ALLDONE: DLTUSRSPC USRSPC(QTEMP/%SST(&USRSPC 1 10))
|
|
MONMSG MSGID(CPF0000)
|
|
ENDPGM</pre>
|
|
<p>To create the CL program, specify the following:</p>
|
|
<pre>CRTCLPGM PGM(QGPL/CHGSCDEUSR) SRCFILE(QGPL/QCLSRC)</pre>
|
|
<p>You
|
|
can change the command to:</p>
|
|
<ul><li>Specify different parameters that the Change Job Schedule Entry (CHGJOBSCDE)
|
|
command can change. </li>
|
|
<li>Provide a menu to select job schedule entries 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> |