
MainframeSupports tip week 6/2003:
You can do a lot of asynchronous stuff in CICS. This tip and the next tip in english will
give you some idea of the basic elements you can use to make asynchronous tasks in CICS and
how you can make them wait for each other.
If you are in the mood for starting another task in CICS asynchronously then you must use a
EXEC CICS START TRANSID(<trans-id>), where <trans-id> is the name of the transaction
you want to run. If you don't supply a time for the task to start on, it will start as soon
as possible. If you supply a time to start the task on, you can give the transaction
waiting to be started a name
by using the parameter REQID(<name>). <name> can consist of any characters and be up
to 8 characters long. Check your release of CICS, maybe it allows up to 16 characters. A
transaction waiting to be started is called an Interval Control Element (ICE). An
asynchronous task is for CICS what a batch job is for your TSO session.
It is possible to remove an ICE with the command EXEC CICS CANCEL REQID(<name>). This
is the equivalent of purging a batch job waiting to be processed. This command can be quite
useful if your asynchronous transaction will start itself within a certain time interval.
Now imagine that this transaction is started more times within the interval
by other tasks. Then you get a
lot of repetitions of the transaction and that might not be what you desired. You can
avoid this situation in the following manner:
...
EXEC CICS
CANCEL REQID('MYREQID')
NOHANDLE
END-EXEC
IF EIBRESP NOT = 0 AND EIBRESP NOT = 13
THEN
/* ERROR */
ELSE
/* REST OF PROGRAM */
...
EXEC CICS
START TRANSID('MYID')
INTERVAL(500)
REQID('MYREQID')
END-EXEC
...
This transaction is guaranteed to start every fifth minute only if no one else starts it.
If someone starts it in between then the waiting transaction will be removed. EIBRESP = 13
is returned when no waiting ICE's with the requested REQID exists.
You can read a lot more about START TRANSID and CANCEL REQID in the the manual called
Application Programming Reference for Transaction Server. Transaction Server is the IBM name
for CICS these days. I will assume that you are running on a CICS system after version 3.3.
If not you might experience trouble using START with the REQID parameter. Send me a note
if you have this kind of trouble.
Previous tip in english
Sidste danske tip
Tip list
|