Professional Documents
Culture Documents
Basic Examples: Figure 1. Copybook INQINTC
Basic Examples: Figure 1. Copybook INQINTC
Recommendation
For ease of maintenance of a client/server application that uses a channel, create a copybook that
records the names of the containers used and defines the data fields that map to the containers.
Include the copybook in both the client and the server program.
Note: This example shows two COBOL programs. The same techniques can be used in any of the
other languages supported by CICS®. However, for COBOL programs only, if the server program
uses the SET option (instead of INTO) on the EXEC CICS GET CONTAINER command, the
structure of the storage pointed to by SET must be defined in the LINKAGE section of the
program. This means that you will require two copybooks rather than one. The first, in the
WORKING-STORAGE section of the program, names the channel and containers used. The
second, in the LINKAGE section, defines the storage structure.
Figure 2. A simple example of a program that creates a channel and passes it to a second
program
IDENTIFICATION DIVISION.
PROGRAM-ID. CLIENT1.
WORKING-STORAGE SECTION.
COPY INQINTC
PROCEDURE DIVISION.
MAIN-PROCESSING SECTION.
*
* INITIALISE CUSTOMER RECORD
*
... CREATE CUSTNO and BRANCHNO
*
* GET CUSTOMER RECORD
*
EXEC CICS PUT CONTAINER(CUSTOMER-NO) CHANNEL(INQUIRY-
CHANNEL)
FROM(CUSTNO) FLENGTH(LENGTH OF CUSTNO)
END-EXEC
EXEC CICS PUT CONTAINER(BRANCH-NO) CHANNEL(INQUIRY-CHANNEL)
FROM(BRANCHNO) FLENGTH(LENGTH OF BRANCHNO)
END-EXEC
*
* PROCESS CUSTOMER RECORD
*
... FURTHER PROCESSING USING CUSTNAME and CUSTADDR1 etc...
EXIT.
Figure 3 shows the SERVER1 program linked to by CLIENT1. SERVER1 retrieves the data from the
custno and branchno containers it has been passed, and uses it to locate the full customer
record in its database. It then creates a new container, custrec, on the same channel, and
returns the customer record in it.
Note that the programmer hasn't specified the CHANNEL keyword on the GET and PUT commands
in SERVER1: if the channel isn't specified explicitly, the current channel is used—that is, the
channel that the program was invoked with.
Figure 3. A simple example of a linked to program that retrieves data from the channel it has been
passed. This program is linked-to by program CLIENT1 shown in Figure 2.
IDENTIFICATION DIVISION.
PROGRAM-ID. SERVER1.
WORKING-STORAGE SECTION.
COPY INQINTC
PROCEDURE DIVISION.
MAIN-PROCESSING SECTION.
EXIT.