CALL PROGRAM Statement COBOL

The CALL PROGRAM statement transfers control from the current program to another program, with implicit termination of the current program and no expectation of return.

CALL PROGRAM Statement

literal-1 must be a nonnumeric literal.

identifier-1 must be defined as an alphanumeric data item such that its value can be a program-name.

If the program specified by literal-1 or by the current value of the data item identified by identifier-1 can be found and loaded, the USING operands, if any, are copied to a save area in memory, the current run unit is canceled, and control is transferred to the specified program, passing the saved USING operands as parameters.

Cancellation of the run unit in which the CALL PROGRAM statement is executed includes closing any files that are in an open mode and the release of all external objects.

The specified program is entered as the main program of a completely new run unit in the same way as a program started from the command line, except that the argument list to this program is not restricted in the same way.The main program of a run unit started with the CALL PROGRAM statement may receive all the arguments passed by that CALL PROGRAM statement.

The specified program is not under the control of a calling program.There is no provision for return of control from the specified program to the program in which the CALL PROGRAM statement is executed.If the specified program executes an EXIT PROGRAM statement, execution of the program continues with the next executable statement.

If the program referred to by literal-1 or by the current value of the data item identified by identifier-1 cannot be found or loaded, the exception condition is raised and control remains in the current program.

If the exception condition is raised and there is an ON EXCEPTION phrase, control is transferred to imperative-statement-1 and execution continues according to the rules for each statement specified in mperative-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 execution of imperative-statement-1, control is transferred to the end of the CALL PROGRAM statement.

The reason for the exception condition can be determined by executing an ACCEPT . . . FROM EXCEPTION STATUS statement. If the exception condition is raised and there is no ON EXCEPTION phrase, the exception condition is ignored.

Selection of the program to be activated by a CALL PROGRAM statement is done using the same rules as are used for that purpose by the CALL statement.

The USING phrase is subject to the same conditions and has the same purpose and effect as described previously for the CALL statement.

CALL PROGRAM Statement Examples


Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

COBOL Topics