IBM CTG Connector 2.3 Examples | MuleSoft Documentation
# IBM CTG Connector 2.3 Examples
The following examples show several Mule flows for IBM CTG Connector:
  * Invoke a COMMAREA Program
  * Invoke a Channel Program
  * Invoke a COMMAREA or Channel Program Inside a Transactional Scope
  * Use Multiple Containers


## Before You Begin
  * Java 8 or 11
  * Anypoint Studio 7.x
  * Mule runtime engine (Mule) 4.x
  * DataWeave
  * Access to an IBM CTG system 9.1 or 9.2
  * IBM SDK 9.1 or 9.2


## Configure a Connection
To secure connections, you must specify the connection field values. To do this:
  * Create a configuration file for a connection.
  * Configure the connection global elements.
  * Configure a global element for the properties file.


### Create a Configuration File for a Connection
Create a configuration file that includes properties for a connection:
  1. Create a file named `mule-app.properties` in the `/src/main/resources/` folder.
  2. In the `mule-app.properties` file, create a set of properties for the connection, similar to the ones that follow, replacing the bracketed text (including the brackets) with the correct values for your configuration:
```
ibm.host=<hostname>
ibm.port=<port number>
ibm.serverName=<server name>
ibm.username=<username> (optional)
ibm.password=<password> (optional)
ibm.keystoreLocation=<location of the keystore containing the certificates required for an SSL connection> (optional)
ibm.keystorePassword=<password required to access the keystore for an SSL connection> (optional)
```

This may vary depending on the selected connection configuration.


For more information about creating a properties file, refer to Configuring Property Placeholders.
### Configure the Connection Global Elements
Configure global elements for connection:
  1. Create a new Mule project.
  2. In the **Mule Palette** view, click **Search in Exchange** and enter `ibm ctg`.
  3. Add **IBM CICS Transaction Gateway Connector** to the **Selected modules** section and click **Finish**.
  4. Click the **Global Elements** tab and click **Create**.
  5. Select **Connector Configuration > IBM CTG Config** and click **OK**.
  6. Enter the values to configure **Connection**.
  7. Click the **Test Connection** button to ensure there is connectivity with the IBM CTG API. A successful message should pop up.
  8. Click **OK**.


### Configure a Global Element for the Properties File
Configure a global element for the `mule-app.properties` file so that Mule knows where to find it:
  1. Click the **Global Elements** tab and click **Create**.
  2. In the **Choose Global Type** dialog, select **Configuration properties** and click **OK**.
  3. In the **File** field, enter `mule.app.properties`.
  4. Click **OK**.


## Invoke a COMMAREA Program
This application calls EC01, a COMMAREA-based program that outputs the current datetime in a formatted EBCDIC string.
  1. Create a new Mule Project in Anypoint Studio and fill in the IBM CTG credentials in `src/main/resources/mule-app.properties`.
```
ctg.host=<HOST>
ctg.port=<PORT>
ctg.serverName=<SERVER_NAME>
ctg.username=<USERNAME>
ctg.password=<PASSWORD>
```

  2. Drag an HTTP Listener operation onto the canvas, leave the default values for Host and Port, and set the Path to `/test/ec01`.
  3. Drag an IBM CTG operation onto the canvas and add a new Global Element to configure a standard (non-SSL) client.
Parameter | Value  
---|---  
**Server Name** |  `${ctg.serverName}`  
`${ctg.username}`  
`${ctg.password}`  
Click **Test Connection** 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 **Execute** operation and configure the following parameters:
Parameter | Value  
---|---  
**Content Reference**  
**Request Reference** |  `#[flowVars.commareaRequest]`  
  5. Add a Transform Message between the HTTP and the IBM CTG operation.
The connector does not provide dynamic or static metadata, but allows users to define custom types using the Metadata Type tool.
    1. Define the input metadata for Add Custom Metadata using the ec01-type.ffd schema file:
```
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.
```
%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 flow variable named `commareaRequest` and configure the following fields, as described in Load Java Metadata:
```
%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 Load Java Metadata for how to obtain metadata for the CommareaRequest.
  6. Add a Transform Message after the IBM CTG to extract the results in a JSON format.
```
%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:
```
{
  date: "08/01/2019 13:41:17"
}
```
3. Create a flow variable named `commareaRequest` and configure the following fields, as described in Load Java Metadata:
```
%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 Load Java Metadata for how to obtain metadata for the CommareaRequest.
  6. Add a Transform Message after the IBM CTG to extract the results in a JSON format.
```
%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:
```
{
  date: "08/01/2019 13:41:17"
}
```



### XML for This Example
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
```
<?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>
</mule>
```

## Invoke a Channel Program
This application calls EC03, a channel-based program that takes an input data container and returns three containers:
  * A data and time container
  * The length of the input data, use channels, and containers in a CICS program
  * An output container that contains a copy of the input data, or an error message


  1. Perform steps 1 to 3 from the previous example and set the HTTP path to `/ec03`.
  2. Double-click the IBM CTG operation, select the Execute operation, and configure the following parameters:
