Skip to main content

Can a Cobol program be put into a wait state?

  • February 15, 2013
  • 0 replies
  • 3 views

Problem:

We have a need to add a delay into our PC testing of an application using Mainframe Express and MQSeries. Is there a way to have Cobol wait for some specified amount of time?

Resolution:

IBM still supplies an old TCAM wait state interface (ILBOWAT) in LE (Language Environment) for Cobol programs running on z/OS, but on the PC we do not have a direct equivalent. Micro Focus provides several means of causing a delay. Here is a sample program that can be used in Mainframe Express with a Non-mainframe dialect.   

      $set mf align(2)

       identification division.

       program-id.  LORINCE.

      * This program requests a WAIT

       environment division.

       data division.

       working-storage section.

       1   current-time      pic xx comp-5.

       1   start-time        pic xx comp-5.

       1   clock.

        2  date-i.

         3  d-yyyy           pic 9(4).

         3  d-mm             pic 9(2).

         3  d-dd             pic 9(2).

        2  work-time         pic 9(8).

        2  time-parts  redefines  work-time.

         3 time-hh           pic 9(2).

         3 time-mm           pic 9(2).

         3 time-ss           pic 9(2).

         3 time-cc           pic 9(2).

       1   work-vars.

        2  second-count      pic xx comp-5.

        2  thread-cnt        pic x(4) comp-5.

           66  time-count  renames  second-count.

       procedure division.

       p1.

      * start time

           accept date-i from date yyyymmdd

           accept work-time from time

           compute start-time =

                   time-hh * 360000

                   time-mm * 6000

                   time-ss * 100

                   time-cc

           display ' Today''s Date  = ' date-i

           display ' Starting Time = ' start-time

           move 0 to time-count

      * time in milliseconds using field or value

      *    move 6000 to thread-cnt

      *    call 'cbl_thread_sleep' using thread-cnt

      *    call 'cbl_thread_sleep' using by value 9999

           call 'cbl_thread_sleep' using by value 6000

      * end of time count comments

           accept work-time from time

           compute current-time =

                   time-hh * 360000

                   time-mm * 6000

                   time-ss * 100

                   time-cc

           display ' Ending Time   = ' current-time

           compute time-count = current-time - start-time

           display ' Elapsed Time  = ' time-count

           stop run.

Old KB# 2543

#MFDS
#EnterpriseDeveloper