Skip to main content

Actions

The ballerinax/ibm.ctg package exposes the following clients:

ClientPurpose
ClientInvokes CICS programs via ECI and manages the IBM CTG gateway connection lifecycle.

Client

Invokes CICS programs via ECI and manages the IBM CTG gateway connection lifecycle.

Configuration

FieldTypeDefaultDescription
hoststringRequiredHostname or IP address of the IBM CICS Transaction Gateway daemon.
portintRequiredPort number of the IBM CTG gateway (e.g., 2006 for non-SSL, 8050 for SSL).
cicsServerstringRequiredThe logical name of the CICS server (region) registered with the CTG gateway.
authAuthRequiredCICS user credentials record containing userId and password.
socketConnectTimeoutint15Timeout in seconds for establishing a socket connection to the CTG gateway daemon.
secureSocketSecureSocket()SSL/TLS configuration for secure connections to the CTG gateway. Omit for non-SSL connections.
enableTracebooleanfalseEnables application-level tracing for debugging ECI interactions.

Initializing the client

import ballerinax/ibm.ctg;

configurable string host = ?;
configurable int port = ?;
configurable string cicsServer = ?;
configurable string userId = ?;
configurable string password = ?;

ctg:Client ctgClient = check new ({
host: host,
port: port,
cicsServer: cicsServer,
auth: {
userId: userId,
password: password
}
});

Operations

ECI program execution

execute

Executes a CICS program via the ECI protocol, passing an optional COMMAREA payload and returning the response COMMAREA data as a byte array. Returns () (nil) if the CICS program returns no COMMAREA data.

Parameters:

NameTypeRequiredDescription
programNamestringYesThe name of the CICS program to invoke (up to 8 characters).
commAreabyte[]NoThe COMMAREA input data to pass to the CICS program.
commAreaSizeintNoExplicit size of the COMMAREA buffer in bytes. If omitted, derived from the length of commArea.
timeoutintNoECI request timeout in seconds. Defaults to 10.

Returns: byte[]|Error?

Sample code:

byte[] inputPayload = "INQUIRY INPUT DATA".toBytes();
byte[]? response = check ctgClient->execute(
programName = "HELLOCICS",
commArea = inputPayload
);

Sample response:

[72, 101, 108, 108, 111, 32, 102, 114, 111, 109, 32, 67, 73, 67, 83, 33]

Connection management

close

Closes the IBM CTG client connection and releases all associated resources. Should be called when the client is no longer needed to ensure clean resource cleanup.

Returns: Error?

Sample code:

check ctgClient->close();