Previous Topic: SyntaxNext Topic: SYNCKEY


Parameters

STOP supports the following parameter values:

CLOSE

This parameter value closes the INFILE when the STOP keyword is processed. This is the default value, but it may have been changed by updating the &BAT_CLOSEIN installation option.

Note: If the INFILE keyword is present, and CLOSE/NOCLOSE is not specified with the STOP keyword, STOP sets its CLOSE/NOCLOSE option to that of the INFILE.

NOCLOSE

This parameter value does not close the INFILE when the STOP keyword is processed. However, all data sets are closed before executing subsequent job steps.

When the NOCLOSE parameter is used, the current job step's subsequent command begins processing with the record that matched the STOP selection criteria.

Example 1

This example stops command processing when invalid packed data is found in the CUST-BALANCE field. Once detected, the record is printed using the layout file referenced by ddname LAYOUT, the condition code is set to 8, and the command stops. The record on which the invalid packed data was found is available to any subsequent commands within the particular job step.

PRINT,
  LAYOUTFILE(LAYOUT),
  FORMAT(S),  
  SELRECIF(CUST-BALANCE,NEP),
     SETRC(8),
	STOP(NOCLOSE)

Example 2

In this example when a C'400' is found for field CUST-REWARD-LEVEL, the record is written to the file referenced by the ddname REC400, and the READ command is immediately terminated. For all other records that do not meet this selection, they are written to the file referenced by ddname OLDRECS. (Usually the action previous to an IF statement ends the previous IF's actions, in this case WRITE(OLDRECS). However, when STOP is used, it ends the subordinate actions to the previous IF/AND/OR.) Any records with a CUST-REWARD-LEVEL of C'500' are written to the file referenced to by REC500.

READ,
  MOVE(CLEAR),
  MOVE(1,0,1),
  IF(CUST-REWARD-LEVEL,EQ,C'400'),
	WRITE(REC400),
	STOP,
  WRITE(OLDRECS),
  IF(CUST-REWARD-LEVEL,EQ,C'500),
	WRITE(REC500)
     

Example 3

In this example the first 500 records from INFILE are read. If no records match the IF selection criteria, CUST-REWARD-LEVEL field value of C'400', the INFILE is closed and the COPY processing starts with the first record from the INFILE. If however, there is a record that matches the IF selection criteria, before the INLIM value is reached, the command terminates and the INFILE is not closed. The record that matched the IF selection criteria, as well as subsequent record, are made available to the COPY command.

READ,
  INLIM(500),
  INFILE(,CLOSE),
  IF(CUST-REWARD-LEVEL,EQ,C'400'),
	STOP(NOCLOSE)
COPY