icRowids | input | character | Comma seperated list of rowids of records of the main table, converted to string format. |
icPkeys | input | character | List of the values of the primary key fields of records of the main table. Fields are chr(2) seperated, keys are chr(4) seperated. Fields are listed in the order as they appear in the primary index. You are not obliged to give a value for all fields of the primary index, but the list cannot contain any 'gaps'. |
icObjectIds | input | character | Comma seperated list of values of the identity field of records of the main table. |
icFreeform | input | character | In case none of the standard keys (primary, rowid, identity) are available, you can load data based on a freeform for each statement on the main table of the business class. This for each statement should not contain break by, sorting or no-lock options. |
ilKeepPrevious | input | logical | True if the data to load must be added to the already existing data in the class temp-tables. False if the data to load must replace the already existing data. |
oiReturnStatus | output | integer |
/* ========================================== */ /* Set class-data-item based upon input param */ /* ========================================== */ assign vlDataLoadKeepPrevious = ilKeepPrevious. /* ============================================================= */ /* Start by clearing the instance when input param requests this */ /* ============================================================= */ if ilKeepPrevious = no then do: /* Empty all generated temp-tables */ <M-8 run ClearData (output viFcReturnSuper (oiReturnStatus)) in database> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then return. end. /* if ilKeepPrevious = no */ /* ========================================== */ /* Load the temp-table tFcDynRel */ /* ========================================== */ <M-79 run DataDescription (input icRowids (icRowids), input icPkeys (icPkey), input icObjectIds (icObjectIds), input no (ilAllTables), output viFcReturnSuper (oiReturnStatus)) in database> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then return. if (icRowids = "" or icRowids = ?) and (icPkeys = "" or icPkeys = ?) and (icObjectIds = "" or icObjectIds = ?) and icFreeform <> "" and icFreeform <> ? then do: find first tFcDynRel where tFcDynRel.tcFcFrom = "" no-error. if available tFcDynRel then assign tFcDynRel.tcFcRel = icFreeform. end. /* if (icRowids = "" or icRowids = ?) and */ /* =================================== */ /* Load the generated temp-tables t<x> */ /* =================================== */ <M-6 run StartPersistence (output vhFcComponent (ohPersistence), output viFcReturnSuper (oiReturnStatus)) in database> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then return. <M-7 run ReadData (input tFcDynRel (tDynRel), input {&TARGETPROCEDURE} (ihClass), output viFcReturnSuper (oiReturnStatus)) in persistence> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then return. /* ====================================================================== */ /* Set class-data-item vlFcDataValidated to false as we have now loaded */ /* (additional) data into the instance and this data is not validated yet */ /* ====================================================================== */ assign vlFcDataValidated = false. /* ======================== */ /* Execute Calculate method */ /* ======================== */ if not vlDataLoadSkipCalculate then do : <M-5 run Calculate (output viFcReturnSuper (oiReturnStatus)) in database> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then return. /* If we are keeping the previously loaded instances then register the rowids of the new read records as passed the calculate-method */ if ilKeepPrevious then do: <M-10 run DataDescription (input icRowids (icRowids), input icPkeys (icPkey), input icObjectIds (icObjectIds), input yes (ilAllTables), output viFcReturnSuper (oiReturnStatus)) in database> for each tFcDynRel on error undo, throw: create query vhQuery in widget-pool "non-persistent". vhQuery:forward-only = yes. vhQuery:set-buffers(tFcDynRel.thFcBuffer). vhQuery:query-prepare ("for each ":U + tFcDynRel.thFcBuffer:name). vhQuery:query-open(). vhQuery:get-first(). do while not vhQuery:query-off-end: if not can-find (tAlreadyCalculatedRecords where tAlreadyCalculatedRecords.tcTableName = tFcDynRel.tcFcTo and tAlreadyCalculatedRecords.tc_Rowid = tFcDynRel.thFcBuffer::tc_Rowid) then do: create tAlreadyCalculatedRecords. assign tAlreadyCalculatedRecords.tcTableName = tFcDynRel.tcFcTo tAlreadyCalculatedRecords.tc_Rowid = tFcDynRel.thFcBuffer::tc_Rowid. end. /* if not can-find */ vhQuery:get-next(). end. /* do while not vhQuery:query-off-end: */ vhQuery:query-close(). delete object vhQuery. assign vhQuery = ?. end. /* for each tFcDynRel on error undo, throw: */ end. /* if ilKeepPrevious */ end. /* if not vlDataLoadSkipCalculate */ finally: if vhQuery <> ? then delete object vhQuery. end finally.