Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

IBM CICS Transaction Gateway Connector

Premium

The IBM CICS Transaction Gateway (IBM CTG) connector provides integration with back-end CICS applications using the CICS Transaction Gateway. For Java platforms, CTG implements the JCA resource adapter to connect Java applications to the CICS system.

The connector serves as a link between Mule applications and the CTG.

Prerequisites

This document assumes that you are familiar with IBM CTG, Mule, Anypoint Connectors, Anypoint Studio, Mule concepts, elements in a Mule flow, and Global Elements.

You need login credentials to test your connection to your target resource.

For hardware and software requirements and compatibility information, see the Connector Release Notes.

To use this connector with Maven, view the pom.xml dependency information in the Dependency Snippets in Anypoint Exchange.

Important Concepts

  • CICS (Customer Information Control System): Set of enterprise application servers with support for high-transaction workloads in a secure, scalable, cost efficient environment. CICS applications are written in a variety of languages, from Java to COBOL.

  • CICS Region: Named collection of resources that are controlled by CICS as a unit. A CICS resource is any facility or component of a CICS system that is required to perform a task.

  • CICS TG (CICS Transaction Gateway): Set of client and server software components that allow a remote client application to invoke services in a CICS region. The client application can be either a Java application or a non-Java application. The CICS TG is available through the following two products: CICS TG on z/OS and CICS TG for Multiplatforms.

  • COMMAREA: Block of contiguous memory used to pass data between programs. It is the binary equivalent of a COBOL structure and it is character-based.

  • ECI (External Call Interface): Simple remote procedural call style interface, used for linking to CICS applications. The COMMAREA or channel is the data interface used for the exchange of data between the client application and the CICS.

  • JCA: Standard architecture for connecting the J2EE platform to heterogeneous Enterprise Information Systems (EIS), such as CICS. The JCA enables an EIS vendor to provide a standard resource adapter for its EIS. A resource adapter is the middle tier between a Java application and an EIS and connects the Java application to the EIS.

What is New in this Connector

Support for Mule4 has been added.

To Connect in Design Center

  1. In Design Center, click Set Up > Upload, browse for and select the driver for this connector on your file system, and upload it. Alternatively, search for and select a driver that is already uploaded.

  2. Click a trigger. You can create a global element by selecting this connector as their trigger. If a global element is not needed, you can use an HTTP Listener or Scheduler trigger.

    Trigger options

  3. To create an HTTP global element for the connector, set these fields:

    HTTP Listener configuration

    Field Description

    Protocol

    Protocol selected for the HTTP endpoint, it can be HTTP or HTTPS (secure).

    Host

    IP address where your Mule application listens for requests.

    Port

    Port address where your Mule application listens for requests.

    Base

    Path where your Mule application listens for requests.

  4. Select the plus sign to add a component.

    add connector

  5. Select the connector as a component.

  6. Select the operation.

    config connector

    Name Description

    Execute

    Invokes a CICS program with data encapsulated as channels and containers.

    Execute using COMMAREA

    Invokes a CICS program with data encapsulated as a COMMAREA. Requests are limited to a maximum of 32 KB.

  7. Configure the Global element for the connector:

    config connector

    Field Description

    Host

    Enter the host name of the CICS TG.

    Port

    Enter the port on which the CICS TG is running. Default value is 2006.

    Server Name

    Enter the name of the target CICS server as defined in the CICS TG configuration file. Optional.

    Username

    Enter the CICS user ID. Optional, if security is NOT enabled in the CICS region.

    Password

    Enter the password for the CICS user ID. Optional, if security is NOT enabled in the CICS region.

  8. Go to add dependencies.

    dependency connector

    dependency connector

    Field Description

    Required Dependencies

    • ccf2.jar (CICS Common Connector Framework)

    • cicsjee.jar (CICS JEE)

    • ctgclient.jar (CTG Client Library)

    • ctgserver.jar (CTG Server Library)

    • geronimo-j2ee-connector_1.6_spec-1.0.jar

      Note: It is advisable to use the JAR files that come bundled within the installation of the CTG server instead of downloading the SDK ZIP from IBM’s website to ensure the compatibility between the connector and the CTG system.

  9. Go to Advanced Settings Tab and complete the configuration.

    config connector

    Field Description

    Connection Timeout

    Enter the socket timeout for the client to CTG. Default value is 0 (no timeout).

    Keystore Location

    Enter the location of the keystore containing the certificates required for an SSL client. Optional.

    Keystore Password

    Enter the password required to access the keystore for an SSL client. Optional.

    CTG Trace

    If checked, all debug levels of CTG tracing are turned on. Default value is false.

