IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Time Wait in COBOL program


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
subhadeep_infy

New User


Joined: 06 Mar 2006
Posts: 10

PostPosted: Fri Mar 24, 2006 12:27 pm
Reply with quote

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
View user's profile Send private message
Rupesh.Kothari

Member of the Month


Joined: 27 Apr 2005
Posts: 463

PostPosted: Fri Mar 24, 2006 2:43 pm
Reply with quote

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
View user's profile Send private message
DARAPRADEEP

New User


Joined: 13 Apr 2005
Posts: 7

PostPosted: Fri Mar 24, 2006 3:08 pm
Reply with quote

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
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Fri Mar 24, 2006 3:30 pm
Reply with quote

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
View user's profile Send private message
subhadeep_infy

New User


Joined: 06 Mar 2006
Posts: 10

PostPosted: Fri Mar 24, 2006 4:17 pm
Reply with quote

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
View user's profile Send private message
lordholnapult
Currently Banned

New User


Joined: 01 Feb 2006
Posts: 5
Location: Italy

PostPosted: Fri Mar 24, 2006 5:39 pm
Reply with quote

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
View user's profile Send private message
lordholnapult
Currently Banned

New User


Joined: 01 Feb 2006
Posts: 5
Location: Italy

PostPosted: Fri Mar 24, 2006 8:44 pm
Reply with quote

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
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Mon Mar 27, 2006 7:59 am
Reply with quote

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
View user's profile Send private message
subhadeep_infy

New User


Joined: 06 Mar 2006
Posts: 10

PostPosted: Wed Mar 29, 2006 11:44 am
Reply with quote

Thanks everyone for all your suggestions.

Regards,
Subhadeep
Back to top
View user's profile Send private message
subhadeep_infy

New User


Joined: 06 Mar 2006
Posts: 10

PostPosted: Wed Mar 29, 2006 12:47 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top