Parameter | Value  
---|---  
**Content Reference**  
**Request Reference** |  `#[flowVars.request]`  
  3. Add a Transform Message between the HTTP and the IBM CTG operation.
  4. Define the input metadata according to Add Custom Metadata using the schema file ec03-type.ffd:
```
form: COPYBOOK
id: 'DFHCOMMAREA'
values:
- { name: 'CICS-DATE-TM', type: String, length: 8 }
```

  5. Map the fields in the DataWeave transformer.
```
%dw 2.0
output text/plain schemaPath = "ec03-type.ffd", segmentIdent = "DFHCOMMAREA"
---
[{
	CICS-DATE-TM: ""
}]
```

  6. Create a flowVar variable named `request` and configure the following fields, as described in Load Java Metadata:
```
%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 operation to convert the result into a readable format.
  8. Add a Logger at the end of the flow.
  9. Save the changes and deploy the Mule app.
  10. Open a browser and make a request to `http://localhost:8081/ec03`.
The result should be similar to:
```
{
  cics-date-time: "08/01/2019 13:57:25"
}
```



### Add Custom Metadata
The IBM CTG Connector does not provide dynamic or static metadata out of the box, but it enables users to define custom types using the Metadata Type tool. Define input and output metadata as follows:
  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 **Add metadata**.
     * Select Input:Payload and click **Edit** to open the 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, select Schema, and provide the location of the schema file.
  5. From the list of available data segments drop-down menu that appears, choose the one you need and click **Select** to save the configuration.
  6. Drag a DataWeave transformer in front of the IBM CTG component in the flow.
Metadata fields become available to build the mapping.
Having a metadata definition is not required to use IBM CTG Connector, but it is essential to improve the usability of the connector. See Create Metadata.
### Add Custom Metadata
The IBM CTG Connector does not provide dynamic or static metadata out of the box, but it enables users to define custom types using the Metadata Type tool. Define input and output metadata as follows:
  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 **Add metadata**.
     * Select Input:Payload and click **Edit** to open the 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, select Schema, and provide the location of the schema file.
  5. From the list of available data segments drop-down menu that appears, choose the one you need and click **Select** to save the configuration.
  6. Drag a DataWeave transformer in front of the IBM CTG component in the flow.
Metadata fields become available to build the mapping.
Having a metadata definition is not required to use IBM CTG Connector, but it is essential to improve the usability of the connector. See Create Metadata.


#### Load Java Metadata
In DataWeave, click **Define Metadata** to open the Metadata window.
  1. Click **Add** and provide an ID, such as `CommareaRequest`.
  2. Select type Java and then select a 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 **Select** to save the configuration.
  5. Perform the same steps to load metadata for the ChannelRequest type.


### XML for This Example
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
```
<?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="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>
</mule>
```

## Invoke a COMMAREA or Channel Program Inside a Transactional Scope
This application calls EC02, a COMMAREA-based program that returns a simple run counter.
  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  
---|---  
`XA Transaction`  
`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 Add Custom Metadata using the schema file ec02-type.ffd:
```
form: COPYBOOK
id: 'DFHCOMMAREA'
values:
- { name: 'LK-COUNT', type: String, length: 40 }
```

  7. Map the fields in the DataWeave transformer.
```
%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, as described in Load Java Metadata:
```
%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.
```
%dw 2.0
output application/json
---
{
	count: payload
}
```

  10. Add a Logger at the end of the flow.
  11. Save the changes and deploy the Mule app.
  12. Open a browser and make a request to `http://localhost:8081/ec02`. The result should be similar to:
```
{
  count: "1st RUN OF EC02"
}
```
7. Map the fields in the DataWeave transformer.
```
%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, as described in Load Java Metadata:
```
%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.
```
%dw 2.0
output application/json
---
{
	count: payload
}
```

  10. Add a Logger at the end of the flow.
  11. Save the changes and deploy the Mule app.
  12. Open a browser and make a request to `http://localhost:8081/ec02`. The result should be similar to:
```
{
  count: "1st RUN OF EC02"
}
```



### XML for This Example
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
```
<?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="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>
```

## Use Multiple Containers
This Mule flow shows how to use multiple containers. This example uses the following operations:
  * **HTTP Listener** Accepts data from HTTP requests
  * **Transform Message** Sets the first content request and outputs the data as a flat file
```
%dw 2.0
output application/flatfile schemaPath = "ec03-type.ffd", segmentIdent = "DFHCOMMAREA", encoding="cp037"
---
[{
	"CICS-DATE-TM": ""
}]
```

  * **Transform Message** Sets the second content request and outputs the data as a flat file
```
%dw 2.0
output application/flatfile schemaPath = "ec03-type.ffd", segmentIdent = "DFHCOMMAREA", encoding="cp037"
---
[{
	"CICS-DATE-TM": ""
}]
```

  * **Transform Message** Sets multiple channels and content requests and outputs the data in JSON
