This routine is used to define a COBOL subsystem, which allows cancelling of all COBOL programs in the subsystem with a single statement.


This library routine takes two parameters. The first parameter is an opcode, and the second parameter depends on the opcode used:

CALL "CBL_SUBSYSTEM" using op-code, parameter GIVING status-code


op-code (pic x comp-x) This contains one of the following values:
  • 0 - declare subsystem
  • 1 - cancel subsystem
  • 2 - remove subsystem

When op-code = 0, "parameter" is a group item that looks like:

  ss-handle    pic x(2) comp-x.
  ss-name-len  pic x(2) comp-x.
  ss-name    pic x(n).

When op-code = 1, "parameter" is:

  ss-handle    pic x(2) comp-x.

When op-code = 2, "parameter" is ignored.

On entry:

op-code has the value of the operation to perform, 0, 1, or 2.

When op-code = 0, ss-name-len holds the length of the subsystem program-name field. ss-name holds the subsystem program-name. This must be a COBOL program.

When op-code = 0, ss-handle holds the subsystem handle returned by a function 0 call.

On exit:

When op-code = 0, ss-handle holds the subsystem handle value.


  1. A subsystem is defined as a specified program in an application, plus any subprograms subsequently called by programs already in the subsystem that do not already belong to any other subsystems.
  2. opcode 0 declares a subsystem. The routine returns a subsystem handle in ss-handle. The next time the program named is called in an initial state, it becomes part of the subsystem. Any subprograms it calls also become part of the subsystem, unless they are not in an initial state.
  3. A program belonging to a subsystem is cancelled only under the following circumstances: it is the object of a CANCEL verb, the program cancels the entire subsystem using opcode 1, or the application executes a STOP RUN or CHAIN statement.
  4. opcode 1 cancels all programs in the specified subsystem. If any program in the subsystem is still active, that program is released from the subsystem and is not cancelled.
  5. opcode 2 removes the program that called it from any subsystem the program is in. To ensure a program is never included in any subsystem, call this function at the start of each entry into the program.