Previous Topic

Next Topic

Book Contents

Book Index

Built-in functions for DO statements

The following built-in functions are available for any of the DO statements that require textual input.

Tab.JV.3.17a Built-in functions

Function

Description

CALCDATE

Performs date calculations based on a given date.

Valid format:

%%var = %%$CALCDATE date ±quantity

where

date - must be in the format yymmdd

quantity - is a number, or numeric AutoEdit expression, of days to add to or subtract

GETWORD

Gets the value of a JCL parameter from a predefined variable.

Valid format:

%%var = %%$GETWORD %%var num

where

var - variable name (can be a user defined variable)

num - the sequential subparameter (If there are more than one subparameters, for example, DSN and DCB.) Maximum value is 128.

LENGTH

Returns the length of string.

Valid format:

%%var = %%$LENGTH argument

where

argument - a variable name or a built-in function

LOWER

Convert a string into lowercase characters.

Valid format:

%%var = %%$LOWER %%var

NUM

Return the numeric value of a variable. Used for converting values that appear in such variables as: REGION, MEMLIMIT, BLKSIZE. (For example, 10M can be converted to 10000000).

Valid format:

%%var = %%$NUM %%var

ORIGIN

Verifies if JCL parameters were added by the user or they were added as JCL or CTM default parameters.

Valid format:

%%var = %%$ORIGIN %%$var_operand

where

var_operand - a variable name

For the following "ON" statements: JOB, INCLUDE, EXEC, DD, END, PROC, DDSYSIN, JCLLIB, DDSYSOUT the input can be:

  • %%$JOBCLS - The JOB class value
  • %%$JOBPRTY - The JOB priority value
  • %%$JOBMSGC - The JOB msgclass value
  • %%$JOBMSGL - The JOB msglevel value
  • %%$JOBREGN - The JOB region size
  • %%$JOBTIME - The JOB max CPU value
  • %%$JOBUSER - The user name value
  • %%$JOBMEMLMT - The memory limit above the bar
  • %%$JOBPERFORM - The WLM class for the job

ORIGIN

(continued)

For the following "ON" statements: EXEC, DD, END, DDSYSIN, DDSYSOUT the input can be:

  • %%$EXECPROG - Program name
  • %%$EXECPROC - Procedure name
  • %%$EXECREGN - Step's region size
  • %%$EXECTIME - Step's max CPU value
  • %%$EXECPARM - The PARAM value (up to 100 characters)
  • %%$EXMEMLMT - Step's memory limit above the bar
  • %%$EXPERFORM - Step's WLM class

For the following "ON" statements: DD, DDSYSIN, DDSYSOUT, END the input can be:

  • %%$DSORG - Dataset DSORG value
  • %%$RECFM - Dataset RECFM value
  • %%$LRECL - Dataset LRECL value
  • %%$BLKSZ - Dataset BLKSZ value
  • %%$DDDISP1 - Dataset DISP
  • %%$DDUNIT - Dataset UNIT value
  • %%$DDVOL# - Dataset VOLUME value
  • %%$DDDTCLS - Dataset data class value
  • %%$DDMNGCLS - Dataset management class value
  • %%$DDSTORCLS - Dataset storage class value

If the input value is invalid (not from the above list for each "ON" statement) an error is displayed in the Control-M JCL Verify Rule Definition Facility (JR screen).

The ORIGIN function can return the following values:

  • YES - the JCL statement parameter exists in the original JCL, for example added by user.
  • NO - the JCL statement parameter does not exist in the original JCL.
  • CTM - the JCL statement parameter was added by Control-M during submission time.

ORIGIN can only accept one Control-M JCL Verify built-in variable as an input.

An error message is displayed, if the user types an invalid value. For example, for the following ON JOB statement:

DO SET %%VAR=%%$ORIGIN %%$EXECTIME

An error message is displayed since the %%$EXECTIME variable is not a valid input for an ON JOB statement (as indicated in the above list).

POS

Locates a substring in a specified string, and returns the position of the first occurrence of the located substring.

Valid format:

%%var = %%$POS substring string start

where

substring - constant or variable that contains the substring for which to search

string - constant or variable that contains the string in which to search for the specified substring

start - search starting position in the string; maximum value is 128

Note: If the substring is not found in the specified string, function %%$POS returns a value of 0.