Connect in Anypoint Studio 7

You can use this connector in Anypoint Studio by adding it as a dependency in your Mule application.

To Install this Connector

  1. In Anypoint Studio, click the Exchange icon in the Studio taskbar.

  2. Click Login in Anypoint Exchange.

  3. Search for the connector and click Install.

  4. Follow the prompts to install the connector.

When Studio has an update, a message displays in the lower right corner, which you can click to install the update.

How to Configure

  1. Drag and drop the connector to the Studio Canvas.

  2. Configure the Global element for the connector.

    config connector

    Field Description

    Host

    Enter the host name of the CICS TG.

    Port

    Enter the port on which the CICS TG is running. Default value is 2006.

    Server Name

    Enter the name of the target CICS server as defined in the CICS TG configuration file. Optional.

    Username

    Enter the CICS user ID. Optional, if security is NOT enabled in the CICS region.

    Password

    Enter the password for the CICS user ID. Optional, if security is not enabled in the CICS region.

    Required Dependencies

    • ccf2.jar (CICS Common Connector Framework)

    • cicsjee.jar (CICS JEE)

    • ctgclient.jar (CTG Client Library)

    • ctgserver.jar (CTG Server Library)

    • geronimo-j2ee-connector_1.6_spec-1.0.jar

      Note: It is advisable to use the JAR files that come bundled within the installation of the CTG server instead of downloading the SDK ZIP from IBM’s website to ensure the compatibility between the connector and the CTG system.

  3. To add the dependencies select Add dependency and complete the fields.

    dependecy connector

  4. Go to Advanced Settings Tab and complete the configuration.

    config connector

    Field Description

    Connection Timeout

    Enter the socket timeout for the client to CTG. Default value is 0 (no timeout).

    Keystore Location

    Enter the location of the keystore containing the certificates required for an SSL client. Optional.

    Keystore Password

    Enter the password required to access the keystore for an SSL client. Optional.

    CTG Trace

    If checked, all debug levels of CTG tracing are turned on. Default value is false.

  5. Choose the operation.

    operations connector

    The IBM CTG connector supports the following two outbound operations:

    Name Description

    Execute

    Invokes a CICS program with data encapsulated as channels and containers.

    Execute using COMMAREA

    Invokes a CICS program with data encapsulated as a COMMAREA. Requests are limited to a maximum of 32 KB.

Common Use Cases

  • Invoke a COMMAREA Program

  • Invoke a Channel Program

  • Invoke a COMMAREA or Channel Program inside a Transactional Scope

  • Add Custom Metadata

Note: For a successful run of use cases 1 to 3, the CICS programs invoked must to be available on the target CICS system.

Invoke a COMMAREA Program

This application calls EC01, a COMMAREA-based program that outputs the current datetime in a formatted EBCDIC string.

