HCL Workload Automation, Version 9.4

SETVAR directive

Purpose

This directive creates a temporary variable using one of the following:
  • An arithmetic expression together with supplied date or time variables.
  • A substring of another variable.
  • The result of an arithmetic addition or subtraction.
  • Concatenated strings or variables set to an alphanumeric value.
After the agent for z/OS processes the SETVAR directive, you can use the temporary variable in the same way as you use other variables. You can redefine a temporary variable later in the job.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-//*%OPC SETVAR----------------------------------------------->

>--+-Tname=--(--date time variable +/- nnnTT1 nnnTT2 nnnTT3--)-+-><
   +-Tname=--SUBSTR--(--variable--,--n--,--length--)-----------+   
   +-Tname=--(--numeric value / 'alphanumeric value'--)--------+   
   +-Tname=--(--variable1 +/- variable2--)---------------------+   
   |               .--------------------.                      |   
   |               V                    |                      |   
   '-Tname=--(--'----concatenation item-+--'--)----------------'   

Parameters

Tname=(date time variable +/- nnnTT1 nnnTT2 nnnTT3)
Tname
The name of the temporary variable, beginning with the letter T.
date time variable
One of the following defined formats:
Date formats:
ODMY1, ODMY2, OYMD, OYMD1, OYMD2, OYMD3, CDDMMYY, CYMD, CYYMMDD, OCDATE, CDATE
Day-in-year formats:
ODDD, OYYDDD, OLYYDDD, CDDD, CYYDDD
Day-in-month formats:
ODD, CDD
Day-in-week formats:
OWWD, CWWD
Day-of-week formats:
ODAY, CDAY
Week formats:
OWW, CWW
Month formats:
OMM, OMMYY, OYM, OYYMM, CMM, CMMYY, CYYMM, CYYYYMM
Year formats:
OYY, OYYYY, CYY, CYYYY
Time formats:
OHHMM, CHHMM, CHHMMSSX, CTIME, OCTIME
Hour formats:
OHH, OLHH, CHH, CYYY
nnn
A number in the range 0 to 999.
TT1
The first possible type. You can specify the following values:
For date-related variables
CD
Calendar days.
WK
Weeks. Weeks are converted to days before the calculation is performed.
MO
Months. Performing calculation on the month portion affects only the month, and possibly the year. The calculation always generates valid results, handling actual months durations and leap years. For example, adding one month to 080131 gives 080229 (considering the leap year).
YR
Years.
For time-related variables
HH
Hours.
MM
Minutes.
SS
Seconds.
TT2
The second possible type, valid only for time-related variables. You can specify the following values:
MM
Minutes.
SS
Seconds.
TT3
The third possible type, valid only for time-related variables. You can specify only the value SS (seconds).

You can use the format nnnTT1 nnnTT2 nnnTT3 only for time-related variables, to add or subtract hours, minutes, and seconds to or from a given time. Specify this triple format only if you want to specify hours, minutes, and seconds.

Using duplicated types, as for example in 6HH, 5MM, 7MM, is not allowed.

variable
The name of the source string variable. Use an existing variable name properly defined and accessible. You can specify any supplied or user-defined variable. The length of the variable that is replaced is limited to the remaining JCL row length that is not used by the statement.
n
An integer in the range 1 to 60. It defines the starting position, in variable, of the substring variable. If it exceeds the length of variable, the resulting substring is padded with blank.
length
An integer in the range 1 to 60. It defines the length of the substring variable. If it exceeds the length of variable, the resulting substring is padded with blank.
numeric value
An integer in the range 0 to 99999, defining the value of the temporary variable.
alphanumeric value
String of alphanumeric characters, defining the value of the temporary variable. Enclose the string in single quotes. It can be up to 48 characters.

If the length of the whole statement in the JCL reaches column 72, an error message is issued.

variable1
An integer in the range 0 to 99999, defining the first operand of an arithmetic addition or subtraction, whose result defines the value of the temporary variable. The arithmetic expression cannot include blank characters.
variable2
An integer in the range 0 to 99999, defining the first operand of an arithmetic addition or subtraction, whose result defines the value of the temporary variable. The arithmetic expression cannot include blank characters.
concatenation item
One of the following:
  • A variable previously set to an alphanumeric value.
  • A string of alphanumeric characters.
Enclose the item list in single quotes. The result cannot exceed 48 characters.

Usage Notes

These examples show how to use temporary variables created through SETVAR:

Example 1 (with an arithmetic expression)

If the occurrence input arrival date is 12/12/26, the expression is substituted as follows:

TVAR=(360+4)
TVAR=364

If the occurrence input arrival date is 12/12/30, the expression is substituted as follows:

TVAR=(364+4)
TVAR=003

Example 2 (with dynamic-format variable)

//*%OPC SCAN
//*%OPC SETFORM CDATE=(ACCURATE DATE CCYY MM DD)
//*%OPC SETVAR  TDATE=(CDATE + 1CD)

If the occurrence input arrival date is 12/12/26, the expressions are substituted as follows:

CDATE = 'ACCURATE DATE 2012 12 26'
TDATE = 'ACCURATE DATE 2012 12 27'

If the expression includes dynamic-format supplied variables containing the first or the last day in the month or in the year of the job stream instance IA, the calculated date must fall within the range of four years earlier and seven years later than the current year. If the current year is 2012, the resulting date of the temporary variable must be later than 07/12/31 and earlier than 20/01/01.

Example 3 (SUBSTR usage)

  • Using a variable defined in a JCL variable table:
    //*%OPC SETVAR  TVAR=SUBSTR(&VAR1,2,4)

    VAR1 is a variable defined in a JCL variable table.

    TVAR is a substring of VAR1 value, starting from position 2 for a length of 4 characters.

  • Using a predefined variable:
    //*%OPC SETFORM OCDATE=(YYMMDD)
    //*%OPC SETVAR TVAR1=('&OCDATE')
    //*%OPC SETVAR TVAR2=SUBSTR(&TVAR1,3,2)
    //*%OPC SETVAR TVAR3=(OCDATE + 1MO)
    //*%OPC SETVAR TVAR4=SUBSTR(&TVAR3,3,2)
    If the occurrence input arrival date is 08/06/16, the expressions are substituted as follows:
    TVAR1 = 080616
    TVAR2 = 06
    TVAR3 = 080716
    TVAR4 = 07
    In fact the SUBSTR parameter identifies a substring of TVAR1 and TVAR3 values, starting from position 3 for a length of 2 characters. According to the format set by the SETFORM directive, it identifies the MM part of the date value.

Example 4 (arithmetic with temporary variables)

//*%OPC SETVAR TX=(1)
//*%OPC SETVAR TY=(2)
//*%OPC SETVAR TZ=(&TX+&TY)
TZ is a temporary variable set to the result of the arithmetic addition.

Example 5 (concatenating temporary variables)

//*%OPC SETVAR T001=('STRING1')
//*%OPC SETVAR T002=('STRING2')
//*%OPC SETVAR T003=('&T001 &T002 CONCATENATED STRINGS')
T003 is a temporary variable set to the following value: STRING1 STRING2 CONCATENATED STRINGS