Kbase P128526: How to code the OffEnd event for ProBindingSource?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  23/08/2010 |
|
Status: Verified
GOAL:
How to code the OffEnd event for ProBindingSource?
GOAL:
How to use BATCHING and BATCH-SIZE attributes in the OffEnd event
GOAL:
Sample code for binding source
FACT(s) (Environment):
Windows
OpenEdge 10.2x
FIX:
Each time a batch of records is retrieved, the code has to:
- add the records to the current result set.
- set the RowsAdded property for the OffEndEventArgs object to the number of records added to the result set (that is, the number of records retrieved in the most recent batch)
- once all of the records are retrieved, the BATCHING property must be set to FALSE.
The following piece of code assumes that the binding source uses batches, batch size is not 0 and all variables and structures are defined. The code is just an example; there are other ways to add records to a dataset (for example, the FILL method). The Customer temp-table is populated locally; in distributed environment the CustOffEnd procedure would call logic on the AppServer to get next batch.
...
ASSIGN
hBuffTTCust:BATCH-SIZE = 30
rCustBindS:BATCHING = TRUE.
rCustBindS:OffEnd:SUBSCRIBE("CustOffEnd").
...
PROCEDURE CustOffEnd:
DEFINE INPUT PARAMETER rSender AS Progress.Data.BindingSource NO-UNDO.
DEFINE INPUT PARAMETER rArgs AS Progress.Data.OffEndEventArgs NO-UNDO.
DEFINE VARIABLE iRowsAdded AS INTEGER NO-UNDO.
DEFINE VARIABLE doneReading AS LOGICAL NO-UNDO INITIAL FALSE.
DEFINE VARIABLE iBatchSize AS INTEGER NO-UNDO.
DEFINE VARIABLE iCustNum AS INTEGER NO-UNDO.
FIND last ttCustomer NO-LOCK NO-ERROR.
ASSIGN
iCustNum = ttCustomer.CustNum
rargs:RowsAdded = 0.
FIND FIRST Customer WHERE Customer.custNum = iCustNum NO-LOCK NO-ERROR.
DO WHILE rargs:RowsAdded < hBufTTCust:BATCH-SIZE :
FIND NEXT customer NO-LOCK NO-ERROR.
IF AVAILABLE customer THEN DO:
CREATE ttCustomer.
BUFFER-COPY customer TO ttCustomer.
rargs:RowsAdded = rargs:RowsAdded + 1.
iCustNum = Customer.custnum.
END.
ELSE DO: /* next customer is not available - All records read */
rCustBindS:Batching = FALSE.
RETURN.
END.
END. /* Do while */
hCustQry:QUERY-OPEN().
DELETE OBJECt rArgs.
END PROCEDURE.