CTG COMMAREA flow

  1. Create a new Mule Project in Anypoint Studio and fill in the IBM CTG credentials in src/main/resources/mule-app.properties.

    
                 
              
    1
    2
    3
    4
    5
    
    ctg.host=<HOST>
    ctg.port=<PORT>
    ctg.serverName=<SERVER_NAME>
    ctg.username=<USERNAME>
    ctg.password=<PASSWORD>
  2. Drag an HTTP connector onto the canvas and leave the default values for Host and Port and set the path to /test/ec01.

  3. Drag an IBM CTG component onto the canvas and add a new Global Element to configure a standard (non-SSL) client.

    Parameter Value

    Host

    ${ctg.host}

    Port

    ${ctg.port}

    Server Name

    ${ctg.serverName}

    Username

    ${ctg.username}

    Password

    ${ctg.password}

    Note: Click the Test Connection option to confirm that Mule can connect with the IBM CTG instance. If the client is successful, click OK to save the configuration. Otherwise, review or correct any invalid parameters and test again.

  4. Double-click the IBM CTG component, select the operation Execute and configure the following parameters:

    Parameter Value

    Content Reference

    #[payload]

    Request Reference

    #[flowVars.commareaRequest]

  5. Add a Transform Message between the HTTP and the IBM CTG components. The connector does not provide dynamic/static metadata but allows users to define custom types using the Metadata Type tool.

    1. Define the input metadata according to section Add Custom Metadata using the schema file ec01-type.ffd:

      
                      
                   
      1
      2
      3
      4
      5
      6
      7
      
      form: COPYBOOK
      id: 'DFHCOMMAREA'
      values:
      - { name: 'LK-DATE-OUT', type: String, length: 8 }
      - { name: 'LK-SPACE-OUT', type: String, length: 1 }
      - { name: 'LK-TIME-OUT', type: String, length: 8 }
      - { name: 'LK-LOWVAL-OUT', type: String, length: 1 }
    2. Map the fields in the DataWeave transformer.

      
                      
                   
      1
      2
      3
      4
      5
      6
      7
      8
      9
      
      %dw 2.0
      output text/plain schemaPath = "ec01-type.ffd", segmentIdent = "DFHCOMMAREA"
      ---
      [{
          LK-DATE-OUT: "",
          LK-SPACE-OUT: "",
          LK-TIME-OUT: "",
          LK-LOWVAL-OUT: ""
      }]
    3. Create a flowVar named commareaRequest and configure the following fields (see section Load Java Metadata):

      
                      
                   
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      
      %dw 2.0
      output application/java
      ---
      
      {
              channel: "EC03",
              encoding: "US-ASCII",
              errorContainer: "OUTPUTMESSAGE",
              programName: "EC03",
              requestContainer: "INPUTDATA",
              responseContainer: "CICSDATETIME",
              tpnName: "CSMI"
      } as Object {
              class : "org.mule.modules.ibmctg.internal.model.ChannelRequest"
      }

      See section Load Java Metadata to obtain metadata for the CommareaRequest.

  6. Add a Transform Message after the IBM CTG to extract the results in a JSON format.

    
                 
              
    1
    2
    3
    4
    5
    6
    
    %dw 2.0
    output application/json
    ---
    {
            date: payload
    }
  7. Add a Logger at the end of the flow.

  8. Save the changes and deploy the Mule Application. Open a browser and make a request to http://localhost:8081/ec01. The result should be similar to:

    
                 
              
    1
    2
    3
    
    {
        date: "08/01/18 13:41:17"
    }

Invoke a Channel Program

This application calls EC03, a channel-based program that takes an input data container and returns three containers:

  • A data/time container.

  • The length of the input data and returns uses channels and containers in a CICS program.

  • An output container that contains a copy of the input data, or an error message.

Channel Program

  1. Perform steps 1 to 3 from the previous example and set the HTTP path to /ec03.

  2. Double-click the IBM CTG component, select the operation Execute and configure the following parameters:

    Parameter Value

    Content Reference

    #[payload]

    Request Reference

    #[flowVars.request]

  3. Add a Transform Message between the HTTP and the IBM CTG components.

  4. Define the input metadata according to section Add Custom Metadata using the schema file ec03-type.ffd:

    
                 
              
    1
    2
    3
    4
    
    form: COPYBOOK
    id: 'DFHCOMMAREA'
    values:
    - { name: 'CICS-DATE-TM', type: String, length: 8 }
  5. Map the fields in the DataWeave transformer.

    
                 
              
    1
    2
    3
    4
    5
    6
    
    %dw 2.0
    output text/plain schemaPath = "ec03-type.ffd", segmentIdent = "DFHCOMMAREA"
    ---
    [{
            CICS-DATE-TM: ""
    }]
  6. Create a flowVar named request and configure the following fields (see section Load Java Metadata):

    
                 
              
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    
    %dw 2.0
    output application/java
    ---
    {
            channel: "EC03",
            encoding: "US-ASCII",
            errorContainer: "OUTPUTMESSAGE",
            programName: "EC03",
            requestContainer: "INPUTDATA",
            responseContainer: "CICSDATETIME",
            tpnName: "CSMI"
    } as Object {
            class : "org.mule.modules.ibmctg.internal.model.ChannelRequest"
    }
  7. Add a Transform Messager after the IBM CTG to convert the result into readable format.

  8. Add a Logger at the end of the flow.

  9. Save the changes and deploy the Mule Application. Open a browser and make a request to http://localhost:8081/ec03. The result should be similar to:

    
                 
              
    1
    2
    3
    
    {
       cics-date-time: "08/01/2018 13:57:25"
    }

Invoke a COMMAREA or Channel Program inside a Transactional Scope

This application calls EC02, a COMMAREA-based program that returns a simple run counter.

