Control Statements (A-O)

Review the following control statements.
view
Review the following control statements.
Contents
2
BREAK Control Statement
The BREAK control statement is used with the DO control statement to stop iteration and processing of the DO group where the BREAK control statement is embedded. Processing continues with the control statement following the DO group.
Syntax
BREAK
The BREAK control statement contains no additional parameters.
CONTINUE Control Statement
The CONTINUE control statement is used with the DO control statement to perform the next iteration and processing of the DO group where the CONTINUE control statement is embedded. If the scope or bounds of the DO operation are reached, processing continues with the control statement following the DO group.
Syntax
CONTINUE
CONTROL Control Statement
The CONTROL control statement alters the default specification for line count, line size, database ddname, print file ddname, and output file name.
Syntax
CONTROL          LINECNT=
n
         LINESIZE=
n
         DATABASE=
high-level-name
         PRTFILE=
name
         OUTFILE=
name
         RULER=YES|NO
where:
  • LINECNT=
    n
    Specifies the maximum lines printed per page of output.
    must be a number greater than 10.
    The default line count is 60 lines. Aliases of LINECNT are LINECOUNT, LINES, LC, and L.
  • LINESIZE=
    n
    Specifies the maximum width of a print line including the carriage control 
    n
    .
  • DATABASE=
    high-level-name
    Specifies the high-level name of the database
    If omitted, the high-level name specified in the PARM parameter on the EXEC JCL statement is used. Aliases for DATABASE are DB and D.
  • PRTFILE=
    name
    Specifies the name of the DD statement to which the PRINT control statement writes its output.
    The default ddname is PRTFILE. Aliases for PRTFILE are PRT, PF, and P.
  • OUTFILE=
    name
    Specifies the name of the DD statement to which the OUTPUT control statement writes its output.
    The default ddname is OUTFILE. Aliases for OUTFILE are OUT, OF, and O.
  • RULER=YES|NO
    Specifies whether or not a special line of dashes is printed after the sub-heading lines generated from the PRINT control statement. The special line contains dashes under each individual field that is print. The length of the dash is equal to the length of the field being printed or the sub-heading field whichever is longer.
    The default is NO. Specify YES to generate the special ruler line.
