COMMAREA is something all of us, CICS programmers, are familiar with; it has been an integral part of CICS programing since its introduction in 1975 and continues to do so even today. Then why Channel and Containers now? What are the advantages? Should you switch over? These are the questions which we will try to address in this introductory article.
Why Channels and Containers
Let’s start with the BIG question first, why Channels and Containers? The short answer is to break the 32K size limitation of COMMAREA. The need for passing data more than the conventional 32K arise from the fact that modern CICS programs now should have the ability to interface with applications outside the bounds of the CICS and process large quantities of data in XML(Extensible Markup Language) and JSON (JavaScript Object Notation) formats. These formats are used to transfer large binary objects, such as images, in addition to traditional character and numeric data.
You might then ask why not simply increase the size of the COMMAREA, well there is more to it that what meets the eye. Execute Interface Block or DHFEIBLK is a control block which is loaded automatically by CICS for every program, EIB is unique to a task and contains a set of system related information corresponding to the task. One of the most frequently used fields from the EIB block is EIBCALEN, this half word binary field holds the length of COMMAREA.
The linkage section of any CICS program contains DHFEIBLK as the first fields and any change to EIBCALEN which is part of DHFEIBLK means that you will have to recompile your entire set of CICS programs, which IBM does not want you to do.
There are other options to pass data larger than 32K, you can use the GETMAIN command to acquire a storage area larger than 32 KB, and passing the address of the large storage area in the COMMAREA but this only works in a single CICS address space. Data can be written to a TSQ or VSAM file and the name can be passed through COMMAREA or MQ but this would involve allocation of program-specific managed resources and would require implementing the resource setup and configuration, introducing extra processing.
Channels and Containers – Concepts
In simple terms, a container is a storage area managed by CICS that can hold any form of application data with no restriction on size or format and a channel is a reference to a collection of containers.
If you want to pass data to another program you put that data into a Channel/Container and pass the name of the Channel to the other program. The receiving program can access the data using the correct Channel and container name.
Sending Program
01 EMP-DATA
05 EMP-NAME PIC X(20).
05 EMP-DEPT PIC X(10).
MOVE “TOM” TO EMP-NAME.
MOVE “HR” TO EMP-DEP.
EXEC CICS PUT
CONTAINER(‘EMP-CONTR’)
CHANNEL(‘EMP-CHNL’)
FROM(EMP-DATA)
END-EXEC.
EXEC CICS LINK
PROGRAM (PGM1)
CHANNEL(‘EMP-CHNL’)
END-EXEC.
EXEC CICS GET
CONTAINER(‘EMP-CONTR’)
CHANNEL(‘EMP-CHNL’)
INTO(EMP-DATA)
END-EXEC.
DISPLAY “UPDATED DEPARTMENT:” EMP-DEPT.
The first PUT command creates the Channel “EMP-CHNL” and adds a container new ‘EMP-CONTR’ to it and. The program can then pass the channel and its containers to a second program using the CHANNEL (channel-name) option of the EXEC CICS LINK, XCTL, START, or RETURN commands. A subsequent PUT command using the same Channel and Container name will replace the data.
The second program can read containers passed to it using the GET command and returns data back to the calling program by passing the processed data using a PUT to the same containers/Channel.
Receiving Program
01 EMP-DATA-R
05 EMP-NAME-R PIC X(20).
05 EMP-DEPT-R PIC X(10).
EXEC CICS GET
CONTAINER(‘EMP-CONTR’)
CHANNEL(‘EMP-CHNL’)
INTO(EMP-DATA-R)
END-EXEC.
MOVE ‘IT’ TO EMP-DEPT-R
EXEC CICS PUT
CONTAINER(‘EMP-CONTR’)
CHANNEL(‘EMP-CHNL’)
FROM(EMP-DATA-R)
END-EXEC.
Channels and containers are visible only to the program that creates them, and to the programs that they are passed to. When these programs end, CICS automatically deletes the containers and their storage.
Current Channel
The “Current” Channel is the channel that was used during the invocation of a particular program; even though that program can create a new channel, the current channel remains unchanged. If a program is not invoked using a Channel, then it does not have a current channel.
If a command using container is present without a Channel name, CICS assumes the current channel name. For example in the receiving program above, if the GET and PUT commands do not include the Channel name, then the current channel name (the channel with which the program was invoked) of EMP-CHNL is assumed by CICS.
A program can discover its current channel, meaning the channel with which it was started, if it issues the following command.If there is no current channel, this command returns a blank.
EXEC CICS
ASSIGN CHANNEL(WS-CURRENT-CNAME)
END-EXEC
Scope of Channel
If a program that has a current channel executes a CICS LINK, XCTL, START, or RETURN commands without a Channel name, the subsequent program will be started without a channel, however if you are executing a CALL statement to a sub program, this program inherits the Channel of the calling program and any new channel created by the called program will be accessible to the calling program as well. A call is treated more or less like an extended PERFORM statement.
If your program XCTLs to another program using one of 3 channels it has created, only that one channel is made available to the called program and the other two channels are deleted , but if the program LINKS to a sub program all the channels are preserved as a LINK, meaning the control is eventually returned to your calling program by a return command.
Naming of Channel /Containers
Channel and container names can consist of 1-16 characters and acceptable special characters and are case sensitive. You cannot use leading and embedded blank characters. If the name supplied has fewer than 16 characters, it is padded with trailing blanks.
The channel name of your transaction can be same as some other existing channel name. CICS automatically takes care of assigning of channel and container names to the respective tasks.
Type of Containers and conversion
Containers are of two types
- BIN or Binary
- CHAR or Character
Binary is the default and binary channels cannot have the data encoding converted to ASCII and retain the encoding format in which they are created but a CHAR container can have its data encoding changed dynamically.
Should you switch to Channels and Containers?
Here is a short comparison
COMMAREA Channel & Containers
Is available as default Needs to be defined explicitly
Has length restriction of 32K No Length restriction
Singular with one data structure Multiple individual data structures
No additional application coding Overhead of additional coding
It’s important to note that a COMMAREA driven program can invoke channels and containers and a channel and container driven program can use COMMAREA as well. A program can even be written to be driver by either COMMAREA or channels and containers.
So the decision to move to the new channels and containers structure should be requirement driven. If you see no reason to pass data beyond 32K or there is no need to have multiple data structures, COMMAREA should work just fine. The support for COMMAREA is going to continue from IBM. If you have a need to interface with applications outside the bounds of the CICS and process large quantities of data then channels and containers structure is the way to go.
In the next article I will try to explore the various EXEC CICS commands set for channels and containers and provide programing examples. Hope this helped you get a basic overview of CICS channels and containers. Thanks for reading.
Recent Comments