Use case flow in Studio

  1. Perform steps 1 to 3 from the previous example and set the HTTP path to /test/ec02.

  2. In the Global Elements tab, add a new Bitronix Transaction Manager without further configurations.

  3. Drag a Transactional element next to the HTTP and configure according to the table below:

    Parameter Value

    Type

    XA Transaction

    Action

    BEGIN_OR_JOIN

  4. Double-click the IBM CTG component, select the operation Execute using COMMAREA and configure the following parameters:

    Parameter Value

    Content Reference

    #[payload]

    Request Reference

    #[flowVars.request]

  5. Add a Transform Message between the HTTP and the IBM CTG components. The connector does not provide dynamic/static metadata but allows users to define custom types using the Metadata Type tool.

  6. Define the input metadata according to section Add Custom Metadata using the schema file ec02-type.ffd:

    
                 
              
    1
    2
    3
    4
    
    form: COPYBOOK
    id: 'DFHCOMMAREA'
    values:
    - { name: 'LK-COUNT', type: String, length: 40 }
  7. Map the fields in the DataWeave transformer.

    
                 
              
    1
    2
    3
    4
    5
    6
    
    %dw 2.0
    %output text/plain schemaPath = "ec02-type.ffd" , segmentIdent = "DFHCOMMAREA"
    ---
    [{
            LK-COUNT: "000001234TH RUN OF EC02"
    }]
  8. Create a flowVar named request and configure the following fields (see section Load Java Metadata):

    
                 
              
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
    %dw 2.0
    output application/java
    ---
    {
            commareaLength: 40,
            encoding: "IBM037",
            programName: "EC02",
            replyLength: 40,
            tpnName: "CSMI"
    } as Object {
            class : "org.mule.modules.ibmctg.internal.model.CommareaRequest"
    }
  9. Add a Transform Message after the IBM CTG to extract the results in a JSON format.

    
                 
              
    1
    2
    3
    4
    5
    6
    
    %dw 2.0
    output application/json
    ---
    {
            count: payload
    }
  10. Add a Logger at the end of the flow.

  11. Save the changes, deploy the Mule Application. Open a browser and make a request to http://localhost:8081/ec02. The result should be similar to:

    
                 
              
    1
    2
    3
    
    {
        count: "1st RUN OF EC02"
    }

Add Custom Metadata

The IBM CTG connector does not provide dynamic or static metadata out-of-the-box, but allows users to define custom types using the Metadata Type tool. Follow the below guide to define input and output metadata:

  1. Place a schema file under src/main/resources directory, normally in .ffd format.

    Note: These schema files must be supplied by the user. They can be obtained from COBOL copybooks, which are included in the CICS installation.

  2. Go to the Metadata tab of the connector operation and click the Add metadata button.

    • Select Input:Payload and click the Edit icon to open the Metadata Editor.

      Metadata Editor

  3. Click Add to create a new type and provide and ID for it (that is, ec03-in-type for the program EC03 input data).

  4. Select type Copybook, then Schema and provide the location of the schema file.

  5. This populates a drop-down with a list of available data segments. Choose the one you need and click the Select button to save the configuration.

  6. Drag a DataWeave transformer before the IBM CTG component. Metadata fields become available to build the mapping.

    Metadata fields

    Note: Metadata definition is not a required step to use the IBM CTG connector but it is essential to improve the usability of the connector. See Create Metadata in the See Also section at the end of this document.

Load Java Metadata

Inside DataWeave, click the Define Metadata link to open the Metadata window.

  1. Click Add and provide the an ID, such as "CommareaRequest".

  2. Select type Java, then Java object in the Data Structure table.

  3. Search the class CommareaRequest (or the fully qualified name org.mule.modules.ibmctg.internal.model.CommareaRequest) and click OK.

  4. Click the Select button to save the configuration.

  5. Perform the same steps to load metadata for the ChannelRequest type.

Use Case: XML


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:bti="http://www.mulesoft.org/schema/mule/ee/bti"
        xmlns:ibmctg="http://www.mulesoft.org/schema/mule/ibmctg"
        xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
        xmlns:http="http://www.mulesoft.org/schema/mule/http"
        xmlns="http://www.mulesoft.org/schema/mule/core"
        xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/ee/bti