```
%dw 2.0
output application/json
---
[
	{
		channelRequest : 	{
			channel: "EC03",
			encoding: "US-ASCII",
			errorContainer: "OUTPUTMESSAGE",
			programName: "EC03",
			requestContainer: "INPUTDATA",
			responseContainer: "CICSDATETIME",
			tpnName: "CSMI"
		},
		content : vars.request1.^raw
	},
	{
		channelRequest : 	{
			channel: "EC03",
			encoding: "US-ASCII",
			errorContainer: "OUTPUTMESSAGE",
			programName: "EC03",
			requestContainer: "INPUTDATA",
			responseContainer: "CICSDATETIME",
			tpnName: "CSMI"
		},
		content : vars.request2.^raw
	}
]
```

  * **Execute with multiple channels** Calls a remote CICS program sending data encapsulated in channels and containers, enabling users to transfer more than 32 KB in a single request
Enter the following values:
**Object type**  
---  
**Connector Configuration** |  `IBMCTG_Config`  
**Channel and contents**  
  * **Transform Message** Outputs the data in JSON
```
%dw 2.0
output application/json
---
{
	"cics-date-time":payload
}
```

  * **Logger** Performs logging
* **Execute with multiple channels** Calls a remote CICS program sending data encapsulated in channels and containers, enabling users to transfer more than 32 KB in a single request
Enter the following values:
**Object type**  
---  
**Connector Configuration** |  `IBMCTG_Config`  
**Channel and contents**  
  * **Transform Message** Outputs the data in JSON
```
%dw 2.0
output application/json
---
{
	"cics-date-time":payload
}
```

  * **Logger** Performs logging


### XML for This Example
Paste this code into the Studio XML editor to quickly load the flow for this example into your Mule app:
```
<?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="mule-app.properties"/>
	<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="de838cd2-71c3-41b3-9fbd-be6f671921dc" 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" doc:id="1435fcc3-4b97-496e-8552-58a339dce96f" >
		<ibmctg:connection host="${config.host}" port="${config.port}" serverName="${config.serverName}" username="${config.username}" password="${config.password}" />
	</ibmctg:config>
	<flow name="multi_channel_testFlow" doc:id="a79bd0f2-e659-4778-96b1-fdcbf86166eb" >
		<http:listener doc:name="Listener" doc:id="594a7d30-b82f-4899-a212-0fc8897b414a" config-ref="HTTP_Listener_config" path="/multi"/>
		<ee:transform doc:name="Set Content Request I" doc:id="f3ebec71-8cb5-41f0-a993-bd68a963ac63" >
			<ee:variables >
				<ee:set-variable variableName="request1" ><![CDATA[%dw 2.0
output application/flatfile schemaPath = "ec03-type.ffd", segmentIdent = "DFHCOMMAREA", encoding="cp037"
---
[{
	"CICS-DATE-TM": ""
}]]]></ee:set-variable>
			</ee:variables>
		</ee:transform>
		<ee:transform doc:name="Set Content Request II" doc:id="1362b85a-a36c-4fa1-bc28-96266bc416c5">
			<ee:variables>
				<ee:set-variable variableName="request2" ><![CDATA[%dw 2.0
output application/flatfile schemaPath = "ec03-type.ffd", segmentIdent = "DFHCOMMAREA", encoding="cp037"
---
[{
	"CICS-DATE-TM": ""
}]]]></ee:set-variable>
			</ee:variables>
		</ee:transform>
		<ee:transform doc:name="Set Multiple Channels And Contents Request" doc:id="4157b44c-ac57-40a6-8ced-c5e165a1035c" >
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
[
	{
		channelRequest : 	{
			channel: "EC03",
			encoding: "US-ASCII",
			errorContainer: "OUTPUTMESSAGE",
			programName: "EC03",
			requestContainer: "INPUTDATA",
			responseContainer: "CICSDATETIME",
			tpnName: "CSMI"
		},
		content : vars.request1.^raw
	},
	{
		channelRequest : 	{
			channel: "EC03",
			encoding: "US-ASCII",
			errorContainer: "OUTPUTMESSAGE",
			programName: "EC03",
			requestContainer: "INPUTDATA",
			responseContainer: "CICSDATETIME",
			tpnName: "CSMI"
		},
		content : vars.request2.^raw
	}
]]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<ibmctg:execute-with-multiple-channels doc:name="Execute with multiple channels" doc:id="1913f9b3-95b2-4e83-8028-ea934d1a59ae" config-ref="IBMCTG_Config" />
		<ee:transform doc:name="Transform Message" doc:id="31f774bb-a848-42c6-a1ea-efb44612ca03" >
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
	"cics-date-time":payload
}]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<logger level="INFO" doc:name="Logger" doc:id="dff20a20-43a0-401f-8c20-7d480062fe64" message="#[payload]"/>
	</flow>
</mule>
```

## See Also
  * Introduction to Anypoint Connectors
  * MuleSoft Help Center