---
title: "CICS XCTL Sample Logic to Call the Remote Program"
description: "The below is the sample CICS program on how to use 'XCTL' to call sub program which is in the local system. Also you can read where XCTL and CALL can be used in CICS.  "
url: https://srinimf.com/2016/04/06/cics-sample-program-for-xctl/
date: 2016-04-06
modified: 2026-10-10
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2016/04/pexels-photo-6598873.jpeg?fit=1880%2C1253&ssl=1
categories: ["CICS"]
tags: ["CICS tips and Tricks", "CICS XCTL Sample Code"]
type: post
lang: en
---

# CICS XCTL Sample Logic to Call the Remote Program

The below is the sample CICS program on [how to use](https://srinimf.com/2016/04/06/cics-sample-program-for-link/) ‘XCTL’ to call [sub program](https://srinimf.com/2013/05/07/3-rules-calling-sub-programs-from-cics/) which is in the same logical level. [You can read where XCTL and CALL can be used in CICS](https://srinimf.com/2015/09/25/how-xctl-command-useful-in-mainframe-cics-programs/).

---

> In XCTL, you cannot expect control is returned

## **How to call Remote Sub-program**

The ‘LINK’ command can be used both the purposes of calling a sub program of lower logical level and sub program located in remote system.

Related[How to pass a Channel to Local or Remote System in CICS](https://srinimf.com/2015/11/06/how-to-pass-a-channel-to-local-or-remote-system-in-cics/)

In ‘LINK’ you can expect control is returned.

```
ID DIVISION.
PROGRAM-ID. HAS.
DATA DIVISION.
WORKING-STORAGE SECTION.
 77 TID PIC X(4).
 77 MSG PIC X(50) VALUE 'IMPORTANT OF LINK PROGRAM'.
 77 A PIC X(35) VALUE 'THIS IS MAIN PROGRAM'.
 77 B PIC X(35) VALUE 'NOW CONTROL MOVE TO SUB'.
PROCEDURE DIVISION.
 EXEC CICS 
 RECEIVE INTO (TID) 
 LENGTH(LENGTH OF TID) 
 END-EXEC.
 
 EXEC CICS 
 SEND FROM(MSG) 
 END-EXEC.
 
 EXEC CICS RECEIVE END-EXEC.
 EXEC CICS SEND FROM(A) ERASE END-EXEC.
 EXEC CICS RECEIVE END-EXEC.
 EXEC CICS SEND FROM(B) END-EXEC.
 EXEC CICS RECEIVE END-EXEC.
 
 EXEC CICS XCTL
 PROGRAM('SUB')
 END-EXEC.
 
 EXEC CICS 
 RETURN 
 END-EXEC.
```

**The sample LINK syntax**

```
LINK

>>-LINK--PROGRAM(name)------------------------------------------>

>--+-------------------------------------------------------------------------+-->
   +-COMMAREA(data-area)--+--------------------+--+------------------------+-+   
   |                      '-LENGTH(data-value)-'  '-DATALENGTH(data-value)-' |   
   '-CHANNEL(name)-----------------------------------------------------------'   

>--+------------------------------------------------------------+-><
   +-INPUTMSG(data-area)--+-------------------------+-----------+   
   |                      '-INPUTMSGLEN(data-value)-'           |   
   '-+-------------------+--+--------------+--+---------------+-'   
     '-SYSID(systemname)-'  '-SYNCONRETURN-'  '-TRANSID(name)-'
```

Related Posts

- [The Real Use of ‘XCTL’ command in CICS](https://srinimf.com/2015/09/25/how-xctl-command-useful-in-mainframe-cics-programs/)DateSeptember 25, 2015
- [How to write Menu Driven CICS programs](https://srinimf.com/2016/04/06/cics-menu-driven-programs/)DateApril 6, 2016
- [XCTL, LINK, RETURN in CICS: Here are Top Differences](https://srinimf.com/2015/08/05/cics-how-xctllink-and-return-controls-execution-of-programs/)DateAugust 5, 2015

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2016%2F04%2F06%2Fcics-sample-program-for-xctl%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2016%2F04%2Fpexels-photo-6598873.jpeg%3Ffit%3D1200%252C800%26ssl%3D1&description=CICS%20XCTL%20Sample%20Logic%20to%20Call%20the%20Remote%20Program)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2016/04/06/cics-sample-program-for-xctl/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2016/04/06/cics-sample-program-for-xctl/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2016/04/06/cics-sample-program-for-xctl/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2016/04/06/cics-sample-program-for-xctl/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20CICS%20XCTL%20Sample%20Logic%20to%20Call%20the%20Remote%20Program&body=https%3A%2F%2Fsrinimf.com%2F2016%2F04%2F06%2Fcics-sample-program-for-xctl%2F&share=email)
-

### Like this:

Like Loading…
