SETVAR directive
Purpose
- 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.
Syntax
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:
- See Date formats allowed in the SETVAR directive.
- Day-in-year formats:
- See Day-in-year formats allowed in the SETVAR directive.
- Day-in-month formats:
- ODD, OLDD, CDD
- Day-in-week formats:
- OWWD, CWWD
- Day-of-week formats:
- ODAY, OLDAY, CDAY
- Week formats:
- OWW, OLWK, CWW
- Month formats:
- See Month formats allowed in the SETVAR directive.
- Year formats:
- OYY, OYYYY, CYY, CYYYY
- Time formats:
- See Time formats allowed in the SETVAR directive.
- 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
-
- WD
- Work days, as defined for the calendar used by the occurrence.
- 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.
- PHASE=SETUP|SUBMIT
- Specifies whether the SETVAR calculation should take place during
the setup or submit phase of the operation. This parameter is optional,
and if nothing is specified, the default SUBMIT is assumed. Note: If you use setup phase, you can still use submit-phase date or time variables (those beginning with the letter C) in the expression for the temporary variable.
- 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 quotation marks. It can be
up to 48 characters.
If the length of the whole statement in the JCL reaches column 72, the error message EQQJ585E 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.
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 97/12/26, the expression is substituted as follows:
TVAR=(360+4)
TVAR=364
If the occurrence input arrival date is 97/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 97/12/26, the expressions are substituted as follows:
CDATE = 'ACCURATE DATE 1997 12 26'
TDATE = 'ACCURATE DATE 1997 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 occurrence 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 1997, the resulting date of the temporary variable must be later than 92/12/31 and earlier than 05/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 ofVAR1
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:
In fact the SUBSTR parameter identifies a substring ofTVAR1 = 080616 TVAR2 = 06 TVAR3 = 080716 TVAR4 = 07
TVAR1
andTVAR3
values, starting from position 3 for a length of 2 characters. According to the format set by the SETFORM directive, it identifies theMM
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