http://www.mulesoft.org/schema/mule/ee/bti/current/mule-bti-ee.xsd
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core
http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/ibmctg
http://www.mulesoft.org/schema/mule/ibmctg/current/mule-ibmctg.xsd">
        <configuration-properties file="automation-credentials.properties"/>
        <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" basePath="/" >
                <http:listener-connection host="0.0.0.0" port="8081" />
        </http:listener-config>
        <bti:transaction-manager />
        <ibmctg:config name="IBMCTG_Config" doc:name="IBMCTG Config">
                <ibmctg:connection host="${config.host}" port="${config.port}" serverName="${config.serverName}" username="${config.username}" password="${config.password}" />
        </ibmctg:config>
        <flow name="ibmdemoFlow">
                <http:listener doc:name="/ec01" config-ref="HTTP_Listener_config" path="/ec01"/>
                <ee:transform doc:name="Transform Message">
                        <ee:message >
                                <ee:set-payload ><![CDATA[%dw 2.0
output application/flatfile schemaPath = "ec01-type.ffd", segmentIdent = "DFHCOMMAREA"
---
[{
        "LK-DATE-OUT": "",
        "LK-SPACE-OUT": "",
        "LK-TIME-OUT": "",
        "LK-LOWVAL-OUT": ""
}]]]></ee:set-payload>
                        </ee:message>
                        <ee:variables >
                                <ee:set-variable variableName="request" ><![CDATA[%dw 2.0

output application/java
---
{
        commareaLength: 18,
        encoding: "IBM037",
        programName: "EC01",
        replyLength: 18,
        tpnName: "CSMI"
} as Object {
        class : "org.mule.modules.ibmctg.internal.model.CommareaRequest"
}]]></ee:set-variable>
                        </ee:variables>
                </ee:transform>
                <ibmctg:execute-using-commarea doc:name="Execute using commarea"
                commareaRequestType="#[vars.request]" config-ref="IBMCTG_Config"/>
                <ee:transform doc:name="Transform Message">
                        <ee:message >
                                <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
        date:payload
}]]></ee:set-payload>
                        </ee:message>
                </ee:transform>
        </flow>
        <flow name="ibmdemoFlow2">
                <http:listener doc:name="/ec02" config-ref="HTTP_Listener_config" path="/ec02"/>
                <try doc:name="Try" transactionalAction="ALWAYS_BEGIN" transactionType="XA">
                        <ee:transform doc:name="Transform Message">
                                <ee:message>
                                        <ee:set-payload ><![CDATA[%dw 2.0
output application/flatfile schemaPath = "ec02-type.ffd" , segmentIdent = "DFHCOMMAREA"
---
[{
        "LK-COUNT": "000001234TH RUN OF EC02"
}]]]></ee:set-payload>
                                </ee:message>
                                <ee:variables >
                                        <ee:set-variable variableName="request" ><![CDATA[%dw 2.0
output application/java
---
{
        commareaLength: 40,
        encoding: "IBM037",
        programName: "EC02",
        replyLength: 40,
        tpnName: "CSMI"
} as Object {
        class : "org.mule.modules.ibmctg.internal.model.CommareaRequest"
}]]></ee:set-variable>
                                </ee:variables>
                        </ee:transform>
                        <ibmctg:execute-using-commarea doc:name="Execute using commarea" config-ref="IBMCTG_Config" commareaRequestType="#[vars.request]"/>
                        <ee:transform doc:name="Transform Message">
                                <ee:message >
                                        <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
        count:payload
}]]></ee:set-payload>
                                </ee:message>
                        </ee:transform>
                </try>
        </flow>
        <flow name="ibmdemoFlow1">
                <http:listener doc:name="/ec03" config-ref="HTTP_Listener_config" path="/ec03"/>
                <try doc:name="Try" transactionalAction="ALWAYS_BEGIN" transactionType="XA">
                        <ee:transform doc:name="Transform Message">
                                <ee:message >
                                        <ee:set-payload ><![CDATA[%dw 2.0
output application/flatfile
schemaPath = "ec03-type.ffd" , segmentIdent = "DFHCOMMAREA"
---
[{
        "CICS-DATE-TM": null
}]]]></ee:set-payload>
                                </ee:message>
                                <ee:variables >
                                        <ee:set-variable variableName="request" ><![CDATA[%dw 2.0

output application/java
---
{
        channel: "EC03",
        encoding: "US-ASCII",
        errorContainer: "OUTPUTMESSAGE",
        programName: "EC03",
        requestContainer: "INPUTDATA",
        responseContainer: "CICSDATETIME",
        tpnName: "CSMI"
} as Object {
        class : "org.mule.modules.ibmctg.internal.model.ChannelRequest"
}]]></ee:set-variable>
                                </ee:variables>
                        </ee:transform>
                        <ibmctg:execute doc:name="Execute" channelRequest="#[vars.request]" config-ref="IBMCTG_Config"/>
                        <ee:transform doc:name="Transform Message">
                                <ee:message >
                                        <ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
        "cics-date-time":payload
}
]]></ee:set-payload>
                                </ee:message>
                        </ee:transform>
                </try>
        </flow>
</mule>