project QadFinancials > class BSharedSetMerge > method MergeValidateRuleValidateAndUpdate
Description
This method compares content of temporary table with shared set data to be compared and definition of validation rules.
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bsharedsetmerge.p)
/* =================================================================================================== */
/* Method : MergeValidateRuleValidateAndUpdate */
/* Desc : This method compares content of temporary table with shared set data to be compared */
/* and definition of validation rules. */
/* --------------------------------------------------------------------------------------------------- */
/* Params: (H) MergeValidateTable Definiton of tables to be validated */
/* (H) MergeValidateField Definition of fields of tables with field's rules */
/* (H) MergeSharedSetData Array of handles of temporary tables with content of shared set*/
/* =================================================================================================== */
assign oiReturnStatus = -98.
/* =================================================================================================== */
/* Validate input parameters */
/* =================================================================================================== */
if not can-find(first tMergeValidateTable) or
not can-find(first tMergeValidateField)
then do:
assign vcMessage = #T-1'Some mandatory parameters have not been passed to method GetSharedSetMergeRules.':255(63722)t-1#
vcContext = 'tMergeValidateTable=&1|tMergeValidateField=&2':U
vcContext = substitute(vcContext, can-find(first tMergeValidateTable), can-find(first tMergeValidateField))
vcContext = replace(vcContext, '|':U, chr(2)).
<M-2 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-6555':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BSharedSetMerge>
assign oiReturnStatus = -1.
return.
end.
/* =================================================================================================== */
/* Validate, whether all fields retrieved from definition table are really presented in temporary */
/* table to be compared */
/* =================================================================================================== */
for each tMergeValidateTable:
assign viIndex = integer(tMergeValidateTable.tc_Rowid)
vhTableHandle = vhMasterSharedSetData[viIndex]
vhBuf = vhTableHandle:default-buffer-handle.
for each tMergeValidateField where
tMergeValidateField.tc_ParentRowid = tMergeValidateTable.tc_Rowid:
assign vhFld = vhBuf:buffer-field(tMergeValidateField.tcFieldName).
if vhFld = ? or
not valid-handle (vhFld)
then do:
assign vcMessage = #T-5'The definition of validation rules for fields for merge and the structure of data to be compared do not match.':255(63723)t-5#
vcContext = 'tMergeValidateField.tcFieldName=&1':U
vcContext = substitute(vcContext, tMergeValidateField.tcFieldName).
<M-4 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-6556':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BSharedSetMerge>
assign oiReturnStatus = -1.
return.
end.
end.
end. /* foreach tMergeValidateTable: */
/* =================================================================================================== */
/* Definitional file for validation of shared set does not contain all fields. It contains mainly */
/* ID, Key and Mandatory fields. All other fiels are or non-mandatory or technical and records for */
/* are created dynamically */
/* =================================================================================================== */
for each tMergeValidateTable:
assign viIndex = integer(tMergeValidateTable.tc_Rowid)
vhTableHandle = vhMasterSharedSetData[viIndex]
vhBuf = vhTableHandle:default-buffer-handle.
do viFieldIndex = 1 to vhBuf:num-fields:
assign vhFld = vhBuf:buffer-field(viFieldIndex)
vcFldName = vhFld:name.
if not can-find(tMergeValidateField where
tMergeValidateField.tcFieldName = vcFldName and
tMergeValidateField.tc_ParentRowid = tMergeValidateTable.tc_Rowid)
then do:
/* Create new validation rule for field */
create tMergeValidateField.
assign tMergeValidateField.tcFieldName = vcFldName
tMergeValidateField.tlIsBlankAllowed = false
tMergeValidateField.tc_ParentRowid = tMergeValidateTable.tc_Rowid.
/* Is this one of the technical fields */
if can-do('tc_RowID,tc_ParentRowID,tc_Status,LastModifiedDate,LastModifiedTime,LastModifiedUser':U, vcFldName) or
index( vcFldName, 'SharedSet_ID':U) <> 0
then assign tMergeValidateField.tiMergeType = {&SHAREDSETMERGE-FIELDTYPE-TECHNICAL}.
else assign tMergeValidateField.tiMergeType = {&SHAREDSETMERGE-FIELDTYPE-NON-MANDATORY}.
end.
end.
end. /* for each tMergeValidateTable: */
/* =================================================================================================== */
/* Return */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.