Module 8: CICS Program and Data Passing
LINK vs XCTL
LINK vs XCTL at a glance
- Both LINK and XCTL transfer control to another CICS program.
- LINK expects control back. The called program runs at the next lower logical level and RETURNs to the caller.
- XCTL does not expect control back. The new program runs at the same logical level and the old program ends.
- LINK is like a subroutine call. XCTL is like a one-way jump.
- Both can pass data with COMMAREA or CHANNEL.
When to use LINK
- Use LINK when the calling program must continue after the called program finishes.
- Typical use: a main program LINKs to a validation routine, then continues with the next step.
- LINK is the right choice for reusable subprograms that serve many callers.
- Example:-* LINK - PROGA continues after PROGB returns EXEC CICS LINK PROGRAM('PROGB') COMMAREA(WS-AREA) LENGTH(100) END-EXEC. * control comes back here when PROGB issues RETURN
When to use XCTL
- Use XCTL when the current program is finished and another program takes over.
- Typical use: error handling. On a serious error, XCTL to an error program that shows a message and ends the task.
- Use XCTL to chain programs step by step without building up logical levels.
- Example:-* XCTL - control never comes back to PROGA EXEC CICS XCTL PROGRAM('PROGC') COMMAREA(WS-AREA) LENGTH(100) END-EXEC. * no code here will ever run after a successful XCTL
