project BLF > class Database Component > method PartialSetSTables
Description
Method to set a dataset in the t_s temp-tables, based on a dataset-handle as input.
This is a variation of the SetSTables method, in the sense that it accepts a dataset as input that has an incomplete structure. Some fields might be missing from the dataset that is sent in.
If fields are missing from the input, the value in the t_s buffer will be the unknown value (?). It is the intention that in the rest of the flow of processing the data, these fields are treated separately, to make sure the original value of the changed record is not overwritten with the unknown value.
Parameters
izDatasetHandle | input | dataset-handle | The input parameter holding a handle to the dataset with the input values. This must always be a subset of the official object dataset. It might have missing fields. |
ilIsPartialUpdate | input | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
QadFinancials
program code (program1/database.p)
<M-1 run DataDescription
(input '' (icRowids),
input '' (icPkey),
input '' (icObjectIds),
input true (ilAllTables),
output viFcReturnSuper (oiReturnStatus)) in database>
assign vcForceDeleteRowids = "".
create query vhQuery in widget-pool "non-persistent".
vhQuery:forward-only = yes.
do viFcCount1 = 1 to izDatasetHandle:Num-buffers:
vhBuf = izDatasetHandle:Get-buffer-handle(viFcCount1).
vhQuery:Set-buffers(vhBuf).
vhQuery:Query-prepare("for each " + vhBuf:Name).
vcName = substring(vhBuf:Name,2,-1,"CHARACTER":U).
if vcName = "Contextinfo" then next.
find first tFcDynRel where tFcDynRel.tcFcTo = vcName no-error.
if not available tFcDynRel
then do:
oiReturnStatus = -3.
<M-2 run SetMessage
(input #T-3'Unknown table ($1) in input.':255(998716595)T-3# (icMessage),
input vcName (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-227':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in database>
delete object vhQuery.
assign vhQuery = ?.
return.
end.
vhQuery:Query-open().
REPEAT on error undo, throw:
vhQuery:GET-NEXT().
IF vhQuery:QUERY-OFF-END THEN LEAVE.
tFcDynRel.thFcSBuffer:buffer-create().
tFcDynRel.thFcSBuffer:buffer-copy (vhBuf).
/* BLF-3119 avoid duplicate values when method DataLoadByInput replaces tc_Rowid and tc_ParentRowid */
if tFcDynRel.thFcSBuffer::tc_Rowid <> ""
then tFcDynRel.thFcSBuffer::tc_Rowid = "++" + vhBuf::tc_Rowid.
if tFcDynRel.thFcSBuffer::tc_ParentRowid <> ""
then tFcDynRel.thFcSBuffer::tc_ParentRowid = "++" + vhBuf::tc_ParentRowid.
if ilIsPartialUpdate
then do:
/* ========================================================================================================= */
/* Copy the partial input to the S buffer - replacement of tFcDynRel.thFcSBuffer:buffer-copy(vhBuf). */
/* First, record the records where the tc_status = "D" in the input. */
assign vhFieldHandle = vhBuf:buffer-field("tc_status") no-error.
if valid-handle(vhFieldHandle) and vhFieldHandle:buffer-value = "D"
then assign vcForceDeleteRowids = vcForceDeleteRowids + "," + string(tFcDynRel.thFcSBuffer:rowid).
/* Then, preprocess to check for unknown values or unspecified fields, and list them in vcNeglectableFields. */
/* Fields that are not specified get a value of ? (unknown value) */
do viCnt = tFcDynRel.thFcSBuffer:num-fields to 1 by -1:
assign vcBufFieldName = tFcDynRel.thFcSBuffer:buffer-field(viCnt):name.
assign vhFieldHandle = vhBuf:buffer-field(vcBufFieldName) no-error.
if not valid-handle (vhFieldHandle)
then tFcDynRel.thFcSBuffer:buffer-field(vcBufFieldName):buffer-value = ?.
end.
/* ========================================================================================================= */
end.
tFcDynRel.thFcSBuffer:buffer-release().
END.
vhQuery:Query-close().
end.
finally:
if vhQuery <> ? then delete object vhQuery.
end finally.