MainframeSupports
tip week 8/2003:

The tip this week is a continuation of the previous tip in english about asynchronous tasks in CICS. This week I will tell you how to wait for another task to finish.

If you want to wait in CICS, you must use an EXEC CICS DELAY. When you issue a DELAY the same thing happens as when you issue an EXEC CICS START for later execution: CICS creates an Interval Control Element (ICE). When the ICE expires the task issuing the DELAY will be resumed. Because an ICE is used for DELAY it is also possible to give it a REQID just like when you issue a START.

Now imagine that your CICS task just has discovered that some kind of ressource is missing (maybe a TS-queue). This ressource is normally set up using another transaction. This transaction can be executed asynchronously in the following manner from your task:

...
EXEC CICS
  START TRANSID('GADG')
END-EXEC
EXEC CICS
  DELAY INTERVAL(10) REQID('GADGWAIT')
END-EXEC
...

Here the transaction GADG is started asynchronously and then the issuing task will wait for 10 seconds unless another task in the meantime issues an EXEC CICS CANCEL REQID('GADGWAIT'). The best setup is when the GADG task issues the CANCEL as a signal to waiting tasks. Then the waiting tasks can continue immediately instead of waiting for the full period of time. For some strange reason it is not possible to check whether the DELAY lasted for the whole period or was cancelled. Therefore you have to validate if the transaction GADG has done its work properly.

Now imagine this situation: the GADG transaction is started and does all of its work including issuing the CANCEL before your task issues the DELAY command. In this case your task will wait for all 10 seconds even though there is no reason for this. This situation is very unlikely to happen, but it is possible in an MVS system with a lot of CPU's at its disposal.

You can read more about DELAY in the the manual called Application Programming Reference for Transaction Server. Transaction Server is the IBM name for CICS these days.

Previous tip in english        Sidste danske tip        Tip list