To pass control to another program at the same level not expecting the control to be returned.
When one program XCTLs to another, i.e.., transfers control, the first program is considered terminated, and the second program operates at the same level as the first program.
The above diagram explains the process of Calling a XCTL’ed program from Main program – Same Logical Level.
When the execution of the second program ends the control is returned not to the first program, but to a program which is at a higher logical level or to CICS, if the first program was invoked directly under CICS.
EXEC CICS XCTL PROGRAM(name) COMMAREA(ws-area) LENGTH(ws-length) END-EXEC. |
Name of the program to which we wish to transfer control. If the name is a literal, it should be enclosed in quotes. Program name can be eight characters long and should be defined in PPT.
An optional parameter. When specified, it is the name of the area containing the data to be passed. This option is required only if you want to pass information to XCTLed to program.
Specifies the length of the commarea. This parameter is required only COMMAREA is present. Like the length parameters in other commands it must be half word binary.
Ws-length is length of ws-area and ws-area has the information that needs to be passed to XCTL program.
Data from the XCTLing program to XCTLed program can be passed using the COMMAREA option.
If the COMMAREA is used in the program which is performing the XCTL, the area must be defined in the working storage section. In the called program the area must be defined as the first area in the LINKAGE SECTION, using the DFHCOMMAREA. Only a copy of the data is passed and not the address.
This diagram explains the internal process of calling a XCTL’ed program from Main program.
Both the XCTLing and the XCTLed programs execute under the same task.
The below example shows how to use XCTL command to pass the control to another program.
IDENTIFICATION DIVISION. PROGRAM-ID. IBMMF. WORKING-STORAGE SECTION. 01 WS-COMMAREA PIC X(70). PROCEDURE DIVISION. EXEC CICS XCTL PROGRAM('PROGRAM1') COMMAREA(WS-COMMAREA) LENGTH(70) END-EXEC. |
This above XCTL command transfers the control to be passed to program 'PROGRAM1' with 70 bytes of data. COMMAREA is an optional parameter and is the name of the area containing the data to be passed or the area to which results are to be returned.
XCTL | LINK |
---|---|
XCTL does not expect control back | LINK expects control back |
Handle conditions in the main program are not available to the called program. Establish new handle conditions | Handle conditions in the calling program are needed again. Hence use PUSH and POP commands to restore them again |
XCTL does not expect control back and hence less overhead on system resources like memory etc. | LINK expects control back and hence the overhead is more in this case on memory etc. |
Similar to GO TO | Similar to PERFORM, and control will be passed back to the instruction following this |
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!