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

315 lines
17 KiB
HTML
Raw Permalink 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 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(&amp;JOBNAME &amp;OLDUSER &amp;NEWUSER)
/* */
/* Input parameters are as follows: */
/* */
DCL VAR(&amp;JOBNAME) TYPE(*CHAR) LEN(10) /* Input +
job name */
DCL VAR(&amp;OLDUSER) TYPE(*CHAR) LEN(10) /* Input +
old user name */
DCL VAR(&amp;NEWUSER) TYPE(*CHAR) LEN(10) /* Input +
new user name */
/* */
/* Local variables are as follows: */
/* */
DCL VAR(&amp;USRSPC) TYPE(*CHAR) LEN(20) +
VALUE('CHGSCDEUSRQTEMP ') /* User +
space name for APIs */
DCL VAR(&amp;CNTHDL) TYPE(*CHAR) LEN(16) +
VALUE(' ') /* Continuation +
handle */
DCL VAR(&amp;NUMENTB) TYPE(*CHAR) LEN(4) /* Number +
of entries from list job schedule entries +
in binary form */
DCL VAR(&amp;NUMENT) TYPE(*DEC) LEN(8 0) /* Number +
of entries from list job schedule entries +
in decimal form */
DCL VAR(&amp;HDROFFB) TYPE(*CHAR) LEN(4) /* Offset +
to the header portion of the user space in +
binary form */
DCL VAR(&amp;HDRLENB) TYPE(*CHAR) LEN(4) /* Length +
to the header portion of the user space in +
binary form */
DCL VAR(&amp;GENHDR) TYPE(*CHAR) LEN(140) /* Generic +
header information from the user space */
DCL VAR(&amp;HDRINFO) TYPE(*CHAR) LEN(26) /* Header +
information from the user space */
DCL VAR(&amp;LSTSTS) TYPE(*CHAR) LEN(1) /* Status +
of the list in the user space */
DCL VAR(&amp;OFFSETB) TYPE(*CHAR) LEN(4) /* Offset +
to the list portion of the user space in +
binary form */
DCL VAR(&amp;STRPOSB) TYPE(*CHAR) LEN(4) /* Starting +
position in the user space in binary form */
DCL VAR(&amp;ELENB) TYPE(*CHAR) LEN(4) /* List job +
entry length in binary 4 form */
DCL VAR(&amp;LENTRY) TYPE(*CHAR) LEN(1156) /* +
Retrieve area for list job schedule entry */
DCL VAR(&amp;INFOSTS) TYPE(*CHAR) LEN(1) /* Retrieve +
area for information status */
DCL VAR(&amp;JOBNAM) TYPE(*CHAR) LEN(10) /* Retrieve +
area for job name */
DCL VAR(&amp;ENTRY#) TYPE(*CHAR) LEN(6) /* Retrieve +
area for entry number */
DCL VAR(&amp;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(&amp;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(&amp;USRSPC 'SCDL0200' +
&amp;JOBNAME &amp;CNTHDL 0)
/* */
/* Retrieve the generic header from the user space. */
/* */
CALL PGM(QUSRTVUS) PARM(&amp;USRSPC X'00000001' +
X'0000008C' &amp;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(&amp;LSTSTS) VALUE(%SST(&amp;GENHDR 104 1))
IF COND(&amp;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(&amp;NUMENTB) VALUE(%SST(&amp;GENHDR 133 4))
CHGVAR VAR(&amp;NUMENT) VALUE(%BIN(&amp;NUMENTB))
IF COND(&amp;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(&amp;ELENB) VALUE(%SST(&amp;GENHDR 137 4))
CHGVAR VAR(&amp;OFFSETB) VALUE(%SST(&amp;GENHDR 125 4))
CHGVAR VAR(%BIN(&amp;STRPOSB)) VALUE(%BIN(&amp;OFFSETB) + 1)
/* */
/* This loops for the number of entries until no more entries are */
/* found and goes to the ALLDONE label. */
/* */
STARTLOOP: IF COND(&amp;NUMENT = 0) THEN(GOTO CMDLBL(PARTCHK))
/* */
/* This retrieves the list entry. */
/* */
CALL PGM(QUSRTVUS) PARM(&amp;USRSPC &amp;STRPOSB &amp;ELENB +
&amp;LENTRY)
MONMSG MSGID(CPF3C00) EXEC(GOTO CMDLBL(ERROR))
/* */
/* This copies the information status, job name, entry number, and */
/* user name. */
/* */
CHGVAR VAR(&amp;INFOSTS) VALUE(%SST(&amp;LENTRY 1 1))
CHGVAR VAR(&amp;JOBNAM) VALUE(%SST(&amp;LENTRY 2 10))
CHGVAR VAR(&amp;ENTRY#) VALUE(%SST(&amp;LENTRY 12 10))
CHGVAR VAR(&amp;USERNM) VALUE(%SST(&amp;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(&amp;INFOSTS *NE ' ') THEN(GOTO +
CMDLBL(ENDLOOP))
IF COND(&amp;USERNM *NE &amp;OLDUSER) THEN(GOTO +
CMDLBL(ENDLOOP))
/* */
/* This code will issue the CHGJOBSCDE command for the entry. */
/* */
CHGJOBSCDE JOB(&amp;JOBNAM) ENTRYNBR(&amp;ENTRY#) USER(&amp;NEWUSER)
MONMSG MSGID(CPF1620) EXEC(GOTO CMDLBL(NOCHG))
SNDPGMMSG MSG('Entry' *BCAT &amp;JOBNAM *BCAT &amp;ENTRY# +
*BCAT 'was changed.')
GOTO CMDLBL(ENDLOOP)
NOCHG: SNDPGMMSG MSG('Entry' *BCAT &amp;JOBNAM *BCAT &amp;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(&amp;STRPOSB)) VALUE(%BIN(&amp;STRPOSB) +
+ %BIN(&amp;ELENB))
CHGVAR VAR(&amp;NUMENT) VALUE(&amp;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(&amp;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(&amp;HDROFFB) VALUE(%SST(&amp;GENHDR 121 4))
CHGVAR VAR(&amp;HDRLENB) VALUE(%SST(&amp;GENHDR 117 4))
CALL PGM(QUSRTVUS) PARM(&amp;USRSPC &amp;HDROFFB +
&amp;HDRLENB &amp;HDRINFO)
MONMSG MSGID(CPF3C00) EXEC(GOTO CMDLBL(ERROR))
CHGVAR VAR(&amp;CNTHDL) VALUE(%SST(&amp;HDRINFO 11 16))
GOTO CMDLBL(PARTLIST)
/* */
/* All done. Now the temporary user space is deleted. */
/* */
ALLDONE: DLTUSRSPC USRSPC(QTEMP/%SST(&amp;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>