Sleep

Syntax

SLEEP { expression | UNTIL { WAKEUP | WOKEN } 
ENDAFTER expression } [NOCOMMIT]

Parameters

Sleep can be abbreviated as SLP.

 Caution

Use of the NoCommit command option can severely degrade other system processing, due to the increased level of resource locking.

This command option is restricted to OLTP applications.

Description

The Sleep logic command commits any current database transaction and suspends execution of a report. When reactivated, execution resumes from the next logic command in the method.

If the Glb.Close built-in segment attribute is set to CLOSE when a Sleep logic statement is executed, the report goes to end-of-job.

Set Glb.Close to CLOSE for a report by uisng the Report Attempt Closedown command for the running report.

If the report has started an OLTP global transaction, the Sleep logic command commits and completes the transaction, and commences a new global transaction. This ensures that the required recovery information is stored in the appropriate databases.

Following the Sleep logic command, a new database transaction (thread) is started. On MCP-based systems, this occurs on the first database update following the Sleep command.

Note: The Sleep logic command is for use in Reports only. The use of this command in Ispecs and Messengers is invalid or is ignored.

ROC Reports

In standard ROC reports, it is recommended that the CriticalPoint logic command be used instead of the Sleep 0 logic command variant. This is because although the Sleep 0 logic command variant causes a user database commit, all ROC standard report output might not have been written to the appropriate structures in the ROC database (as it is with the CriticalPoint logic command). This is due to the separation of transaction activities performed by the report on the ROC database from the user database. Refer to CriticalPoint Recovery. Recovery of the output cannot therefore be fully guaranteed. In addition, the values of segment attributes are not recovered.

Restrictions

The following restrictions apply to use of the Sleep logic command:

Examples

Example 1

In this example, the report is suspended for 30 seconds every time Frame03 is printed.

Loop
      Determine Actual PrintInv
      Frame03.Print()
      End
      Sleep 30
      If Glb.Close = "CLOSE"       : Closedown logic
          Advance 5
          Frame05.Print()              : Heading
          Frame07.Print()              : Invoice summary
          Break All
      End
End

Example 2

In this example, the report is suspended until the ispec sends a Wake logic statement.

Loop
      Sleep Until Woken
      If Glb.Close = Glb.Spaces
            Determine From Event.Sales (Cust.Customer, Glb.Zeros)
                 :  Logic
            End
      End
End