MainframeSupports
tip week 30/2016:

Way back in week 42 in 2009 I wrote a tip about waiting in REXX and COBOL as neither of those languages have a builtin feature to delay execution. I have now discovered that my tip does not work anymore at least not for REXX. It forced me to find another way of waiting.

Language Environment offers a module called CEEDLYM which can be called from COBOL, but it only works with static link and thus it cannot be used from REXX. On the other hand CEEDLYM does not require your program to be running in 24 bit addressing mode. Furthermore you can specify the delay time in milliseconds which is much more granular than seconds offered by ILBOWAT0. An example:

01  MISC.
  03  DELAY-TIME PIC S9(9) BINARY.
  03  CEE-RC PIC X(12).
...
MOVE 5000 TO DELAY-TIME
CALL 'CEEDLYM' USING DELAY-TIME CEE-RC
IF CEE-RC = LOW-VALUES
  DISPLAY 'WAIT OK'
ELSE
  DISPLAY 'WAIT FAILED WITH ' CEE-RC
END-IF

I hope I am forgiven for lack of indentation and missing statements. The above declarations and code will make your COBOL program delay for 5 seconds. Do not execute the above code in CICS. Either it fails with an abend or even worse it pauses the whole CICS region for five seconds.

But what about REXX which was my original challenge? I found a completely new solution:

SLEEPTIME = 5
CALL SYSCALLS 'ON'
ADDRESS SYSCALL "SLEEP" SLEEPTIME
CALL SYSCALLS 'OFF'

ADDRESS SYSCALL lets you execute a range of z/OS UNIX commands and one of them is SLEEP which understands a number of seconds assigned to a REXX variable. Well then there is nothing left than just to wait...

Previous tip in english        Forrige danske tip        Tip list