Previous Topic: Passing Program ControlNext Topic: Passing Control Laterally


Returning to a Higher-level Program

You can return control to a higher level within a task or to DC. If you return control to DC and specify the next task code to be invoked, the task ends and a pseudoconverse begins.

DC RETURN Statement

To return control to the next-higher level in a task, issue a DC RETURN statement, optionally specifying the next task code to be invoked on the terminal.

If the next-higher-level program specifies a next task code, it overrides any task code specified by the subordinate program. If the issuing program is the highest-level program, DC regains control.

Note: You can bypass intervening link levels and return control to DC by issuing a DC RETURN IMMEDIATE statement.

When the Next Task is Invoked

DC invokes the next task differently depending on how it is defined to the DC system:

Example of Return Specifying Next Task

The program excerpt below returns control to DC and specifies the next task code to be invoked on that terminal.

The first DC RETURN statement returns control to DC. The second DC RETURN statement also specifies that DEPTDISM is the next task invoked on that terminal.

 DATA DIVISION.
 WORKING-STORAGE SECTION.
 01  DEPTDISM                   PIC X(8)  VALUE 'DEPTDISM'.
 01  SOLICIT-REC.
     05  SOLICIT-DEPT-ID        PIC X(4).
 PROCEDURE DIVISION.
*** ESTABLISH ADDRESSABILITY TO THE MAP AND MAP RECORD ***
     BIND MAP SOLICIT.
     BIND MAP SOLICIT RECORD SOLICIT-REC.
*** CHECK THE AID BYTE ***
     INQUIRE MAP SOLICIT MOVE AID TO DC-AID-IND-V.
*** RETURN CONTROL TO CA IDMS/DC IF OPERATOR HAS PRESSED CLEAR ***
     IF CLEAR-HIT
             DC RETURN.
     MOVE ZERO TO SOLICIT-DEPT-ID.
*** TRANSMIT THE MAP TO THE TERMINAL SCREEN ***
     MAP OUT USING SOLICIT
        NEWPAGE
        MESSAGE IS INITIAL-MESSAGE LENGTH 80.
*** RETURN CONTROL TO CA IDMS/DC AND SPECIFY THE NEXT TASK ***
     DC RETURN
        NEXT TASK CODE DEPTDISM.