Example of starting transactions
start transaction ISR1 on terminal PEO1 on system ICC1.
| CICS® system | ICC1 | ICC2 |
|---|---|---|
| Transaction | ISR1/ITMP | ISR2 |
| Program | ICC$SRQ1/ICC$TMP | ICC$SRQ2 |
| Terminal | PEO1 | PEO2 |
This issues two start requests; the first is cancelled before it has expired. The second starts transaction ISR2 on terminal PEO2 on system ICC2. This transaction accesses its start data and finishes by starting transaction ITMP on the original terminal (PEO1 on system ICC1).
The programs and the expected output from them, can be found in C++ sample programs as files ICC$SRQ1 and ICC$SRQ2. Here the code is presented without the terminal IO requests.
#include "icceh.hpp"
#include "iccmain.hpp"
void IccUserControl::run()
{
IccRequestId req1;
IccRequestId req2("REQUEST1");
IccTimeInterval ti(0,0,5);
IccTermId remoteTermId("PE02");
IccTransId ISR2("ISR2");
IccTransId ITMP("ITMP");
IccBuf buffer;
IccStartRequestQ* startQ = startRequestQ();
- req1
- An empty IccRequestId object ready to identify a particular start request.
- req2
- An IccRequestId object containing the user-supplied identifier "REQUEST1".
- ti
- An IccTimeInterval object representing 0 hours, 0 minutes, and 5 seconds.
- remoteTermId
- An IccTermId object; the terminal on the remote system where we start a transaction.
- ISR2
- An IccTransId object; the transaction we start on the remote system.
- ITMP
- An IccTransId object; the transaction that the started transaction starts on this program's terminal.
- buffer
- An IccBuf object that holds start data.
startQ->setRouteOption( "ICC2" );
startQ->registerData( &buffer );
startQ->setReturnTermId( terminal()->name() );
startQ->setReturnTransId( ITMP );
startQ->setQueueName( "startqnm" );
This code fragment prepares the start data that is passed when we issue a start request. The setRouteOption says we will issue the start request on the remote system, ICC2. The registerData method associates an IccBuf object that will contain the start data (the contents of the IccBuf object are not extracted until we issue the start request). The setReturnTermId and setReturnTransId methods allow the start requester to pass a transaction and terminal name to the started transaction. These fields are typically used to allow the started transaction to start another transaction (as specified) on another terminal, in this case ours.
buffer = "This is a greeting from program
'icc$srq1'!!";
req1 = startQ->start( ISR2, &remoteTermId, &ti );
startQ->cancel( req1 );
req1 = startQ->start( ISR2, &remoteTermID,
&ti, &req2 );
return;
}
Again we start transaction ISR2 after an interval ti (5 seconds). This time the request is allowed to expire so transaction ISR2 is started on the remote system. Meanwhile, we end by returning control to CICS.
IccBuf buffer;
IccRequestId req("REQUESTX");
IccTimeInterval ti(0,0,5);
IccStartRequestQ* startQ = startRequestQ();
- buffer
- An IccBuf object to hold the start data we were passed by our caller (ICC$SRQ1).
- req
- An IccRequestId object to identify the start we will issue on our caller's terminal.
- ti
- An IccTimeInterval object representing 0 hours, 0 minutes, and 5 seconds.
if ( task()->startType() != IccTask::startRequest )
{
term->sendLine(
"This program should only be started via the StartRequestQ");
task()->abend( "OOPS" );
}
startQ->retrieveData();
buffer = startQ->data();
term->sendLine( "Start buffer contents = [%s]", buffer.dataArea() );
term->sendLine( "Start queue= [%s]", startQ->queueName() );
term->sendLine( "Start rtrn = [%s]",
startQ->returnTransId().name());
term->sendLine( "Start rtrm = [%s]", startQ->returnTermId().name() );
task()->delay( ti );
startQ->setRouteOption( "ICC1" );
startQ->start(
startQ->returnTransId(),startQ->returnTermId());
return;
We start a transaction called ITMP (the name of which was passed by ICC$SRQ1 in the returnTransId start information) on the originating terminal (where ICC$SRQ1 completed as it started this transaction). Having issued the start request, ICC$SRQ1 ends, by returning control to CICS.
Finally, transaction ITMP runs on the first terminal. This is the end of this demonstration of starting transactions asynchronously.