project QadFinancials > class BBusinessRelation > method ValidateComponent

Description

Write here all tests on database update (new / modify / delete) that cannot be coded with a validation mask.
The type of update can be found in tc_status (N/C/D).
If you find incorrect data, you must write an entry in tFcMessages (using SetMessage) and set the return status of this method to either +1 or -1.
Return status +1 = data will still be accepted.
Return status -1 = data will not be accepted.
This method is run from SetPublicTables, before transferring the received data into the class temp-tables.


Parameters


oiReturnStatusoutputinteger


Internal usage


unused


program code (program/bbusinessrelation.p)

/* make sure the MFG Instances are stopped */
<M-46 run StopExternalInstances  (output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>

<M-54 run ValidateComponentPre  (output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
if viFcReturnSuper < 0 
then do:
    assign oiReturnStatus = viFcReturnSuper.    
    return.
end.
if viFcReturnSuper > 0
then assign viLocalReturnStatus = viFcReturnSuper.

<ANCESTOR-CODE>

if oiReturnStatus < 0
then return.
if viLocalReturnStatus > 0
then assign oiReturnStatus = viLocalReturnStatus.

for each t_sBusRelationSafDefault where
         t_sBusRelationSafDefault.tc_ParentRowid = t_sBusinessRelation.tc_Rowid and
        (t_sBusRelationSafDefault.tc_Status = 'N':U or
         t_sBusRelationSafDefault.tc_Status = 'C':U),
     each t_sBusinessRelation where 
          t_sBusinessRelation.tc_Rowid   = t_sBusRelationSafDefault.tc_ParentRowid and
          t_sBusinessRelation.tc_Status <> "D":U :

    if t_sBusRelationSafDefault.Saf_ID = -1
    then assign t_sBusRelationSafDefault.Saf_ID = ?.

    if t_sBusRelationSafDefault.Saf_ID <> 0 and
       t_sBusRelationSafDefault.Saf_ID <> ?
    then do:
        <Q-10 run SafPrim (all) (Read) (Cache)
           (input t_sBusRelationSafDefault.Saf_ID, (SafID)
            input t_sBusRelationSafDefault.tcSafCode, (SafCode)
            input ?, (SafConceptCode)
            output dataset tqSafPrim) in BSaf >
        find first tqSafPrim where
                   tqSafPrim.tcSafCode        = t_sBusRelationSafDefault.tcSafCode and
                   tqSafPrim.tcSafConceptCode = t_sBusRelationSafDefault.tcSafConceptCode
                   no-error.
        if not available tqSafPrim
        then do:
            assign vcMessage = trim(substitute(#T-14'The SAF value &3 does not belong to SAF concept &2 for item &1.':200(846)t-14#, trim(t_sBusinessRelation.BusinessRelationCode), trim(string(t_sBusRelationSafDefault.tcSafConceptCode)), trim(string(t_sBusRelationSafDefault.tcSafCode)))).
             <M-13 run SetMessage
                (input  vcMessage (icMessage), 
                 input  '':U (icArguments), 
                 input  'tBusRelationSafDefault.tcSafCode':U (icFieldName), 
                 input  string(t_sBusRelationSafDefault.tcSafCode) (icFieldValue), 
                 input  'E':U (icType), 
                 input  3 (iiSeverity), 
                 input  t_sBusinessRelation.tc_Rowid (icRowid), 
                 input  'QADFIN-2200':U (icFcMsgNumber), 
                 input  '' (icFcExplanation), 
                 input  '' (icFcIdentification), 
                 input  '' (icFcContext), 
                 output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
            assign oiReturnStatus = -1.
        end.
    end.
end.

<Q-12 run SafPrim  (Stop) in BSaf >

for each t_sBusinessRelation where (t_sBusinessRelation.tc_Status = "N":U or 
                                    t_sBusinessRelation.tc_Status = "C":U):

    if t_sBusinessRelation.BusinessRelationIsTaxRep = true and 
       vlTaxReportValidated                         = false 
    then do:
        <M-19 run ValidateTaxReport
           (input  t_sBusinessRelation.tc_Rowid (icRowID), 
            output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
        assign vlTaxReportValidated = true.
        if oiReturnStatus >= 0 then
            assign oiReturnStatus = viFcReturnSuper.
        
        if t_sBusinessRelation.BusinessRelationNameCtrl = "" then
        do:
            assign vcMessage      =  #T-24'This field has no value':50(17934)T-24#.    
                   oiReturnStatus = -1.
            <M-20 run SetMessage
               (input  vcMessage (icMessage), 
                input  '' (icArguments), 
                input  'Name Control':u (icFieldName), 
                input  '' (icFieldValue), 
                input  'W':U (icType), 
                input  4 (iiSeverity), 
                input  '' (icRowid), 
                input  'QADFIN-4530':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
        end.

    end.

    /* Check BusinessRelationFormat:
       MFG/PRO
                  find first code_mstr  where code_mstr.code_domain = global_domain
            and  code_fldname = "ad_format"
                                   and code_value = string(input ad_format)
       BusinessRelation is System wide -> need to have a domain?????????
     */
end.

/* =========================================================================== *
 * Address validation                                                          *
 * =========================================================================== */
<M-59 run ValidateComponentPostAddress  (output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0) then assign oiReturnStatus = viFcReturnSuper.


/* =========================================================================== *
 * Contact validation                                                          *
 * =========================================================================== */
<M-31 run ValidateComponentContact  (output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0) then assign oiReturnStatus = viFcReturnSuper.


/* =========================================================================== *
 * Stop Format validation component                                            *
 * =========================================================================== */
if valid-handle(vhBFormatSetInst)
then do:
    <I-11 {bFcCloseAndStopInstance
         &CLASS           = "BFormatSet"}>
end.
else if viBFormatSetID <> ? and
        viBFormatSetID <> 0
then do:
    <I-50 {bFcStopInstance
         &CLASS           = "BFormatSet"}>
end.