Writing a front-end transaction program
The front-end TP is responsible for acquiring a session, specifying the conversation characteristics, and requesting the startup of the back-end TP.
Note:
This section and other sections in this chapter pertain to applications deployed on MVS.
Step 1: Defining a conversation
Your program can define (allocate) a CPI-C conversation with its partner program using the AbtCPICConnectionSpec class. The symbolic destination name defined in the client's side information can be used to identify the partner and the transaction to be started on the server side.
| connection |
"Instantiate the connection"
connection := AbtCPICConnectionSpec new.
"Initialize the connection using the symbolic destination name defined in
the client's side information passed to this method"
connection symDestName: aSymDestName.
Step 2: Allocating a conversation
By using the AbtCPICConversation class, your transaction allocates the conversation using the connection defined in step 1.
| conversation |
"Instantiate the conversation"
conversation := AbtCPICConversation new.
"Allocate the conversation using the connection instance
obtained in step 1"
conversation connectUsing: connection.
CPI-C makes the connection, if possible, and notifies the partner TP of the conversation request. (Because allocation requests are buffered, it is possible that any errors making the connection will not be returned until a later call.) If the partner TP accepts the conversation, then both TPs share a set of default conversation characteristics for the conversation. Once the conversation is accepted, all calls can be made using methods available on the AbtCPICConversation class.
Step 3: Sending data to the partner transaction
With the conversation accepted, the front-end transaction can use one of the sendData methods on the AbtCPICConversation class.
| sendToTP qID command |
"Send data, in the form of a byte array, to the partner transaction
program. In this example, we are sending a command and a queue name,
converted to EBCDIC for the host"
qID := 'TSTSRVQ1'.
command := 'BUILDTSQ ', qID.
command := self convertStringToServer: command.
sendToTP := conversation sendData: command asByteArray.
Step 4: Receiving data from the partner transaction
When the front-end transaction is prepared to receive data from the back-end transaction, you can use the receiveBuffer: method of the AbtCPICConversation class. You can use thesetReceiveType: method to control whether or not receiveBuffer: waits for inbound data before returning. (The receiveAndWait method forces a setReceiveType: to CMRECEIVEANDWAIT before receiving.)
| receive |
"Receive from the host an indication of whether the command sent
in step 3 processed correctly. Test the call for errors"
(msg := conversation receiveAndWaitDataComplete) isCommunicationsError
ifTrue: [CICSTranscript cr;
show: 'Error occurred receiving message from Server.'].
A transaction program in send state can use the prepareToReceive: or receiveAndWaitmethod to put itself in receive state and put its partner transaction in send state.
Step 5: Ending the conversation
When a TP is finished communicating with its partner, it should end the conversation using either the deallocate: or disconnect method of the AbtCPICConversation class.
"End conversation with the partner transaction"
conversation disconnect.
The partner receives the deallocation indicator and any remaining data from the buffer. The partner typically finishes its own processing.
Last modified date: 01/29/2015