Rational Developer for System z
Enterprise COBOL for z/OS, Version 4.1, Language Reference


START statement

The START statement provides a means of positioning within an indexed or relative file for subsequent sequential record retrieval.

When the START statement is executed, the associated indexed or relative file must be open in either INPUT or I-O mode.

Read syntax diagramSkip visual syntax diagram
Format

>>-START--file-name-1------------------------------------------->

>--+-------------------------------------------------------------------+-->
   '-KEY--+----+--+-EQUAL--+----+-----------------------+--data-name-1-'   
          '-IS-'  |        '-TO-'                       |                  
                  +-=-----------------------------------+                  
                  +-GREATER--+------+-------------------+                  
                  |          '-THAN-'                   |                  
                  +->-----------------------------------+                  
                  +-NOT LESS--+------+------------------+                  
                  |           '-THAN-'                  |                  
                  +-NOT <-------------------------------+                  
                  +-GREATER--+------+--OR EQUAL--+----+-+                  
                  |          '-THAN-'            '-TO-' |                  
                  '->=----------------------------------'                  

>--+------------------------------------------+----------------->
   '-INVALID--+-----+--imperative-statement-1-'   
              '-KEY-'                             

>--+----------------------------------------------+------------->
   '-NOT INVALID--+-----+--imperative-statement-2-'   
                  '-KEY-'                             

>--+-----------+-----------------------------------------------><
   '-END-START-'   

file-name-1
Must name a file with sequential or dynamic access. file-name-1 must be defined in an FD entry in the data division and must not name a sort file.

KEY phrase

When the KEY phrase is specified, the file position indicator is positioned at the logical record in the file whose key field satisfies the comparison.

When the KEY phrase is not specified, KEY IS EQUAL (to the prime record key) is implied.

data-name-1
Can be qualified; it cannot be subscripted.

When the START statement is executed, a comparison is made between the current value in the key data-name and the corresponding key field in the file's index.

If the FILE STATUS clause is specified in the file-control entry, the associated file status key is updated when the START statement is executed (See File status key).

INVALID KEY phrases

If the comparison is not satisfied by any record in the file, an invalid key condition exists; the position of the file position indicator is undefined, and (if specified) the INVALID KEY imperative-statement is executed. (See INTO and FROM phrases under "Common processing facilities".)

Both the INVALID KEY phrase and an applicable EXCEPTION/ERROR procedure can be omitted.

END-START phrase

This explicit scope terminator serves to delimit the scope of the START statement. END-START permits a conditional START statement to be nested in another conditional statement. END-START can also be used with an imperative START statement.

For more information, see Delimited scope statements.

Indexed files

When the KEY phrase is specified, the key data item used for the comparison is data-name-1.

When the KEY phrase is not specified, the key data item used for the EQUAL TO comparison is the prime RECORD KEY.

When START statement execution is successful, the RECORD KEY or ALTERNATE RECORD KEY with which data-name-1 is associated becomes the key of reference for subsequent READ statements.

data-name-1
Can be any of the following:
  • The prime RECORD KEY.
  • Any ALTERNATE RECORD KEY.
  • A data item within a record description for a file whose leftmost character position corresponds to the leftmost character position of that record key; it can be qualified. The size of the data item must be less than or equal to the length of the record key for the file.

Regardless of its category, data-name-1 is treated as an alphanumeric item for purposes of the comparison operation.

The file position indicator points to the first record in the file whose key field satisfies the comparison. If the operands in the comparison are of unequal lengths, the comparison proceeds as if the longer field were truncated on the right to the length of the shorter field. All other numeric and alphanumeric comparison rules apply, except that the PROGRAM COLLATING SEQUENCE clause, if specified, has no effect.

When START statement execution is successful, the RECORD KEY with which data-name-1 is associated becomes the key of reference for subsequent READ statements.

When START statement execution is unsuccessful, the key of reference is undefined.

Relative files

When the KEY phrase is specified, data-name-1 must specify the RELATIVE KEY.

Whether or not the KEY phrase is specified, the key data item used in the comparison is the RELATIVE KEY data item. Numeric comparison rules apply.

The file position indicator points to the logical record in the file whose key satisfies the specified comparison.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)