Using REXX variables (Scripting) vBase
Use REXX variables as input
One of the basic features of using REXX with Performance Test is to replace recorded inputs with variable names to dynamically replace input data with unique values during playback.
The following example replaces the employee number field with a variable named employee_number. You can also add a loop to increment employee_number by 1 on each iteration of the loop.
Original
<THINK>00.07.907 AT 00:00:21.014
<KEY>ENTER
<CURSOR>01,07
<I01>”add”
<I02>”11111”
</INPUT>
Modified
<THINK>00.07.907 AT 00:00:21.014
<KEY>ENTER
<CURSOR>01,07
<I01>”add”
<I02>employee_number
</INPUT>
It is possible with unattended playback to run one script across multiple terminals. Using variable substitution, you can enter unique input data across the different terminals. For example, you can play back a single script that adds an employee number to the database, while simulating multiple terminals with each terminal entering a unique employee number to the application. To do this, insert a compound variable using PORT as the compound variable extension. In this example, the unattended playback controls are GROUP H01AC054 TERM(4) SUMMARY (*) SCRIPT (TEST1).
employee_number.2 = ‘22222’
employee_number.3 = ‘33333’
employee_number.4 = ‘44444’
<INPUT>
<KEY>ENTER
<I01>employee_number.port
</INPUT>
Perform file I/O from a script
Reading a file from a Performance Test script is done the same way as reading a file in a stand-alone REXX program (see Retrieving-data-from-external-sources-Scripting). Before you read or write to a file, the file must be allocated. ALLOCATE is a TSO command, so you cannot invoke it from REXX in a Performance Test script. Performance Test does provide its own ALLOCATE command. You can use it by invoking ADDRESS HSCMDS.
External File Contents
-------------------------------------------------------------------------------
EDIT USERID1.TRAINING.SCRIPT.INPUT Columns 00001 00072
Command ===> Scroll ===> CSR
****** ***************************** Top of Data ******************************
000100 18751 Covell Ryan 050.00 040.00
000200 23452 Woods Tiger 045.00 900.00
000300 56781 Couples Fred 020.00 840.00
000400 16531 Norman Greg 023.00 560.00
000500 86791 Watson Tom 042.00 480.00
****** **************************** Bottom of Data ****************************
Script Contents
<INPUT>0000002
<KEY>ENTER
</INPUT>
<INPUT>0000003
<KEY>ENTER
<I01>"userab0"
<N03>"n -Vbl"
</INPUT>
<INPUT>0000004
<KEY>CLEAR
</INPUT>
ADDRESS HSCMDS"ALLOC F(MYINDD) DA(USERAB0.TRAINING.SCRIPT.INPUT) SHR"
"EXECIO * DISKR MYINDD (STEM input_rec. FINIS "
ADDRESS HSCMDS"FREE F(MYINDD)"
DO ptr = 1 to input_rec.0
PARSE VAR input_rec.ptr ,
employee_number.ptr ,
last_name.ptr ,
first_name.ptr ,
hours_worked.ptr ,
hourly_rate.ptr
employee_name.ptr = first_name.ptr||' '||last_name.ptr
SAY employee_number.ptr
SAY employee_name.ptr
SAY hours_worked.ptr
SAY hourly_rate.ptr
END
<INPUT>0000005
<KEY>ENTER
<I01>"plaf"
</INPUT>
DO x = 1 TO input_rec.0
<INPUT>0000006
<KEY>ENTER
<I01>"add"
<I02>employee_number.x
</INPUT>
<INPUT>0000007
<KEY>ENTER
<I01>employee_name.x
<I02>hours_worked.x
<I03>hourly_rate.x
</INPUT>
<INPUT>0000014
<KEY>ENTER
<I01>"del"
<I02>employee_number.x
</INPUT>
<INPUT>0000015
<KEY>ENTER
</INPUT>
END
<INPUT>0000016
<KEY>CLEAR
</INPUT>
<INPUT>0000017
<KEY>ENTER
<I01>"cesf logoff"
</INPUT>
Read data from VSAM-GETVSAMR
The command,
retrieves a VSAM record. Four REXX variables are used for this command:
- HS_VSAM_DD
- HS_VSAM_KE
- HS_VSAM_RC
- HS_VSAM_REC
Before issuing this command, set HS_VSAM_DD with the allocated DD name of the VSAM dataset and HS_VSAM_KEY with the key. GETVSAMR sets HS_VSAM_RC as follows:
/*HS_VSAM_RC :Notes */
/*0 :Successful */
/*4 :No record found */
/*8 :HS_VSAM_DD problem */
/*12 :HS_VSAM_KEY problem */
/*14 :HS_VSAM_REC problem */
/*16 :HS_VSAM_DD OPEN error */
/*24 :Not licensed */
/*********************************/
When HS_VSAM_RC is zero, HS_VSAM_REC will contain the VSAM record that matches the specified HS_VSAM_key.
Analyze application screens
You can code REXX in the script to interrogate screen contents. This information can then be used to make IF/THEN/ELSE decisions, to handle synchronization issues, and as input later in the script (as in data replacement).
Use commands such as POS and SUBSTR against the SCREEN variable to analyze data displayed on the screen. The below figure shows an example of this analysis.
Use logic to control script flow
You can use REXX to control playback. Use conditional logic such as IF/THEN/ELSE structures, DO loops, and SELECT structures to do this.
You can wrap DO/END statements around portions of the script. The above figure shows a DO loop wrapped around the section of the script that adds and deletes the employee information to the application. See the below figure for additional examples.
Use the REXX log
The REXX log allows you to create custom reports to document what happens during script execution.
The REXX log creates a file that contains the results of any SAY statements executed from the script.
To create a REXX log during playback via Performance Test for VTAM’s Domain Traveler, enter the RLOG command on the command line. To create a REXX log during an unattended playback, specify RLOG(??) on the GROUP statement.
The below figures shows a complete 3270 script containing REXX logic that:
- Sends the Enter command (up to 100 times) until the system returns a job complete return code
and
- Reports the return code to the REXX log.
Examples of analysis, using logic and the REXX Log (1 of 6)
/* Let's check the tpf before starting with the script execution */
IF tpfname <> 'TSO' THEN
DO
SAY TIME() 'Oops. wrong tpf. Playback aborted'
EXIT
END
SAY TIME() 'The script execution has started'
<IMSUNLOK>N
<OUTPUT>0000001
<RESPONSE>01.27.709
<S01> IKJ56700A ENTER USERID -
<S02>
<S03>
<S04>
<S05>
<S06>
<S07>
<S08>
<S09>
<S10>
<S11>
<S12>
<S13>
<S14>
<S15>
<S16>
<S17>
<S18>
<S19>
<S20>
<S21>
<S22>
<S23>
<S24>
</OUTPUT>
<BASETIME>05/14/07 21:17:24.394
<INPUT>0000002
<THINK>00.04.985 AT 00:00:00.000
<KEY>ENTER
<CURSOR>01,07
<I02>"userab1"
</INPUT>
<OUTPUT>0000002
<RESPONSE>00.00.053
<S01> ------------------------------- TSO/E LOGON ----------------------
<S02>
<S03>
<S04> Enter LOGON parameters below: RACF LOGON para
<S05>
<S06> Userid ===> USERAB1
<MSK> NNNNNNNNNNNNNNNN
<S07>
<S08> Password ===> New Password ==
<MSK> NNNNNNNN
<S09>
<S10> Procedure ===> AISPF41 Group Ident ==
<S11>
<S12> Acct Nmbr ===> OVPBAS5.1.0MNT
<S13>
<S14> Size ===> 4096
<S15>
<S16> Perform ===>
<S17>
<S18> Command ===>
<S19>
<S20> Enter an 'S' before each option desired below:
<S21> -Nomail -Nonotice S -Reconnect -OID
<S22>
<S23> PF1/PF13 ==> Help PF3/PF15 ==> Logoff PA1 ==> Attention P
<S24> You may request specific help information by entering a '?' in any
</OUTPUT>
Examples of analysis, using logic and the REXX Log (2 of 6)
<THINK>00.03.102 AT 00:00:03.412
<KEY>ENTER
<CURSOR>07,25
<N01>"n -Vbl"
</INPUT>
<OUTPUT>0000010
<RESPONSE>00.07.775
<S01> ICH70001I USERAB1 LAST ACCESS AT 21:15:28 ON MONDAY, MAY 14, 2007
<S02> USERAB1 LOGON IN PROGRESS AT 21:17:28 ON MAY 14, 2007
<S03> NO BROADCAST MESSAGES
<S04> ******************************************************************
<S05> * Welcome to CW01
<S06> * Compuware Mainframe System News (restricted to authorized user
<S07> ******************************************************************
<S08> * This system is now running OS/390 V1R2M0
<S09> * Due to the nature of Server Pack operating system installation,
<S10> * many SYSRES/DLIB dataset names have changed. Please reference
<S11> * SYS2.SW.DOCLIB(NEWDSNS) for detailed information on OLD vs NEW D
<S12> * name changes. Please direct any questions to the help desk.
<S13> ******************************************************************
<S14> * Attention Boole CICS Manager Users: Change all references of
<S15> * SYS2A.BOOLE.** to SYS2.BOOLE.** in your in your CICS region JCL
<S16> ******************************************************************
<S17> * Attention VSE Users: VSE migration to the P/390 is scheduled fo
<S18> * May 24-25. Reference SYS2.SW.DOCLIB(VSEMIGR) for details.
<S19> ******************************************************************
<S20> ***
<S21>
<S22>
<S23>
<S24>
</OUTPUT>
<INPUT>0000011
<THINK>00.01.328 AT 00:00:12.782
<KEY>ENTER
<CURSOR>19,05
</INPUT>
<OUTPUT>0000011
<RESPONSE>00.00.384
<S01> Menu Utilities Compilers Options Status Help
<S02> ------------------------------------------------------------------
<S03> ISPF Primary Option Menu
<S04> Option ===>
<S05>
<S06> 0 Settings Terminal and user parameters User ID .
<S07> 1 View Display source data or listings Time. . .
<S08> 2 Edit Create or change source data Terminal.
<S09> 3 Utilities Perform utility functions Screen. .
<S10> 4 Foreground Interactive language processing Language.
<S11> 5 Batch Submit job for language processing Appl ID .
<S12> 6 Command Enter TSO or Workstation commands TSO logon
<S13> 7 Dialog Test Perform dialog testing TSO prefi
<S14> 8 LM Facility Library administrator functions System ID
<S15> 9 IBM Products IBM program development products MVS acct.
<S16> 10 SCLM SW Configuration Library Manager Release .
<S17> D DB2 & QMF DB2I/QMF access to DB2 subsystems
<S18> M MIS MIS Dialogs
<S19> P Products COMPUWARE Product Menu
<S20> S SDSF System Display and Search Facility
<S21> U User User Dialogs
<S22>
<S23>
<S24> Enter X to Terminate using log/list defaults
</OUTPUT>
Examples of analysis, using logic and the REXX Log (3 of 6)
<THINK>00.05.324 AT 00:00:18.760
<KEY>ENTER
<CURSOR>03,16
<I01>"3.4"
</INPUT>
<OUTPUT>0000012
<RESPONSE>00.00.430
<S01> Menu RefList RefMode Utilities Help
<S02> ------------------------------------------------------------------
<S03> Data Set List Utility
<S04> Command ===>
<S05>
<S06> blank Display data set list P Print data set list
<S07> V Display VTOC information PV Print VTOC information
<S08>
<S09> Enter one or both of the parameters below:
<S10> Dsname Level . . . USERAB1.LOGON.CLIST
<S11> Volume serial . .
<S12>
<S13> Data set list options:
<S14> Initial View . . . 1 1. Volume Enter "/" to select o
<S15> 2. Space / Confirm Delete
<S16> 3. Attrib
<S17> 4. Total
<S18>
<S19> The following actions will be available when the list is displayed
<S20> Enter a "/" on the data set list command field for command prom
<S21> Enter TSO commands, CLIST, REXX execs, or "=" to execute previo
<S22>
<S23>
<S24>
</OUTPUT>
<INPUT>0000013
<THINK>00.05.105 AT 00:00:24.573
<KEY>ENTER
<CURSOR>09,44
<I02>"userab0.hiper.scripts"
</INPUT>
<OUTPUT>0000013
<RESPONSE>00.00.263
<S01> Menu Functions Sort Confirm View Utilities Compilers Help
<S02> ------------------------------------------------------------------
<S03> DSLIST - Data Sets Matching USERAB0.HIPER.SCRIPTS
<S04> Command ===> Scro
<S05>
<S06> Command - Enter "/" to select action Message
<S07> ------------------------------------------------------------------
<S08> USERAB0.HIPER.SCRIPTS
<S09> ***************************** End of Data Set list ***************
<S10>
<S11>
<S12>
<S13>
<S14>
<S15>
<S16>
<S17>
<S18>
<S19>
<S20>
<S21>
<S22>
<S23>
<S24>
</OUTPUT>
Examples of analysis, using logic and the REXX Log (4 of 6)
<THINK>00.02.431 AT 00:00:27.527
<KEY>ENTER
<CURSOR>07,02
<I03>"e USERAB0.HIPER.SCRIPTS "
</INPUT>
<OUTPUT>0000014
<RESPONSE>00.00.736
<S01> Menu Functions Utilities Help
<S02> ------------------------------------------------------------------
<S03> EDIT USERAB0.HIPER.SCRIPTS Row 00
<S04> Command ===> Scro
<S05> Name VV MM Created Changed Size Init
<S06> . ABC00000 00.00 07/04/22 07/04/22 15:58 319 10
<S07> . ASIAR 01.01 06/03/13 06/03/13 17:42 168 168
<S08> . ASIA1 00.00 06/03/13 06/03/13 17:16 307 10
<S09> . ASIA2 00.00 06/03/13 06/03/13 18:05 472 15
<S10> . A1 01.01 06/08/26 06/08/26 16:50 1089 1089
<S11> . BATCH 01.97 05/03/10 07/05/12 21:16 16 16
<S12> . BATCHPB 01.00 07/05/12 07/05/12 21:17 16 16
<S13> . BATCH1 01.02 06/04/02 06/04/02 14:16 33 33
<S14> . BATCH2 01.81 04/07/14 06/03/26 10:23 21 16
<S15> . BATCH3 01.01 06/03/26 06/06/10 16:38 15 21
<S16> . BATCH4 01.00 06/03/26 06/03/26 10:21 21 21
<S17> . BBB 00.10 06/08/08 06/08/15 10:13 160 9
<S18> . BBBIN 01.01 06/08/08 06/08/14 17:03 4 4
<S19> . CALLER 01.10 06/07/25 06/07/25 10:50 4 4
<S20> . CHECK2 01.05 06/10/01 06/10/02 09:13 10 14
<S21> . CICSLIST 00.00 06/10/29 06/10/29 17:07 647 17
<S22> . CICSLST1 00.00 06/10/29 06/10/29 17:10 538 14
<S23> . CICSOFF 00.00 06/08/08 06/08/08 14:19 103 3
<S24> . CICSON 00.05 06/08/08 06/09/05 14:41 146 5
</OUTPUT>
<INPUT>0000015
<THINK>00.04.650 AT 00:00:33.172
<KEY>ENTER
<CURSOR>03,23
<I01>"s batchpb"
</INPUT>
<OUTPUT>0000015
<RESPONSE>00.00.370
<S01> File Edit Confirm Menu Utilities Compilers Test Help
<S02> ------------------------------------------------------------------
<S03> EDIT USERAB0.HIPER.SCRIPTS(BATCHPB) - 01.00 Columns
<S04> Command ===> Scro
<S05> ****** ***************************** Top of Data *****************
<S06> ==MSG> -CAUTION- Profile changed to CAPS ON (from CAPS OFF) becaus
<S07> ==MSG> data does not contain any lower case characters.
<S08> 000001 //USERAB0C JOB ('OVPBAS5.0.0DSP',P87,9,9),'RYAN COVELL',REG
<S09> 000002 // NOTIFY=USERAB0,CLASS=2,MSGCLASS=R
<S10> 000003 //*********************************************************
<S11> 000004 //*
<S12> 000005 //* SAMPLE JCL TO EXECUTE Hiperstation
<S13> 000006 //* IN UNATTENDED MODE
<S14> 000007 //*
<S15> 000008 //*********************************************************
<S16> 000009 //HIPER2 EXEC PGM=EHSBATCH,REGION=4096K
<S17> 000010 //STEPLIB DD DISP=SHR,DSN=SYS2.HPER.V531.LOAD
<S18> 000011 //SYSLIB DD DSN=USERAB0.REVENUE.SCRIPTS,DISP=SHR
<S19> 000012 //SYSPRINT DD SYSOUT=*
<S20> 000013 //SYSUDUMP DD SYSOUT=*
<S21> 000014 //SYSIN DD *
<S22> 000015 GROUP H01AC054 TERM(5) SUMMARY(*) XLOG(*)
<S23> 000016 SCRIPT(TEST1)
<S24> ****** **************************** Bottom of Data ***************
</OUTPUT>
<INPUT>0000016
<THINK>00.16.845 AT 00:00:50.644
<KEY>ENTER
<CURSOR>03,17
<I01>"sub"
</INPUT>
Examples of analysis, using logic and the REXX Log (5 of 6)
<RESPONSE>00.01.182
<S01> File Edit Confirm Menu Utilities Compilers Test Help
<S02> -----------------------------------------------------------------
<S03> EDIT USERAB0.HIPER.SCRIPTS(BATCHPB) - 01.00 Column
<S04> Command ===> sub Scr
<S05> ****** ***************************** Top of Data ****************
<S06> ==MSG> -CAUTION- Profile changed to CAPS ON (from CAPS OFF) becau
<S07> ==MSG> data does not contain any lower case characters.
<S08> 000001 //USERAB1C JOB ('OVPBAS5.0.0DSP',P87,9,9),'RYAN COVELL',RE
<S09> 000002 // NOTIFY=USERAB1,CLASS=2,MSGCLASS=R
<S10> 000003 //********************************************************
<S11> 000004 //*
<S12> 000005 //* SAMPLE JCL TO EXECUTE Hiperstation
<S13> 000006 //* IN UNATTENDED MODE
<S14> 000007 //*
<S15> 000008 //********************************************************
<S16> 000009 //HIPER2 EXEC PGM=EHSBATCH,REGION=4096K
<S17> 000010 //STEPLIB DD DISP=SHR,DSN=SYS2.HPER.V531.LOAD
<S18> 000011 //SYSLIB DD DSN=USERAB0.REVENUE.SCRIPTS,DISP=SHR
<S19> 000012 //SYSPRINT DD SYSOUT=*
<S20> 000013 //SYSUDUMP DD SYSOUT=*
<S21> JOB USERAB1C(JOB23067) SUBMITTED
<S22> ***
<S23>
<S24>
</OUTPUT>
/* Press enter until the 'JOB SUBMITTED' message is displayed */
DO loop_ctr = 1 TO 100
x = POS('SUBMITTED',screen)
IF x > 0 THEN
LEAVE
<INPUT>0000020
<KEY>ENTER
</INPUT>
END
IF loop_ctr >= 100 THEN
DO
SAY TIME() 'Job did not successfully submit. Playback aborted.'
EXIT
END
/* Grab the JOBID off from the screen */
job_id = SUBSTR(screen,x - 7,5)
/* Display a message */
SAY TIME() 'Job sucessfully submitted. The JOBID is 'job_id
/* Now loop until the job completes */
DO loop_ctr = 1 TO 100
IF POS('USERAB1C ENDED',screen) > 0 THEN
LEAVE
<WAIT>00,10
<INPUT>0000020
<KEY>ENTER
</INPUT>
END
IF loop_ctr = 100 THEN
DO
SAY TIME() 'Job did not seem to end. Playback aborted.'
EXIT
END
/* Display the return code status */
return_code_position = POS('MAX COND',screen)
return_code_status = SUBSTR(screen,return_code_position,19)
SAY TIME() 'The batch job ended, status is 'return_code_status
Examples of analysis, using logic and the REXX Log (6 of 6)
<RESPONSE>00.00.024
<S01> 21.18.29 JOB23067 $HASP165 USERAB1C ENDED AT CW01 - MAX COND CODE
<S02>NAL)
<S03>
<S04>
<S05>
<S06>
<S07>
<S08>
<S09>
<S10>
<S11>
<S12>
<S13>
<S14>
<S15>
<S16>
<S17>
<S18>
<S19>
<S20>
<S21>
<S22>
<S23>
<S24>
</OUTPUT>
The above script actually continues to go the JES log to check the output messages.
The contents of the REXX log created by the above script is displayed below.
Menu Utilities Compilers Help
-------------------------------------------------------------------------------
BROWSE USERAB0.TRAINING.REXX.LOG Line 00000000 Col 001 080
Command ===> Scroll ===> CSR
********************************* Top of Data **********************************
13:33:08 The script execution has started
13:33:31 Job sucessfully submitted. The JOBID is 27313
13:33:53 The batch job ended, status is MAX COND CODE 0000
13:34:15 The script execution has completed. Bye.
******************************** Bottom of Data ********************************