Serial

Syntax

SERIAL

The Serial command option can be specified with the ForEach logic command and Determine and LookUp logic command variants to increase the efficiency of profile accesses in copy ispecs and copy events. The Serial command option retains the pointers to the profile when it is first accessed and, on subsequent accesses, simply retrieves the next record without reading through the profile again.

The Serial command option is restricted to use in copy ispecs and copy events. It is ignored in all other classes.

When the Glb.Copy built-in segment attribute is equal to 1, records are retrieved from the point specified in the ForEach, Determine, or LookUp logic statement, until end-of-file is detected or until a Break logic statement is executed. When the Glb.Copy built-in segment attribute is greater than 1, records are retrieved from the last record previously retrieved, and not from the point specified in the ForEach, Determine, or LookUp logic statement.

At end-of-file, the buffer containing the dataset records continues to contain the data values of the last record read. Any subsequent reads do not alter these values. The values from the last record read remain in the database record area it is explicitly cleared.

Since the success of the use of the Serial command option depends upon the setting of the pointer, the same profile should not be accessed elsewhere in the same logic, or results are unpredictable in different runtimes.

The Serial command option must be executed in the first iteration of the copy cycle (when Glb.Copy is equal to 1). Using the Serial command option at other points of the copy cycle, having not used it on the first iteration, will produce unpredictable results.

Examples

Example 1

In this example, an DRInq event has a Glb.Copy value of 4 and a Glb.MaxCopy value of 4. The StartCust variable is used to enter the starting customer. The variables Customer (which has its Link If Present property set to true) and Balance both have their Is Copied property set to true. Part of the logic for DRInq is as follows:

LookUp From StartCust Cust Serial
      Determine Every Event.Debtors (Cust.Customer)
            Balance := Balance + Event.Amount
      End
      Customer := Cust.Customer
      Break
End
Recall

Suppose Cust has records with the following Customer values: "Arnold", "Bruce", "Colleen", "Diane", "Edward", and "Fred". If StartCust is set "Barry", in the first copy cycle iteration, the LookUpFrom logic statement retrieves "Bruce". In the second copy cycle iteration, when Glb.Copy is set to 2, the LookUp From logic statement retrieves "Colleen", and does not re-read Bruce. In the third copy cycle iteration, when Glb.Copy is set to 3, the LookUp From logic statement retrieves "Diane", and does not re-read Bruce and Colleen.

Example 2

This example retrieves the most recent transactions for a specified customer.

Determine Back Event.Recevable (Customer G_Nines Glb.High G_Nines) Serial
If Customer <> Event.Customer
      Break
End
If Glb.Copy = 1
      G_Total := Event.AccBal
End
In_Doc := Event.Document
In_Date := Event.Input_Date
In_Ispec := Event.Ispec
In_ProdNo := Event.Product
In_Amt := Event.Amount
Break
End
Recall