project QadFinancials > class BSharedSetMerge > method MergeValidateCompareProfileData

Description

This method checks compatibility of referenced through profile data.


Parameters


icKeyValueinputcharacter
ilIsReportDetailsinputlogical
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BSharedSetMerge.MergeValidateCompare


program code (program6/bsharedsetmerge.p)

/* =================================================================================================== */
/* Method      : MergeValidateCompareRefProfData                                                       */
/* Desc        : Compare profile referenced data of master and redundant element of the shared set     */
/*               Example of the check that has to be done during merge of debtors. For every profile   */
/*               field value this check has to be done.                                                */
/*                                                                                                     */
/*               For each  DebtorRS where                                                              */
/*                         DebtorRS.SharedSet_ID = DebtorRedundantSharedSet,                           */
/*               first ProfileRS where                                                                 */
/*                     ProfileRS.Profile_ID = DebtorRS.SalesAccountProfile_ID,                         */
/*               Each  ProfileLinkRS where                                                             */
/*                     ProfileLinkRS.Profile_ID           =  ProfileRS.Profile_ID and                  */
/*                     ProfileLinkRS.ProfileLinkObject_ID <> 0                  and                    */
/*                     ProfileLinkRS.ProfileLinkObject_ID <> ?,                                        */
/*               First GLRS where                                                                      */
/*                     GLRS.GL_ID = ProfileLinkRS.ProfileLinkObject_ID,                                */
/*               Each  DebtorMS where                                                                  */
/*                     DebtorMS.SharedSet_ID = DebtorMasterSharedSet and                               */
/*                     DebtorMS.DebtorCode   = DebtorRS.DebtorCode,                                    */
/*               First ProfileMS where                                                                 */
/*                     ProfileMS.Profile_ID =  DebtorMS.SalesAccountProfile_ID,                        */
/*               Each  ProfileLinkMS where                                                             */
/*                     ProfileLinkMS.Profile_ID           = ProfileMS.Profile_ID       and             */
/*                     ProfileLinkMS.ProfileLinkObject_ID <> 0                         and             */
/*                     ProfileLinkMS.ProfileLinkObject_ID <> ?,                                        */
/*               First GLMS where                                                                      */
/*                     GLMS.GL_ID        = ProfileLinkMS.ProfileLinkObject_ID and                      */
/*                     GLMS.SharedSet_ID = GLRS.SharedSet_ID                                           */
/*                     GLMS.GLCode      <> GLRS.GLCode                                                 */
/*                                                                                                     */
/* --------------------------------------------------------------------------------------------------- */
/* Params:  (I)  vcKeyValue           Natural key of the compared values                               */
/*          (O)  Name                 Description                                                      */
/* =================================================================================================== */

assign oiReturnStatus = -98.

/* =================================================================================================== */
/* Find parent record with errors                                                                      */
/* =================================================================================================== */
find bSharedSetMergeValResWarn where
     bSharedSetMergeValResWarn.tcInfoType = {&SHAREDSETMERGE-INFOTYPE-WARN} no-error.

if not available bSharedSetMergeValResWarn
then do:
    assign vcMessage = #T-2'Cannot find resulting record with number of errors during validation.':255(64006)T-2#
           vcContext = 'InfoValue=&1':U
           vcContext = substitute(vcContext, {&SHAREDSETMERGE-INFOTYPE-ERROR})
           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-6632':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  vcContext (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BSharedSetMerge>
    assign oiReturnStatus = -1.
    return.
end.


/* =================================================================================================== */
/* Get all profiles which has different definition in master and redundant shared set                  */
/* =================================================================================================== */
for each tProfileSharedSetData where
         tProfileSharedSetData.tcKeyValue          = icKeyValue and
         tProfileSharedSetData.tcMasterFieldValue <> tProfileSharedSetData.tcRedundantFieldValue:
    
    /* increase counters */
    assign bSharedSetMergeValResWarn.tiInfoValue = bSharedSetMergeValResWarn.tiInfoValue + 1.

    /* create details about */
    if ilIsReportDetails
    then do:
        create tSharedSetMergeValResDet.
        assign tSharedSetMergeValResDet.tcFieldName           = tProfileSharedSetData.tcFieldName
               tSharedSetMergeValResDet.tcKeyValue            = tProfileSharedSetData.tcKeyValue
               tSharedSetMergeValResDet.tcMasterFieldValue    = substitute("&1 -> &2":U, 
                                                                           tProfileSharedSetData.tcProfileCode,
                                                                           tProfileSharedSetData.tcMasterFieldValue)
               tSharedSetMergeValResDet.tcRedundantFieldValue = substitute("&1 -> &2":U, 
                                                                           tProfileSharedSetData.tcProfileCode,
                                                                           tProfileSharedSetData.tcRedundantFieldValue)
               tSharedSetMergeValResDet.tc_ParentRowid        = bSharedSetMergeValResWarn.tc_Rowid
               viValidateResultDetailCount                    = viValidateResultDetailCount + 1
               tSharedSetMergeValResDet.tc_Rowid              = string(viValidateResultDetailCount).
    end.
end.

/* =================================================================================================== */
/* Get all conflicts with definition of profiles                                                       */
/* =================================================================================================== */
for each tRedundantProfileSharedSetData where
         tRedundantProfileSharedSetData.tcKeyValue = icKeyValue,
    each tMasterProfileSharedSetData where
         tMasterProfileSharedSetData.tcKeyValue                 = tRedundantProfileSharedSetData.tcKeyValue                 and
         tMasterProfileSharedSetData.tiProfileTargetSharedSetId = tRedundantProfileSharedSetData.tiProfileTargetSharedSetId and
         tMasterProfileSharedSetData.tcFieldName                = tRedundantProfileSharedSetData.tcFieldName                and
         tMasterProfileSharedSetData.tcProfileTargetKeyValue   <> tRedundantProfileSharedSetData.tcProfileTargetKeyValue:

    /* increase counters */
    assign bSharedSetMergeValResWarn.tiInfoValue = bSharedSetMergeValResWarn.tiInfoValue + 1.

    /* create details about */
    if ilIsReportDetails
    then do:
        create tSharedSetMergeValResDet.
        assign tSharedSetMergeValResDet.tcFieldName           = tRedundantProfileSharedSetData.tcFieldName
               tSharedSetMergeValResDet.tcKeyValue            = tRedundantProfileSharedSetData.tcKeyValue
               tSharedSetMergeValResDet.tcMasterFieldValue    = substitute("&1 -> &2":U, 
                                                                           tMasterProfileSharedSetData.tcProfileCode,
                                                                           tMasterProfileSharedSetData.tcProfileTargetKeyValue)
               tSharedSetMergeValResDet.tcRedundantFieldValue = substitute("&1 -> &2":U, 
                                                                           tRedundantProfileSharedSetData.tcProfileCode,
                                                                           tRedundantProfileSharedSetData.tcProfileTargetKeyValue)
               tSharedSetMergeValResDet.tc_ParentRowid        = bSharedSetMergeValResWarn.tc_Rowid
               viValidateResultDetailCount                    = viValidateResultDetailCount + 1
               tSharedSetMergeValResDet.tc_Rowid              = string(viValidateResultDetailCount).
    end.
end.

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