XCTL
XCTL
The XCTL (Transfer Control) command is used to transfer control permanently from one program to another. Unlike the LINK command, XCTL does not return control to the calling program.
The CICS XCTL command is useful when:
- The current program does not need to resume after calling another program.
- You want to replace the currently running program with a new program.
- Reducing memory usage by freeing resources used by the calling program.
Syntax -
EXEC CICS XCTL
PROGRAM(program-name)
[COMMAREA(data-area) LENGTH(data-area-length)]
[CHANNEL (name)]
[INPUTMSG(data-area)]
[INPUTMSGLEN(data-value)]
[RESP(response-field)]
[RESP2(response-field2)]
END-EXEC.
- PROGRAM(program-name) - Specifies the name of the CICS program to be called.
- COMMAREA(data-area) - Specifies a communication area available to the next program that receives control. The valid range for the COMMAREA length is 0 through 32767 bytes. If the length provided is outside range, the LENGERR condition occurs.
- LENGTH(data-area-length) - Specifies the length of the COMMAREA in bytes. If any negative value provided, ZERO assumed as length.
- CHANNEL (name) - Specifies the channel name (1–16 characters) to be available to the next program that receives control.
- INPUTMSG(data-area) - Specifies the data to pass to the transaction in the TRANSID option or call a program in a multi-region environment.
- INPUTMSGLEN(data-value) - Specifies the length of the INPUTMSG. (Declaration: PIC S9(4) USAGE BINARY).
- RESP(response-variable) - Optional. It captures the response code of the RECEIVE MAP operation and used to check if the command executed successfully or encountered an error.
- RESP2(response2-variable) - Optional. It captures the response2 code of the RECEIVE MAP operation when the error occured.
Short Examples -
Scenario - Using XCTL in a CICS COBOL Program.
Main Program (CALLER-PROG)
IDENTIFICATION DIVISION.
PROGRAM-ID. CALNPROG.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-COMMAREA PIC X(100).
PROCEDURE DIVISION.
...
EXEC CICS XCTL
PROGRAM('SUBPROG')
COMMAREA(WS-COMMAREA)
LENGTH(50)
RESP(WS-RESP-CODE)
END-EXEC.
IF WS-RESP-CODE = 0 THEN
MOVE "Returned from SUBPROG successfully" TO MSG1O
ELSE
STRING "Error in LINK command, Code: "
DELIMITED BY SIZE
WS-RESP-CODE
DELIMITED BY SIZE
INTO MSG1O
END-IF.
...
Called Subprogram (SUBPROG)
IDENTIFICATION DIVISION.
PROGRAM-ID. SUBPROG.
LINKAGE SECTION.
01 DFHCOMMAREA PIC X(100).
PROCEDURE DIVISION.
MOVE DFHCOMMAREA TO WS-COMMAREA.
...
Error Conditions -
Eror Condition | RESP | RESP2 | Reason |
---|---|---|---|
INVREQ | 16 | 8 | A XCTL command with the INPUTMSG option is issued for a program that is not associated with a terminal, or that is associated with an APPC logical unit, or an IRC session. |
16 | 29 | EXEC XCTL is not allowed in a GLUE or TRUE. | |
16 | 30 | The program manager domain has not yet been initialized because an XCTL request was made in a first stage PLT. | |
16 | 31 | An XCTL command is issued from a program that is an application entry point. | |
16 | 200 | An XCTL command with the INPUTMSG option is issued in a program invoked by DPL. | |
LENGERR | 22 | 11 | The COMMAREA length is less than 0 or greater than the permitted length. |
22 | 26 | The COMMAREA address is zero, but the COMMAREA length is nonzero. | |
22 | 27 | The INPUTMSG length is less than 0 or greater than 32767. | |
22 | 28 | LENGTH or INPUTMSGLEN is greater than the length of the data area specified in the COMMAREA or INPUTMSG options. | |
PGMIDERR | 27 | 1 | A program has no installed resource definition and either program auto install was switched off or the program auto install control program indicated that the program should not be auto installed. |
27 | 2 | A program is disabled. | |
27 | 3 | A program was not loaded because the load not found or load new copy not issued. | |
27 | 9 | The installed program definition is for a remote program. | |
27 | 21 | The program auto install control program failed. Program auto install is disabled and message DFHPG0202 or DFHPG0203 is written to the CSPL. | |
27 | 22 | The model returned by the program auto install control program was not defined to CICS or was not enabled. | |
27 | 23 | The program auto install control program returned invalid data. | |
27 | 24 | The defined program failed because auto install returned an invalid program name or definition. | |
NOTAUTH | 70 | 101 | A resource security check has failed on PROGRAM(name). |
CHANNELERR | 122 | 1 | The channel name contains illegal character or combination of illegal characters. |