Ejemplo: Utilización de un programa de alteración temporal de solicitud
Este ejemplo muestra el origen del mandato para un mandato y el programa de alteración temporal de solicitud.
El mandato siguiente permite cambiar la propiedad y la descripción de texto de una biblioteca. El programa de alteración temporal de solicitud para este mandato recibe el nombre de la biblioteca, recupera el valor actual del propietario de la biblioteca y el texto descriptivo y, a continuación, coloca estos valores en una serie de mandato y los devuelve.
Nota: Al utilizar los ejemplos de código, acepta los términos de la Información de licencia y exención de responsabilidad de código.
Origen de mandato
CHGLIBATR: CMD PROMPT('Change Library Attributes')
PARM KWD(LIB) +
TYPE(*CHAR) MIN(1) MAX(1) LEN(10) +
KEYPARM(*YES) +
PROMPT('Library to be changed')
PARM KWD(OWNER) +
TYPE(*CHAR) LEN(10) MIN(0) MAX(1) +
KEYPARM(*NO) +
PROMPT('Library owner')
PARM KWD(TEXT) +
TYPE(*CHAR) MIN(0) MAX(1) LEN(50) +
KEYPARM(*NO) +
PROMPT('Text description')
Pgm alteración temp solicitud
El siguiente programa de alteración temporal de solicitud utiliza los caracteres de solicitud selectiva "? ^".
PGM PARM(&cmdname &keyparm1 &rtnstring)
/*********************************************************************/
/* */
/* Declarations of parameters passed to the prompt override program */
/* */
/*********************************************************************/
DCL VAR(&cmdname) TYPE(*CHAR) LEN(20)
DCL VAR(&keyparm1) TYPE(*CHAR) LEN(10)
DCL VAR(&rtnstring) TYPE(*CHAR) LEN(5700)
/********************************************************************/
/* */
/* Return command string structure declaration */
/* */
/********************************************************************/
/* Length of command string generated */
DCL VAR(&stringlen) TYPE(*DEC) LEN(5 0) VALUE(131)
DCL VAR(&binlen) TYPE(*CHAR) LEN(2)
/* OWNER keyword */
DCL VAR(&ownerkwd) TYPE(*CHAR) LEN(8) VALUE('?<OWNER(')
DCL VAR(&name) TYPE(*CHAR) LEN(10)
/* TEXT keyword */
DCL VAR(&textkwd) TYPE(*CHAR) LEN(8) VALUE(' ?<TEXT(')
DCL VAR(&descript) TYPE(*CHAR) LEN(102)
/********************************************************************/
/* */
/* Variables related to command string declarations */
/* */
/********************************************************************/
DCL VAR("e) TYPE(*CHAR) LEN(1) VALUE('''')
DCL VAR(&closparen) TYPE(*CHAR) LEN(1) VALUE(')')
/********************************************************************/
/* */
/* Start of operable code */
/* */
/********************************************************************/
/********************************************************************/
/* */
/* Monitor for exceptions */
/* */
/********************************************************************/
MONMSG MSGID(CPF0000) +
EXEC(GOTO CMDLBL(error))
/********************************************************************/
/* */
/* Retrieve the owner and text description for the library specified*/
/* on the LIB parameter. Note: This program assumes there are */
/* no apostrophes in the TEXT description, such as (Carol's) */
/* */
/********************************************************************/
RTVOBJD OBJ(&keyparm1) OBJTYPE(*LIB) OWNER(&name) TEXT(&descript)
CHGVAR VAR(%BIN(&binlen)) VALUE(&stringlen)
/********************************************************************/
/* */
/* Build the command string */
/* */
/********************************************************************/
CHGVAR VAR(&rtnstring) VALUE(&binlen)
CHGVAR VAR(&rtnstring) VALUE(&rtnstring *TCAT &ownerkwd)
CHGVAR VAR(&rtnstring) VALUE(&rtnstring *TCAT &name)
CHGVAR VAR(&rtnstring) VALUE(&rtnstring *TCAT &closparen)
CHGVAR VAR(&rtnstring) VALUE(&rtnstring *TCAT &textkwd)
CHGVAR VAR(&rtnstring) VALUE(&rtnstring *TCAT "e)
CHGVAR VAR(&rtnstring) VALUE(&rtnstring *TCAT &descript)
CHGVAR VAR(&rtnstring) VALUE(&rtnstring *TCAT "e)
CHGVAR VAR(&rtnstring) VALUE(&rtnstring *TCAT &closparen)
GOTO CMDLBL(pgmend)
ERROR:
/********************************************************************/
/* */
/* Set the command string length to zero */
/* */
/********************************************************************/
CHGVAR VAR(%BIN(&rtnstring 1 2)) VALUE(0)
/********************************************************************/
/* */
/* Send error message(s) */
/* */
/* NOTE: If you want to send a diagnostic message as well as CPF0011*/
/* you will have to enter a valid error message ID in the */
/* MSGID parameter and a valid message file in the MSGF */
/* parameter for the first SNGPGMMSG command listed below. */
/* If you do not want to send a diagnostic message, do not */
/* include the first SNDPGMMSG in your program. However, in */
/* error conditions, you must ALWAYS send CPF0011 so the */
/* second SNDPGMMSG command must be included in your program. */
/* */
/********************************************************************/
SNDPGMMSG MSGID(XXXXXXX) MSGF(MSGLIB/MSGFILE) MSGTYPE(*DIAG)
SNDPGMMSG MSGID(CPF0011) MSGF(QCPFMSG) MSGTYPE(*ESCAPE)
PGMEND:
ENDPGM