COBOL/400 Language Help

Format 2 (CALL ON EXCEPTION)

Description
The program containing the CALL statement is the calling program; the program identified in the CALL statement is the called subprogram.
Format 2 (CALL ON EXCEPTION)
 
->->--CALL--*--identifier-1--*---------------------------------------->
          *--literal-1-----*
 
->--*-------------------------------------------------------------*-->
   +        *---------------------------------------------------*+
   +        +                     *---------------------------* ++
   +        V                     V                           + ++
   *-USING--*-*------------------**-------------*-identifier-2*-**
            + *-*----*-REFERENCE-**-ADDRESS OF--*             + +
            +   *-BY-*            *-file-name-1---------------* +
            +                                                   +
            +                *---------------------------------*+
            +                V                                 ++
            *-*----*-CONTENT-*-*------------*-----identifier-2-**
              *-BY-*         + *-ADDRESS OF-*                  +
                             + *-LENGTH OF--*                  +
                             *-*-literal-2---*-----------------*
                               *-file-name-1-*
 
 
->--*-------------------------------------------*------------------->
   *-*----*--EXCEPTION imperative-statement-1--*
     *-ON-*
->--*------------------------------------------------*-------------->
   *--NOT-*----*--EXCEPTION imperative-statement-2--*
          *-ON-*
 
->--*------------*--------------------------------------------------><-
   *--END-CALL--*

EXCEPTION imperative-statement-1

An exception condition occurs when the called subprogram cannot be made available. This occurs in one of two ways:

  1. If you specify the ON EXCEPTION phrase in the CALL statement, control is transferred to imperative-statement-1. Execution then continues according to the rules for each statement specified in imperative-statement-1.

    If a procedure branching or conditional statement that causes explicit transfer of control is executed, control is transferred in accordance with the rules for that statement. Otherwise, upon completion of the execution of imperative-statement-1, control is transferred to the end of the CALL statement and the NOT ON EXCEPTION phrase, if specified, is ignored.

  2. If the ON EXCEPTION phrase is not specified in the CALL statement, the NOT ON EXCEPTION phrase, if specified, is ignored.

EXCEPTION imperative-statement-2 or NOT

If you specify the NOT ON EXCEPTION phrase in the CALL statement and the called subprogram can be made available (that is, no exception condition exists), control is transferred to the called subprogram. After control returns from the called subprogram, the ON EXCEPTION phrase, if specified, is ignored and control is transferred to the end of the CALL statement or, if the NOT ON EXCEPTION phrase is specified, to imperative-statement-2.

If control is transferred to imperative-statement-2, execution continues according to the rules for each statement specified in imperative-statement-2.

If a procedure branching or conditional statement that causes explicit transfer of control is executed, control is transferred in accordance with the rules for that statement. Otherwise, upon completion of the execution of imperative-statement-2, control is transferred to the end of the CALL statement.

If you specify this phrase and the ON OVERFLOW phrase, an error occurs.


[ Top of Page | Previous Page | Next Page | Table of Contents ]