Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a TIMER function in Cobol

Status
Not open for further replies.

sawsheen

Programmer
Mar 18, 2002
5
0
0
CA
I'm converting an Assembler module into Cobol. It executes the Timer service call to delay a batch job. Can this be done in Cobol?
Thanks, Alex
 
If you're writing a batch program, I haven't seen any built-in functionality that handles this.
In a CICS environment, it's easily done using the Interval Control facility.
In batch, you can play with COBOL's time/date function to delay something. Just grab the current time/date when the program starts running, then grab it again later. You can use it to delay ending the program etc until time/date 2 is more than 15 mins later than time/date 1, and so on.

Dave
 
Hi,

On the PC search for DosSleep and on the mainframe search for ILBOWAT0.

Regards,

Crox
 
Alex,

"Timer services" are largely operating system dependent, as pointed by Crox. COBOL does have its own implementations. How timers are used depends on what your application design and requirements are.

Lets look at a couple of timer implementations and usages. Some of these solutions may not be available in all platforms.

There is the OPEN WITH TIME LIMITS statement in COBOL. You use this statement to attempt an I/O completion within a time frame that you specify. Creative usage: You can "hang" [sleeping2] your program for a while on an I/O that you know will not complete before the time you set runs out.

You can use Dave's solution in a loop implementing a real clock controlled delay. For example, when your application requires a timing based on a real clock. However, you will need an assist from the operating system in order to go to "sleep" now and then, and avoid taxing the CPU.

Operating systems usually have a line-up of quite sophisticated timer services you can choose from. Your application dictates which one you choose.

Dimandja
 
Hi,

If you make your own function, using start-date and start-time and compare it with the current-date and current-time, it can be very cpu-time consuming. That is why it is better to find an operating system utility to do this because those should not use (much) cpu-time.

But of course, you can make something in COBOL with such a functionality.

Also with the newer COBOL compilers, you can use expressions with the FUNCTION INTEGER-OF-DATE combined with time.

Good Luck and tell us what you did.

Regards,

Crox
 
From the references to "batch" and "assembler" - I am taking a WILD guess that this *may* be an IBM mainframe environment. If so, then YES, there is a "built-in" (but little documented) solution.

If you do a call to the IBM provided ILBOWAT0 (first "O" is letter "O" - 2nd "0" is number "0") passing it a binary value representing seconds to "wait".

NOTE: This is a 24-bit routine. Therefore, you need to either call it from "below-the-line" - or call it dynamically from a program compiled with DATA(24).

***

If you are NOT on an IBM mainframe environment, let us know what your environment is - to get a specific solution.
 
Hi Sawsheen,

On DOS you can use USER or C Libraries to call OS level calls. On windows you can call WIN32API. On Unix you can call functions from Shared Libraries of UNIX. In all cobol OS function calling mechanism is there.

On mainframes also you can call assembly routines from COBOL.

to get the exact answer you should always write the hardware and compiler version.

regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top