Syntax
SLEEP { expression | UNTIL { WAKEUP | WOKEN } ENDAFTER expression } [NOCOMMIT]
Parameters
Sleep can be abbreviated as SLP.
expression
Specifies the time to suspend the report. Time can be specified as number of seconds, as an attribute with numeric value ranging from 0 through 9999, or any numeric expression. The report is suspended until explicitly reactivated using a Wake logic statement, or the specified number of seconds has elapsed.
UNTIL (WAKEUP or WOKEN)
Suspends the report until explicitly reactivated using a Wake logic statement, or termination of the report. It is equivalent to the Sleep 60 logic command variant.
ENDAFTER expression
Suspends the report until explicitly reactivated using a Wake logic statement, or termination of the report, or until the number of seconds (in the range 0 through 9999) specified has elapsed.
If the report is reactivated after the specified number of seconds has elapsed, the Glb.Close built-in segment attribute is also set to CLOSE.
NOCOMMIT
Used in conjunction with OLTP global transaction processing (that is, with two-phase commit). The global transaction is not commited and completed. Any locked resources remain locked both during and after this Sleep logic command.
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:
In reports generated as a coroutine, the Sleep Until WakeUp or Sleep Until Woken logic command variant performs an end transaction only. Refer to External Classes for more information on coroutines.
It is not valid in reports that contain CriticalPoint logic commands. However, the CriticalPoint logic command does have its own Sleep command option.
It cannot be relied upon, in certain multi-user environments, to overcome the limitation set by network lock parameters that control the number of record locks for each workstation and the total number of record locks.
In these cases the record locks are independent of any Sleep logic statement. For reports that are required to process large numbers of records it is recommended that the input files should be split into smaller files, each of which contains fewer records than the maximum number of locks as determined by the network configuration. The report should then be run for each input file.
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