Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Time Wait in COBOL program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Time Wait in COBOL program
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: 464

PostPosted: Fri Mar 24, 2006 2:43 pm    Post subject: Re: Time Wait in COBOL program
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    Post subject: Re: Time Wait in COBOL program
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: 1452
Location: Chicago, IL

PostPosted: Fri Mar 24, 2006 3:30 pm    Post subject: Re: Time Wait in COBOL program
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    Post subject: Re: Time Wait in COBOL program
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    Post subject:
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    Post subject:
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    Post subject: Re: Time Wait in COBOL program
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    Post subject: Re: Time Wait in COBOL program
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    Post subject: Re: Time Wait in COBOL program
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts DSNACCOX (can it be run on 1 db/ts, t... SRICOBSAS DB2 3 Sat May 06, 2017 12:59 am
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us