A COMMAREA is a block of storage allocated by the program. The Client application uses the COMMAREA to send data to the server and the server uses the same storage to return data to the client.
Therefore, you must create a COMMAREA that is large enough to contain all the information to be sent to the server and large enough to contain all the information that can be returned from the server.
For example, you need to send a 12 byte serial number to the server, but you might receive 20 Kb back from the server. You must create a COMMAREA of size 20 Kb. Your code would look like this:
// serialNo is a Null terminated string
CclBuf Commarea; // create extensible buffer object
Commarea.assign(strlen(serialNo),serialNo); // Won't include the Null
Commarea.setDataLength(20480); // stores Nulls in the unused area
In the example, the serial number is stored in the new Commarea which is then increased in size to 20480. The extra bytes are filled with nulls. This is important as it ensures that the information transmitted to the server is kept to a minimum. The CICS Transaction Gateway software strips off the excess nulls and transmits 12 bytes to the server.