COBOL – How to Use ‘ CANCEL’

COBOL-85 Features

Global: This is the term used in Nested programs. If declare as global, it applies to all nested programs.

https://srinimf.com/2012/03/18/cobol-global-initial-externalcommon/

External: If declare any variable as external, it can be referenced by including program(outer) in nested programs.

https://srinimf.com/2021/09/09/external-global-value-can-we-use-these-in-cobol-linkage/

PROGRAM-ID. pgm1    IS COMMAN  PROGRAM.

This is an extention in cob-85 for nested programs. The program defined as ‘common’ can be called by any program  in run unit(nested programs).

Initial:

PROGRAM-ID. pgm1   IS INITIAL.

If we declare as “initial”, this will be available as initial state whenever it is called.

CALL 'pgm2' USING J 
END-CALL.

To Cancel “initial” state:

The program which is defined as Initial, get cancel implicitly without END-CALL.

To Cancel “Common: state:

The program which is defined as “common”, to get cancel its common state, need to mention END-CALL.