View previous topic :: View next topic
|
Author |
Message |
subhadeep_infy
New User
Joined: 06 Mar 2006 Posts: 10
|
|
|
|
Hi,
I have a requirement where we need to wait for a couple of milliseconds before proceeding with the next executable statement in COBOL. Do we have any keyword in COBOL which contains the above mentioned functionality.
TIA,
Subhadeep |
|
Back to top |
|
|
Rupesh.Kothari
Member of the Month
Joined: 27 Apr 2005 Posts: 463
|
|
|
|
HI,
Quote: |
I have a requirement where we need to wait for a couple of milliseconds before proceeding with the next executable statement in COBOL. Do we have any keyword in COBOL which contains the above mentioned functionality. |
I believe its not possible in Cobol.
Correct me if I am wrong.....
Regards
Rupesh |
|
Back to top |
|
|
DARAPRADEEP
New User
Joined: 13 Apr 2005 Posts: 7
|
|
|
|
hi,
I think we don't have any command like sleep or wait.
We can use a simple loop to get delay in the process.
Thanks,
pradeep. |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Wouldn't it be a better idea coding some Dummy statements, rather than putting a halt with WAIT or SLEEP.
Just like if it is a DB2 progarm, COMMIT can be used for a good passtime.
Regards,
Priyesh. |
|
Back to top |
|
|
subhadeep_infy
New User
Joined: 06 Mar 2006 Posts: 10
|
|
|
|
Hi,
If we process the WAIT functionality by moving in a loop, we won't be able to wait for a specified period say 250 milliseconds. Also this will consume CPU time.
For my requirement, I'll be passing the waiting time thru the JCL to the program, which will wait for that particular time if a SQL query returns -904( resource unvailable). Once the waiting period is over, it'll again fire the same query.
If this is not possible in COBOL, then can anyone tell me whether this can be done in DB2 or not?
Thanks,
Subhadeep |
|
Back to top |
|
|
lordholnapult Currently Banned New User
Joined: 01 Feb 2006 Posts: 5 Location: Italy
|
|
|
|
Often, waiting for a while is a lazy method to omit the research of an information that your procedure require. More often , this became an unsuccessfull execution of your program in random moments... and this is hard to DEBUG. I suggest to you to get TRUE information from your procedure, and then obtain stable programs.
Anyway, you also can access and test the system time , making some calculation in a "PERFORM UNTIL" statement :
USE:
Code: |
ACCEPT TIME-TODAY FROM TIME. |
( The current time is transferred into variable TIME-TODAY -
If the time were exactly 1:45 P.M., it would contain: 13450000.)
Code: |
ACCEPT TIME-TODAY FROM TIME.
** 10 SECONDS waiting:
PERFORM UNTIL DELTATIME <= 00001000
ACCEPT TIME-TODAY-2 FROM TIME
COMPUTE DELTATIME = (TIME-TODAY-2 - TIME-TODAY)
END-PERFORM.
|
Warning about day change error.. you could obtain TIME-TODAY = 23590000
and TIME-TODAY-2 = 00010000
in this case you should add to time-today-2 a day number : 24000000 .
The control to obtain the day is:
Code: |
ACCEPT DAT-TODAY FROM DATE. |
(The current date is transferred into variable DAT-TODAY -
If the date were APRIL 7, 1994,
DAT-TODAY would contain: 940407.) |
|
Back to top |
|
|
lordholnapult Currently Banned New User
Joined: 01 Feb 2006 Posts: 5 Location: Italy
|
|
|
|
Excuse the PERFORM error....
Code: |
*** ERRATA CORRIGE:
01 DAT-TODAY PIC 9(8).
01 DAT-TODAY2 PIC 9(8).
01 TIME-TODAY PIC 9(8).
01 TIME-TODAY2 PIC 9(8).
01 WRK-ONE-DAY PIC 9(8).
01 DELTA-TIME PIC 9(8).
ACCEPT DAT-TODAY FROM DATE.
ACCEPT TIME-TODAY FROM TIME.
MOVE 0 TO WRK-ONE-DAY.
**** 10,00 SECONDS WAITING:
PERFORM UNTIL DELTATIME > 00001000
ACCEPT DAT-TODAY2 FROM DATE
IF DAT-TODAY2 > DAT-TODAY
MOVE 24000000 TO WRK-ONE-DAY
END-IF
ACCEPT TIME-TODAY-2 FROM TIME
COMPUTE DELTATIME = (TIME-TODAY-2 + WRK-ONE-DAY - TIME-TODAY)
END-PERFORM. |
|
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Subhadeep,
There is no way in COBOL, and I don't know anyway in DB2 to accomplish this. And I agree with you that using a loop to wait is a horrible waste of resources. You program will consume 100% of the CPU while waiting. You should ask your Systems Programmer(s) if there are any subroutines that you can use to accomplish the wait. This is a simple task in Assembler without looping. If there is none available, maybe they can write one for you.
Dave |
|
Back to top |
|
|
subhadeep_infy
New User
Joined: 06 Mar 2006 Posts: 10
|
|
|
|
Thanks everyone for all your suggestions.
Regards,
Subhadeep |
|
Back to top |
|
|
subhadeep_infy
New User
Joined: 06 Mar 2006 Posts: 10
|
|
|
|
The above functionality can also be attained by calling the IBM utility 'ILBOWAT0' in the COBOL program by supplying the delay time which can range from 0001 to 9999999 seconds. e.g.
CALL 'ILBOWAT0' USING DELAY-AMT.
The benefit of this routine is that it uses minimal CPU time during the wait/sleep period.
Regards,
Subhadeep |
|
Back to top |
|
|
|