Writing a back-end transaction
The back-end transaction (in this sample, a TP running on CICS Transaction Server) is initiated as a result of the front-end transaction's connectUsing: method.
Step 1: Accepting the conversation
The back-end transaction can choose either to accept the conversation or to reject it. If the conversation is accepted, the back-end transaction needs to allocate an instance of AbtCPICConversation on its end of the conversation. You can use the acceptConversation: method to accept and allocate the conversation.
| connection conversation result |
"Instantiate the connection, then accept the conversation based on the
connection. CPI-C sets the conversation characteristics. Test to ensure
the conversation is accepted"
connection := AbtCPICConnectionSpec new.
conversation := AbtCPICConversation new.
(result := conversation acceptConversation: connection)
isCommunicationsError
ifTrue: [CICSTranscript cr;
show: 'Results of obtain conversation'; cr;
show: result printString].
Note:
If your transaction program is not started by Attach Manager, you can use the setTPName: method to specify the TP name you want to use.
Step 2: Retrieving conversation characteristics
Use the getAttributes method of the AbtCPICConversation class to return an AbtCPICConnectionSpec object containing the conversation characteristics. You can also any of the extract... methods to determine a specific conversation characteristic.
| characteristics |
"Obtain the conversation characteristics"
characteristics := conversation getAttributes.
Step 3: Receiving data from the front-end transaction
Once the conversation is accepted, the back-end transaction should use the receiveBuffer: method of the AbtCPICConversation class.You can use the setReceiveType: method to control whether or not receiveBuffer: waits for inbound data before returning. (The receiveAndWait method forces a setReceiveType: to CMRECEIVEANDWAIT before receiving.) Note that the receive methods for the front-end and back-end transactions can be identical.
| command msg |
"Receive the message from the workstation. In this example, the message sent is a command that needs to be processed."
msg := conversation receiveAndWaitDataComplete.
command := msg asString.
self processCommand: command.
The result of a receiveAndWait is an CPICReception object, which contains not only the raw data received, but also CPI-C status information. You can use the methods of CPICReceptionObject to retrieve this information.
The back-end transaction can now use the
send methods to send data to the front-end transaction in the same manner the front-end transaction sends data to the back-end transaction. See
Step 3: Sending data to the partner transaction. Also, the back-end transaction can end the conversation in the same way the front-end transaction requests the conversation be ended. See
Step 5: Ending the conversation.
Last modified date: 01/29/2015