SUBSTR

Returns the substring of string that begins at the nth character and is of defined length, padded with pads if necessary.

Valid format:

%%var = %%$SUBSTR %%var start length

where

start - search starting position in the %%var

length - length of the substring (default- to the end of the %%var)

TIME

Returns the current time in HHMMSS format.

Valid format:

%%var = %%$TIME

UPPER

Convert a string into uppercase characters.

Valid format:

%%var = %%$UPPER %%var

ISNUM

Indicates whether a specified string is numeric. In order to be considered numeric, the specified string must contain only numeric characters from 0 through 9, because a numeric string cannot contain letters, blanks, or special characters.

Possible values returned by this function are

  • YES — the specified string is numeric
  • NO — the specified string is not numeric

Valid format:

%%var = %%$ISNUM string

PARSE

The %%$PARSE function is a powerful tool that offers extensive string manipulation capabilities. This function, which is similar to the REXX PARSE command in the TSO/E environment, can be used to analyze and extract information from various variables strings.

The %%$PARSE function parses a specified string (that is, it splits the specified string into substrings) according to a specified template. A template consists of variables and "patterns" that determine the parsing process.

Note that variable %%$PARSRC contains how the function ended. It is recommended that whenever using %%$PARSE to always check the variable %%$PARSRC.

Valid format:

%%var = %%$PARSE string template

where

string - is the AutoEdit variable that contains the string to be parsed

template - is the AutoEdit variable or constant that contains the template

Example 1

DO SET %%S=THIS IS A SAMPLE STRING

DO SET %%T=A1 A2 A3 A4 A5

DO SET %%$PARSE %%S %%T

The %%$PARSE function assigns substrings of the specified string to the specified variables according to the specified template.

The DO SET statements in the above example provide the same result as the following DO SET statements:

DO SET %%A1=THIS

DO SET %%A2=IS

DO SET %%A3=A

DO SET %%A4=SAMPLE

DO SET %%A5=STRING

PARSE

(continued)

Example 2

This example is similar to Example 1, except that a comma is used as the delimiter between words.

If the string includes commas, instead of blanks, as in the following:

DO SET %%S=THIS,IS,A,SAMPLE,STRING

use the following pattern to achieve the same results as in Example 1 above:

DO SET %%T=A1 ',' A2 ',' A3 ',' A4 ',' A5

DO SET %%$PARSE %%S %%T

For more details about the %%$PARSE function, see Appendix The %%$PARSE function.

PARSRC

The return code resulting from a %%$PARSE function that indicates whether the parsed string matched all string patterns in the template.

Valid values returned by this function are

  • 0 - The parsed string fully matched the string patterns in the template.
  • 4 - At least one string pattern in the template was not matched.

NULL

A null variable.

Valid format:

%%var = %%$NULL

BLANK

Resolves to one blank.

Valid format:

%%var = %%$BLANK

BLANKn

Resolves to n blanks, where n is a number from 1 through 99.

Valid format:

%%var = %%$BLANKn

WORDS

The number of words in the varname variable. A comma or a blank can serve as a delimiter within the variable.

Valid format:

%%var = %%$WORDS varname

PLUS

Arithmetic operator that adds two operands.

Valid format:

DO SET %%var = %%var %%$PLUS n

Example:

DO SET %%I = %%I %%$PLUS 1

MINUS

Arithmetic operator that subtracts one operand from another operand.

Valid format:

DO SET %%var = %%var %%$MINUS n

Example:

DO SET %%I = %%I %%$MINUS 1

Note: Negative values are not supported, therefore the results are always absolute. For example:

1 %%$MINUS 24 ==> 23 (not -23)

TIMES

Arithmetic operator that multiplies one operand by another operand.

Valid format:

DO SET %%var = %%var %%$TIMES n

Example:

DO SET %%I = %%I %%$TIMES 1

DIV

Arithmetic operator that divides one operand by another operand.

Valid format:

DO SET %%var = %%var %%$DIV n

Example:

DO SET %%I = %%I %%$DIV 1

D2X

Decimal value-to-hexadecimal string converter. The maximum number that can be converted with this variable is 2147483647, or 231-1.

Valid format:

%%var = %%$D2X num

Example:

To convert decimal 4095 to the equivalent hexadecimal string (FFF), specify %%$D2X 4095.

