Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 8: CICS Program and Data Passing


XCTL

What the XCTL command does

  • XCTL transfers control from one program to another program.
  • The new program runs at the SAME logical level as the current program.
  • Control does NOT come back. The current program ends when XCTL runs.
  • Think of it as a one-way transfer. The old program is finished.
  • Data is passed with the COMMAREA or CHANNEL option, just like LINK.
  • When the new program issues RETURN, control goes to the program at the next higher logical level.

When to use XCTL

  • Use XCTL for error handling. When a serious error occurs, XCTL to an error program that displays a message and ends the task.
  • Use XCTL to chain programs that each handle one step of a job, where no step needs to return.
  • Use XCTL at the end of a program to pass control to the next program instead of nesting LINKs.
  • Do not use XCTL when you need control back. Use LINK for that.
  • Example of XCTL to an error handling program:-
    MOVE EIBRESP TO ERR-RESP. MOVE EIBRESP2 TO ERR-RESP2. MOVE EIBTRNID TO ERR-TRNID. MOVE EIBRSRCE TO ERR-RSRCE. EXEC CICS XCTL PROGRAM('SYSERR') COMMAREA(ERROR-PARAMETERS) END-EXEC.

XCTL and logical levels

  • LINK moves control down one logical level. XCTL stays on the same level.
  • Because XCTL does not add a level, chaining many programs with XCTL uses less storage than nesting LINKs.
  • A program reached by XCTL that issues RETURN returns to the program one level above, not to the XCTL issuer.
  • This is why XCTL is a clean way to end error processing. The error program RETURNs and the whole task ends.





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant