E
Elaine Rosenberg
Guest
Here are code snippets from the Advanced ABL course that also shows batching on the server side. The dataset, dsDealer has a ttDealer parent and ttCar child. client side: method public void FetchBatchCarData(input piBatchSize as integer): define variable NextRow as integer no-undo initial 1. define variable Done as logical no-undo initial no. dataset dsDealer:empty-dataset(). do while not Done: dsAdapter:FetchBatchCarData(piBatchSize, NextRow , output Done, output dataset dsDealer by-reference). NextRow = NextRow + piBatchSize. end. OpenQuery(). end method. server side business entity: method public void FetchBatchCarData( input piBatchSize as integer, input piNextRow as integer, output pDone as logical, output hdsDealer as handle): /* we will only batch cars as we have a lot of cars */ DA:BatchFillCars(input piBatchSize, input piNextRow, output pDone, output dataset dsDealer by-reference). hdsDealer = dataset dsDealer:handle. return. end method. server side data access class: method public void BatchFillCars (input piBatchSize as integer, input piNextRow as integer, output pDone as logical, output dataset dsDealer): CarDS:Attach(buffer ttCar:handle). DealerDS:Attach(buffer ttDealer:handle). buffer ttCar:batch-size=piBatchSize. CarDS:SetNextRow(piNextRow). /* get a batch of records from the ttCar table */ dataset dsDealer:fill(). find first ttCar no-error. if not available ttCar then pDone = true. else pDone = false. CarDS
etach(buffer ttCar:handle). DealerDS
etach(buffer ttDealer:handle). /* remove ttDealer records if this is the second or later batch we do not want to send ttDealer records again */ if piNextRow > piBatchSize then for each ttDealer: delete ttDealer. end. end method.
Continue reading...
Continue reading...