Use of a REXX routine with the ADBTEP2 program
A REXX routine can provide statements to ADBTEP2 for processing.
REXX %<name> [parm];
- User statements that are in a form that can be processed by ADBTEP2, for example SQL statements, Db2 commands, or DSN commands.
- Iterative processing
You must issue DSNREXX DISCONNECT in the REXX routine before you can use any command that requires ADBTEP2 to connect to Db2.
You can provide information to ADBTEP2 through the user (USERINFO) and utility information (UTILINFO) functions. You can specify a tolerance threshold for utility errors. And you can allocate output from REXX-provided statements processed by ADBTEP2 to a USRPRINT file.
User input
The user input function enables the REXX routine to provide statements on the REXX data stack to ADBTEP2.
--#GET INPUT FROM STACK
REXX %<name> [parms];
- RC=0
- Statements are present on the data stack. The REXX routine writes statements onto the data stack for ADBTEP2 to process. ADBTEP2 pulls the statements from the data stack and processes statements until all statements are processed or until an error occurs.
- RC=4
- No statements are present on the data stack.
- RC<>0, RC<>4
- An error occurred and ADBTEP2 is directed to end processing.
Iterative input
The iterative input function prompts ADBTEP2 to repeat invocation of a REXX routine.
--#GET INPUT FROM STACK WITH ITERATION
REXX %<name> [parms];
- RC=0
- Statements are present on the data stack. ADBTEP2 pulls the statements from the data stack and processes statements until all statements are processed or until an error occurs.
- RC=4
- No statements are present on the data stack.
- Until RC=4
- ADBTEP2 reinvokes the REXX routine to get more statements until the REXX routine ends with RC=4.
- RC<>0, RC<>4
- An error occurred and ADBTEP2 is directed to end processing.
User information
The user information function enables the REXX routine to provide information for iterative REXX calls. The user information function is for iterative input only.
USERINFO <string>;
The
user information statement enables the REXX routine to identify the
work that is passed to ADBTEP2. ADBTEP2 writes the statement back
to the data stack when the REXX routine is invoked the next time,
and only if the call is part of iterative input processing./* rexx */
arg exitrc
queue "USERINFO RUN RUNSTATS ON A TABLE SPACE;
queue "RUNSTATS TABLESPACE ADBDCHG.ADBSPF1",
" INDEX",
" (",
" ALL",
" )",
" SHRLEVEL CHANGE;"
queue ""
exit exitrc
Utility Information
The utility information function enables a REXX routine to provide utility identification information, through ADBTEP2, to Db2.
UTILINFO [SYSTEM<ssid>,][UID=<utility-id>],[UTPROC=<utproc-string>];
The
UTILINFO statement must precede the utility statements to which they apply. Multiple parameters must
be separated by a comma. The statement must end with a semi-colon (;).- SYSTEM
- The value of the SSID() parameter that is passed to ADBTEP2 and then is passed to Db2
- UID
- The value of the WORKLIST() parameter that is passed to ADBTEP2 and then is passed to Db2
- UTPROC
- blank. Passes the supplied JCL procedure, if any, to Db2.
/* rexx */
arg exitrc
queue "UTILINFO SYSTEM='DSNX',UID='VNDR2';"
queue "RUNSTATS TABLESPACE ADBDCHG.ADBSPF1",
" INDEX",
" (",
" ALL",
" )",
" SHRLEVEL CHANGE;"
queue ""
exit 0
Tolerance threshold for Db2 utility command error return codes
The tolerance threshold enables you to specify the error return code number, for a Db2 utility command error, to be tolerated during the processing of REXX statements. When the specified threshold is exceeded, ADBTEP2 stops processing.
--#SET TOLUTILERR n
The value of n is the return code number and must be an integer between 4 to 32767. When processing iterative statements in a REXX routine, the REXX routine, that includes Db2 utility commands, iterates until a return code that is beyond the threshold is encountered or until ADPTEP2 completes execution.
--#SET TOLUTILERR 7
--#GET INPUT FROM STACK WITH ITERATION
REXX T2IN2 0;
In
the example, if the return code for a Db2
utility command error exceeds the value 7, ADPTEP2 stops processing.User Print
The user print function enables you to send output from REXX statements processed by ADBTEP2 to a USRPRINT file.
A USRPRINT file contains output only from Db2. USRPRINT is processed only when a USRPRINT DD statement is provided.
- SYSPRINT and USRPRINT must be preallocated.
- SYSPRINT must be allocated as a non-spool data set with the DISP option as MOD.
- USRPRINT must use the same data set attributes except the DISP option.
//SYSPRINT DD DSN=<your data set>,
// DISP=(MOD,CATLG,CATLG),
// SPACE=(TRK,(10,10,0)),LRECL=137,RECFM=VB,BLKSIZE=141
//USRPRINT DD DSN=<your data set>,
// DISP=(NEW,CATLG,CATLG),
// SPACE=(TRK,(10,10,0)),LRECL=137,RECFM=VB,BLKSIZE=141,
// VOL=SER=<volume name>