X2D

Hexadecimal string-to-decimal value converter. The result of the conversion is always positive. The highest number that can be converted using this variable is 7FFFFFFF.

Valid format:

%%var = %%$X2D string

Example:

To convert the hexadecimal string "FFF" to the equivalent decimal value (4095), specify %%$X2D FFF.

X2C

Hexadecimal string-to-character converter.

Valid format:

%%var = %%$X2C string

Example:

To convert the hexadecimal string "2A4F" to text format, specify %%$X2C 2A4F.

SYSINREAD

The %%$SYSINREAD function reads data from SYSIN statements (in-stream, PDS members, and sequential files).

Valid format:

%%var = %%$SYSINREAD %%varname lines start

where

varname - is the name of the stem variable

               After the execution:

               %%varname0 - holds the number of records read

               %%varname1 - holds the first data record (80 chars)

lines - maximum number of lines to read

start - number indicating the first line to read

To read the entire SYSIN, “lines start” can be omitted and the following call can be used:

%%var = %%$SYSINREAD %%varname

The function returns the following return codes:

  • 0 - Success
  • 4 - Some of the data was read but one or more of the concatenated datasets were not available, did not exist, or the LRECL was different than 80
  • 8 - No data was read (e.g. empty SYSIN, none of the concatenated datasets could be accessed)
  • 16 - Error

Notes:

  • The SYSIN statements will become available in the ON DDSYSIN invocations only.
  • ON DDSYSIN will be invoked once for each DD name instead of for each DD statement (therefore concatenated DD statements will be processed in one single rule invocation).
  • The entire SYSIN, which includes all the concatenated datasets, will be accessible as a whole in the rule itself.
  • Only datasets with LRECL=80 (sequential and PDS members) are supported, besides in-stream (DD *) statements.

Example

   DO SET %%READRC = %%$SYSINREAD %%DATA

   IF  %%READRC GE# 8                   

   DO MSG E SYSIN READ FAILED          

   ENDIF                                

   DO MSG I FIRST RECORD IS %%DATA1     

CURSTMTTYP

Returns the current statement type where the specified comment card appears. Available only for ON INIT rules.

Valid format:

%%$CURSTMTTYP n

where n is the comment card number/index (or a variable).

CURSTMTLBL

Returns the current statement label where the specified comment card appears. Available only for ON INIT rules.

Valid format:

%%$CURSTMTLBL n

where n is the comment card number/index (or a variable).

NXTSTMTTYP

Returns the next statement type relative to where the specified comment card appears. Available only for ON INIT rules.

Valid format:

%%$NXTSTMTTYP n

where n is the comment card number/index (or a variable).

NXTSTMTLBL

Returns the next statement label relative to where the specified comment card appears. Available only for ON INIT rules.

Valid format:

%%$NXTSTMTLBL n

where n is the comment card number/index (or a variable).

UNDERSTEP

Returns the step name under which the specified comment card appears. Available only for ON INIT rules.

Valid format:

%%$UNDERSTEP n

where n is the comment card number/index (or a variable).

CMNT2JCL

Returns the JCL card number (as in %%$JCLx) that corresponds to the specified comment card. Available only for ON INIT rules.

Valid format:

%%$CMNT2JCL n

where n is the comment card number/index (or a variable).

CURSTMTFJ

Returns the JCL card number (as in %%$JCLx) that corresponds to the first JCL card in the statement where the specified comment card appears. Available only for ON INIT rules.

Valid format:

%%$CURSTMTFJ n

where n is the comment card number/index (or a variable).

CURSTMTLJ

Returns the JCL card number (as in %%$JCLx) that corresponds to the last JCL card in the statement where the specified comment card appears. Available only for ON INIT rules.

Valid format:

%%$CURSTMTLJ n

where n is the comment card number/index (or a variable).

CMNTLOC

Returns one of the following values:

  • WITHIN - Indicates that the specified comment card appears within a statement, with the continuation of the statement in the following non-comment card(s).
  • FOLLOW - Indicates that the specified comment card appears after all statement cards in a block of only comment cards. The block of cards where it appears probably describes the following statement.

Available only for ON INIT rules.

Valid format:

%%$CMNTLOC n

where n is the comment card number/index (or a variable).

Parent Topic

Parameter Descriptions