project QadFinancials > class BSharedSetMerge > method MergeValidateCompareFields

Description

This method compares fiels in corresponding records of shared sets.


Parameters


ihQueryMasterinputhandle
ihQueryRedundantinputhandle
ilIsReportDetailsinputlogical
icKeyValueinputcharacter
olIsContainErroroutputlogical
olIsContainWarningoutputlogical
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BSharedSetMerge.MergeValidateCompare


program code (program6/bsharedsetmerge.p)

/* =================================================================================================== */
/* Method      : MergeValidateCompareFields                                                            */
/* Desc        : This method compares values of mandatory and non-mandatory fields of two records      */
/* --------------------------------------------------------------------------------------------------- */
/* Params:  (I)  ihQueryMaster        Handle to query (master)                                         */
/*          (I)  ihQueryRedundant     Handle to query (redundant)                                      */
/*          (I)  IsReportDetails      Report details about errors and warnings                         */
/*          (I)  KeyValue             Value of key(s) of current records                               */
/*          (O)  IsContainError       Contains these corresponding records Errors in definition        */
/*          (O)  IsContainWarning     Constins these corresponding records Warnings in definition      */
/* =================================================================================================== */

assign oiReturnStatus = -98.

/* =================================================================================================== */
/* Create buffers for validation result - Errors and warnings                                          */
/* =================================================================================================== */
find bSharedSetMergeValResError where
     bSharedSetMergeValResError.tcInfoType = {&SHAREDSETMERGE-INFOTYPE-ERROR}
     no-error.

find bSharedSetMergeValResWarn where
     bSharedSetMergeValResWarn.tcInfoType = {&SHAREDSETMERGE-INFOTYPE-WARN}
     no-error.

if not available bSharedSetMergeValResError or
   not available bSharedSetMergeValResWarn
then do:
    assign vcMessage = #T-2'There is missing definition of overview records for Errors and/or Warnings.':255(64199)T-2#
           vcContext = 'bSharedSetMergeValResError=&1|bSharedSetMergeValResWarn=&2':U
           vcContext = substitute(vcContext, string(available bSharedSetMergeValResError), string(available bSharedSetMergeValResWarn))
           vcContext = replace(vcContext, '|':U, chr(2)).
    <M-1 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-6703':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  vcContext (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BSharedSetMerge>
    
    assign oiReturnStatus = -1.
    return.
end.

/* =================================================================================================== */
/* Go through mandatory and non-mandatory fields                                                       */
/* =================================================================================================== */
assign viBufferIndex     = ihQueryMaster:num-buffers  /* take the last buffer, as it contains data to compare */
       vhBufferMaster    = ihQueryMaster:get-buffer-handle(viBufferIndex)
       vhBufferRedundant = ihQueryRedundant:get-buffer-handle(viBufferIndex).

for each tMergeValidateField where
         tMergeValidateField.tc_ParentRowid = tMergeValidateTable.tc_Rowid and
         (tMergeValidateField.tiMergeType = {&SHAREDSETMERGE-FIELDTYPE-MANDATORY} or
          tMergeValidateField.tiMergeType = {&SHAREDSETMERGE-FIELDTYPE-NON-MANDATORY}):
    
    /* compare values of corresponding fields */
    assign viCompareResult = <M-3 CompareFieldValues
                                (input  vhBufferMaster:buffer-field(tMergeValidateField.tcFieldName) (ihField1), 
                                 input  vhBufferRedundant:buffer-field(tMergeValidateField.tcFieldName) (ihField2), 
                                 input  tMergeValidateField.tcFieldName (icFieldName)) in BSharedSetMerge>.
    
    /* if there is difference, store this in result table */
    if viCompareResult <> 0
    then do:
        assign vcFieldValueMaster    = vhBufferMaster:buffer-field(tMergeValidateField.tcFieldName):string-value()
               vcFieldValueRedundant = vhBufferRedundant:buffer-field(tMergeValidateField.tcFieldName):string-value().
         
        /* if blank is allowed for one of the values and one of the fields is realy blank -> NO error */
        if tMergeValidateField.tlIsBlankAllowed and
           (vcFieldValueMaster    = '':U or vcFieldValueMaster    = '?':U or vcFieldValueMaster    = ? or
            vcFieldValueRedundant = '':U or vcFieldValueRedundant = '?':U or vcFieldValueRedundant = ?)
        then next.
        
        /* increase counters */
        if tMergeValidateField.tiMergeType = {&SHAREDSETMERGE-FIELDTYPE-MANDATORY}
        then assign olIsContainError                       = true
                    bSharedSetMergeValResError.tiInfoValue = bSharedSetMergeValResError.tiInfoValue + 1.
        else assign olIsContainWarning                     = true
                    bSharedSetMergeValResWarn.tiInfoValue  = bSharedSetMergeValResWarn.tiInfoValue  + 1.

        /* create details about */
        if ilIsReportDetails
        then do:
            create tSharedSetMergeValResDet.
            assign tSharedSetMergeValResDet.tcFieldName           = substring(tMergeValidateField.tcFieldName, 3, length(tMergeValidateField.tcFieldName, "CHARACTER") - 2, "CHARACTER")
                   tSharedSetMergeValResDet.tcKeyValue            = icKeyValue
                   tSharedSetMergeValResDet.tcMasterFieldValue    = vcFieldValueMaster
                   tSharedSetMergeValResDet.tcRedundantFieldValue = vcFieldValueRedundant
                   tSharedSetMergeValResDet.tc_ParentRowid        = (if tMergeValidateField.tiMergeType = {&SHAREDSETMERGE-FIELDTYPE-MANDATORY}
                                                                     then bSharedSetMergeValResError.tc_Rowid
                                                                     else bSharedSetMergeValResWarn.tc_Rowid)
                   viValidateResultDetailCount                    = viValidateResultDetailCount + 1
                   tSharedSetMergeValResDet.tc_Rowid              = string(viValidateResultDetailCount).
        end.
    end.
end.

/* =================================================================================================== */
/* Return                                                                                              */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.