Example
To specify a line width of 80, a line count of 55, and a print DD statement of PRINT, enter the following:
/CONTROL LINESIZE=80 LINECNT=55 PRTFILE=PRINT
DEFINE Control Statement
The DEFINE control statement defines fields to retain or store the content of data or values.
Syntax
DEFINE field    BIN(    
len
)     CHAR(   
len
)     DATE         PACK(   
len
)
Alternate specifications are specified in a columnar fashion.
Defined fields are not sent to or received from sort unless the field is part of the SORT control statement.
Do not use the same name as any field in the database or unpredictable results occur.
where:
  • field
    Specifies the name of the field to define.
    The name can be 1 - 12 characters in length and must begin with an alphabetic or national character ($, #, @). Multiple field names can be defined by enclosing a list of field names in parentheses.
  • BIN(
    len
    )
    Specifies that the field is defined as a binary field.
    len 
    specifies the length of the binary field.
    The length is specified in bytes and can be a number from 1 through 4. Binary fields other than 4 bytes do not carry a sign. The alias for BIN is BINARY.
    If the length is omitted, the field is 4 bytes in length.
  • CHAR(
    len
    )
    Specifies that the field is defined as a character field.
    len
     specifies the length.
    The length, specified in bytes, can be a number from 1 through 256. The alias for CHAR is CHARACTER.
    If the length is omitted, the field is 1 byte in length.
  • DATE
    Specifies the definition of a date field.
    A date field is maintained internally as the number of days from January 1, 1900 in binary. Date fields print (PRINT control statement) in the default date format and output (OUTPUT control statement) as a 4-byte packed Julian date. These formats can be altered by using the EDIT function.
  • PACK(
    len
    )
    Specifies that the field is defined as a packed field.
    len
     specifies the length of the packed field.
    The length is specified in bytes and can be a number from 1 through 8. The aliases for PACK are PACKED, DEC, and DECIMAL. The default length for the field type (8 bytes) is used if the length is omitted.
Examples
To define a 20-byte character field named CHR, specify:
/DEFINE CHR CHAR(20)
To define three fields I, J, and K as binary, specify:
/DEFINE (I,J,K) BIN
DO Control Statement
The DO control statement repeats a given set of statements a specified number of times, until a certain condition is met or while a certain condition is met. The set of statements following the DO control statement and preceding the corresponding END control statement constitute a DO group. This DO group continues to execute as long as all necessary conditions are met. As a point of reference, the function and evaluation of the DO control statement itself is referred to as DO operation.
Syntax
DO  field =     
expression-1
 TO 
expression-2
 BY
 expression-3
    FOREVER UNTIL(  
condition
) WHILE(
condition
)
where:
  • field
    Specifies the name of the defined field (DEFINE control statement) that is set and incremented during the DO operation.
  • expression-1
    Specifies an expression that defines the initial value for the DO operation.
  • expression-2
    Specifies an expression that defines the final value or limit for the DO operation.
    When the final value is exceeded, execution of the DO group is ended.
  • expression-3
    Specifies an expression that defines the incrementing value for the DO operation.
    If BY increment-expression is not specified, a value of +1 is used for an ascending range (expression-1 is less than or equal to expression-2), and a value of -1 is used for a descending range (expression-1 is greater than expression-2).
  • FOREVER
    Specifies continual execution of the DO group.
    The FOREVER keyword is mutually exclusive with the field = expression-1 TO expression-2 BY expression-3 specification.
  • UNTIL (
    condition
    )
    Specifies that the execution of the DO group is to continue until the given condition is true.
  • WHILE (
    condition
    )
    Specifies that the execution of the DO group is to continue while the specified condition is true.
All operands for the DO control statement are optional. If no operands are specified, or only field = expression-1 is specified, the DO group is executed one time only. The DO group continues to execute until one of the following conditions is met:
  • The value for field exceeds the range specified by expression-1 to expression-2.
  • A true condition is received for the UNTIL condition.
  • A false condition is received for the WHILE condition.
The execution of the DO group can also be interrupted by a BREAK control statement, by a STOP control statement, or by an end-of-data condition retrieving database records or sort records.
DO control statements can be nested within IF control statements or other DO control statements to any level. Avoid an infinite loop when coding the UNTIL or WHILE conditions.
For sample DO control statement, see RELEASE control statement.
ELSE Control Statement
The ELSE control statement is used with the IF control statement to indicate the statements that receive control when a false condition is determined on the IF control statement.
Syntax
ELSE
END Control Statement
The END control statement specifies the end of a DO control statement, an IF control statement, or an ON control statement. There must be a one-to-one correspondence between each DO/IF and END control statement. An END control statement at the lowest level (level 1) indicates the last control statement.
Syntax
END
IF Control Statement
The IF control statement can be used for conditional execution of statements.
The evaluation of the IF control statement determines a true or false condition. If the condition is true, processing continues with the next statement. If the condition is false, processing continues with the statement following either the corresponding ELSE control statement or END control statement if an ELSE control statement was not provided. Conclude the group of statements related to the IF control statement with END.
Syntax
IF 
condition
 THEN    …    …
ELSE
   …    … END
where:
  • condition
    Specifies the condition that is checked to determine the sequence of statements to execute.
  • ELSE
    Nests the IF control statement to any level within DO or other IF control statements.
    The ELSE control statement is optional.
Example
To accumulate the number of catalogued and uncatalogued tapes for later printing, specify:
/DEFINE (CAT,UCAT) BIN /IF TAPECAT = 'N' /   SET UCAT=UCAT+1 /ELSE /   SET CAT=CAT+1 /END
NEXT Control Statement
The NEXT control statement retrieves the next value of a database field. This statement can be used only for retrieving address lines, special instruction lines, text specification entries, history entries, report identifiers, and distribution identifiers.
Syntax
NEXT RECORD
The NEXT control statement allows you to obtain the next record from the database or the next sort record.
For an example of the NEXT control statement, see the RELEASE control statement.
ON Control Statement
The ON control statement designates a series of statements to process when no database records or sort records are available for processing.
The ON control statement can be supplied only once for non-sort logic (no SORT control statement), presort logic (statements preceding the SORT control statement), and logic after the sort (statements following the SORT control statement). The END control statement terminates the series of statements designated by the ON control statement.
Syntax
ON ENDDATA  … END
Example
The ON control statement is used for various purposes, but it is especially convenient for printing final totals, as follows:
/DEFINE CNT BIN /PRINT ID 'SYSOUT ID /PRINT GEN ‘GEN’ /PRINT SEQ ‘SEQ’ /SET CNT=CNT+1 /ON ENDDATA /      PRINT 'TOTAL REPORTS =' SKIP(2) /      PRINT CNT /END
OUTPUT Control Statement
The OUTPUT control statement writes data to the output file.
Syntax
OUTPUT [
expression-1
] [COL(
expression
)] [SKIP]
where:
  • expression-1
    Specifies an expression that determines the data to be written to the output file.
  • COL(
    expression
    )
    Specifies an expression that determines the position to which expression-1 is written.
    A value of 1 represents the first position of the output record. If this value is less than the current column position, the current output record is written to the output file, and expression-1 is placed in the new output record.
  • SKIP
    Causes the current output record to be written to the output file.
    The data from each OUTPUT control statement is queued contiguously in the output record. The output record is written under the following conditions:
    • Statement processing has completed processing for a given database record, and the next OUTPUT control statement does not specify the COL operand.
    • The COL operand is specified with a value less than the current column position.
    • The output record size is exceeded.
    • OUTPUT directs the output record to be written (SKIP parameter).
Character, binary, packed, and time fields are written to the output record in its internal format and length. Date fields are written to the output record as a 4-byte Julian date in the form 0CYYDDDF. You can alter this circumstance using the EDIT function or by moving the data to a defined field.
Examples
To output tape dataset name, unit, and volume serial, use the following statements:
/OUTPUT TAPEDSN /OUTPUT TAPEUNIT /OUTPUT TAPEVOL
To output SYSOUT ID in column 1, archival date in YYYYMMDD format at column 40, and archival time in HHMMSS format at column 60, specify the following OUTPUT control statements:
/OUTPUT ID COL(1) /OUTPUT EDIT(ARCHDATE,’YYYYMMDD’) COL(40) /OUTPUT EDIT(ARCHTIME,’HHMMSS’) COL(60)