project QadFinancials > class BCOAValidation > method ValidateCOA

Description

Validate all COA elements


Parameters


tCOAValidationinputtemp-tableTemptable containing the COA elements and combinations
tCOAErrorMessagesoutputtemp-tableError messages from the COA validation
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCOAValidation.APIValidateCOA


program code (program1/bcoavalidation.p)

/* =========================================================== */
/* Validate the COA elements in the input tCOAValidation       */
/* temptable. The validation should validate all of the COA    */
/* elements as if they were being used in a Journal Entry      */
/*     Validate the following                                  */
/*         1. Domain Code is valid                             */
/*         2. Account/Cost Centre/SubAccount/Project is Valid  */
/*         3. Account/Cost Centre/SubAccount/Project is Active */
/*         4. GL analysis limitation                           */
/*         4. GL Mask Validation                               */
/* =========================================================== */

/*================================================================================= */
/* Iterate through the incoming table, batch by domain and company so if            */
/* either are invalidno more transactions in that domain/company are validated      */
/*================================================================================= */   
for each tCOAValidation break by tCOAValidation.tcDomainCode by tCOAValidation.tcCompanyCode
    on error undo, throw:

    assign vlCOAElementError = false.
    
    if first-of(tCOAValidation.tcDomainCode)
    then do:
        assign vlIsValidDomain = false.
        if tCOAValidation.tcDomainCode <> "" or 
            tCOAValidation.tcDomainCode <> ?
        then do:
            <Q-51 run DomainsByCode (all) (Read) (Cache)
               (input ?, (DomainID)
                input tCOAValidation.tcDomainCode, (DomainCode)
                output dataset tqDomainsByCode) in BDomain>
    
            find tqDomainsByCode where
                tqDomainsByCode.tcDomainCode = tCOAValidation.tcDomainCode no-lock no-error.
             
            if available tqDomainsByCode 
            then do:
                if tqDomainsByCode.tlDomainIsActive <> true 
                then do:
                    assign
                        vlIsValidDomain = false
                        vcMessage       = trim(substitute(#T-50'The selected domain is not active':100(31731)T-50#)).
                    create tCOAErrorMessages.
                    assign 
                        tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
                        tCOAErrorMessages.tcErrorMessage   = vcMessage
                        tCOAErrorMessages.tiErrorCode      = -1.
                    /* ==================================================================== */   
                    /* don't do other validation on this line if the domain code is invalid. */   
                    /* ==================================================================== */                       
                    next.  
                end. /*  if tqDomainsByCode.tlDomainIsActive <> true  */
                else 
                    assign vlIsValidDomain = true.
            end. /*  if available tqDomainsByCode */
            else do:
                assign 
                    vcMessage = trim(substitute(#T-22'The domain code &1 cannot be found.':75(31228)T-22#, trim(tCOAValidation.tcDomainCode) )).
                create tCOAErrorMessages.
                assign 
                    tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
                    tCOAErrorMessages.tcErrorMessage   = vcMessage
                    tCOAErrorMessages.tiErrorCode      = -1.
                /* ==================================================================== */ 
                /* don't do other validation on this line if the domain code is invalid. */
                /* ==================================================================== */ 
                next.                 
            end. /* else do */
        end. /*  if tCOAValidation.tcDomainCode <> "" or tCOAValidation.tcDomainCode <> ? */
    end. /*  if first-of(tCOAValidation.tcDomainCode) */

    if vlIsValidDomain = false
    then next.
    
    /* ========================= */   
    /* Get the Company ID      */
    /* ========================= */   
    if first-of(tCOAValidation.tcCompanyCode)
    then do:
        assign viCurrentCompanyID = 0.
        if tCOAValidation.tcCompanyCode <> "" and 
            tCOAValidation.tcCompanyCode <> ?
        then do:               
            <Q-25 run CompanyPrim (all) (Read) (Cache)
               (input ?, (LookupCompanyId)
                input tCOAValidation.tcCompanyCode, (CompanyCode)
                output dataset tqCompanyPrim) in BCompany>
               
            find tqCompanyPrim where
                tqCompanyPrim.tcCompanyCode = tCOAValidation.tcCompanyCode no-lock no-error.
            if available tqCompanyPrim 
            then assign viCurrentCompanyID = tqCompanyPrim.tiCompany_ID.
        end. /* if tCOAValidation.tcCompanyCode <> "" */          
        if viCurrentCompanyID = 0
        then do:
            assign 
                vlCOAElementError = true
                vcMessage = trim(substitute(#T-15'Entity code (&1) not found.':200(1341)T-15#, trim(tCOAValidation.tcCompanyCode) )).
            create tCOAErrorMessages.
            assign 
                tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
                tCOAErrorMessages.tcErrorMessage   = vcMessage
                tCOAErrorMessages.tiErrorCode      = -1.
            /* don't do other validation on this line if the company code is invalid. */   
            next.               
        end. /* if viCurrentCompanyID = 0 */
    end. /* if first-of(tCOAValidation.tcCompanyCode) */
        
    /* ========================================================= */ 
    /* don't do other validation if the company code is invalid. */
    /* ========================================================= */ 
    if viCurrentCompanyID = 0 or viCurrentCompanyID = ?
    then next.


    /* ==================================== */   
    /* Validate the GL Account              */ 
    /* ==================================== */   
    if tCOAValidation.tcGLCode <> "" and
        tCOAValidation.tcGLCode <> ?
    then do:   
 
        <Q-92 run GLForPostingLineCreation (all) (Read) (Cache)
           (input viCurrentCompanyID, (CompanyID)
            input tCOAValidation.tcGLCode, (GLCode)
            input ?, (GLId)
            output dataset tqGLForPostingLineCreation) in BGL>         
 
        find first tqGLForPostingLineCreation where tqGLForPostingLineCreation.tcGLCode = tCOAValidation.tcGLCode no-lock no-error.
      
        if not available tqGLForPostingLineCreation
        then do:
            assign 
                vlCOAElementError   = true
                vcMessage           = substitute(#T-95'GL account (&1) is not defined in the system.':200(868)T-95#, tCOAValidation.tcGLCode).         
            create tCOAErrorMessages.
            assign 
                tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
                tCOAErrorMessages.tcErrorMessage   = vcMessage
                tCOAErrorMessages.tiErrorCode      = -1.
        end. /* if not available tqGLForPostingLineCreation*/
        else if tqGLForPostingLineCreation.tlGLIsActive = false
        then do:
            assign 
                vlCOAElementError   = true    
                vcMessage           = #T-12'The GL account is not active.':100(2730)T-12#.
            create tCOAErrorMessages.
            assign 
                tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
                tCOAErrorMessages.tcErrorMessage   = vcMessage
                tCOAErrorMessages.tiErrorCode      = -1.
        end. /* if tqGLForPostingLineCreation.tlGLIsActive = false */ 
    end.  /* if tCOAValidation.tcGLCode <> "" */
    else
        /* ======================================================= */        
        /* can't do the combination testing without a gl account  */ 
        /* ====================================================== */     
        assign vlCOAElementError = true. 

    /* ========================= */        
    /* Validate the Cost Centre  */ 
    /* ========================= */   
    if tCOAValidation.tcCostCentreCode <> "" and
        tCOAValidation.tcCostCentreCode <> ?
    then do:
        <Q-86 run CostCentreByCode (all) (Read) (Cache)
           (input viCurrentCompanyID, (CompanyId)
            input tCOAValidation.tcCostCentreCode, (Code)
            output dataset tqCostCentreByCode) in BCostCentre>
            
        find first tqCostCentreByCode where tqCostCentreByCode.tcCostCentreCode = tCOAValidation.tcCostCentreCode no-error. 
      
        if not available tqCostCentreByCode 
        then do:
            assign 
                vlCOAElementError   = true
                vcMessage           = substitute(#T-31'Invalid Cost Center: &1':255(71054)T-31#,tCOAValidation.tcCostCentreCode).
            create tCOAErrorMessages.
            assign 
                tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
                tCOAErrorMessages.tcErrorMessage   = vcMessage
                tCOAErrorMessages.tiErrorCode      = -1.
        end. /* if not available tqCostCentreByCode */     
        else if tqCostCentreByCode.tlCostCentreIsActive = false
        then do:
            assign 
                vlCOAElementError   = true
                vcMessage           = trim(#T-76'Cost Center is not active.':100(232836886)T-76#).
            create tCOAErrorMessages.
            assign 
                tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
                tCOAErrorMessages.tcErrorMessage   = vcMessage
                tCOAErrorMessages.tiErrorCode      = -1.
        end. /* tqCostCentreByCode.tlCostCentreIsActive = false */  
    end. /* if tCOAValidation.tcCostCentreCode <> "" */

     /* ========================= */            
     /* Validate the Sub Account */ 
     /* ========================= */            
    if tCOAValidation.tcSubAccountCode <> "" and
        tCOAValidation.tcSubAccountCode <> ?
    then do:
        <Q-66 run DivisionByCodeIsActive (all) (Read) (Cache)
           (input viCurrentCompanyID, (CompanyId)
            input tCOAValidation.tcSubAccountCode, (DivisionCode)
            input ?, (IsActive)
            output dataset tqDivisionByCodeIsActive) in BDivision>
        
        find first tqDivisionByCodeIsActive where tqDivisionByCodeIsActive.tcDivisionCode = tCOAValidation.tcSubAccountCode no-error. 
    
        if not available tqDivisionByCodeIsActive
        then do:
            assign 
                vlCOAElementError   = true
                vcMessage           = substitute(#T-55'Invalid Sub-Account: &1':255(71051)T-55#,tCOAValidation.tcSubAccountCode).
            create tCOAErrorMessages.
            assign 
                tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
                tCOAErrorMessages.tcErrorMessage   = vcMessage
                tCOAErrorMessages.tiErrorCode      = -1.
        end. /* if not available tqDivisionByCodeIsActive */     
        else if tqDivisionByCodeIsActive.tlDivisionIsActive = false
        then do:
            assign vcMessage = substitute(#T-9'Sub-Account &1 is not active':100(366014490)T-9#,tCOAValidation.tcSubAccountCode).
            create tCOAErrorMessages.
            assign 
                tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
                tCOAErrorMessages.tcErrorMessage   = vcMessage
                tCOAErrorMessages.tiErrorCode      = -1.   
        end. /* if tqDivisionByCodeIsActive.tlDivisionIsActive = false */  
    end. /* if tCOAValidation.tcSubAccountCode <> "" */

    /* ==================== */            
    /* Validate Project     */
    /* ==================== */                    
    if tCOAValidation.tcProjectCode <> "" and
        tCOAValidation.tcProjectCode <> ?
    then do:   
        <Q-63 run ProjectByProjectStatus (all) (Read) (Cache)
           (input viCurrentCompanyID, (CompanyId)
            input ?, (ProjectStatusId)
            input ?, (ProjectID)
            input tCOAValidation.tcProjectCode, (ProjectCode)
            output dataset tqProjectByProjectStatus) in BProject>
     
        find first tqProjectByProjectStatus where tqProjectByProjectStatus.tcProjectCode = tCOAValidation.tcProjectCode no-error.
        if not available tqProjectByProjectStatus
        then do:
            assign 
                vlCOAElementError   = true
                vcMessage           = substitute(#T-19'Invalid Project code: &1':255(144664601)T-19# ,tCOAValidation.tcProjectCode).
            create tCOAErrorMessages.
            assign 
                tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
                tCOAErrorMessages.tcErrorMessage   = vcMessage
                tCOAErrorMessages.tiErrorCode      = -1.
        end. /* if not available tqProjectByProjectStatus */
        /* ========================================= */
        /* System status must be OPEN or CLOSEDCOSTS */
        /* ========================================= */
        else if tqProjectByProjectStatus.tcProjectStatusSystemStatus <> {&PROJECTSYSTEMSTATUS-OPEN} and
                tqProjectByProjectStatus.tcProjectStatusSystemStatus <> {&PROJECTSYSTEMSTATUS-CLOSEDCOSTS}
        then do:
            assign 
                vlCOAElementError = true
                vcMessage = #T-28'Only projects with system status $1 or $2 are allowed.':250(16566)T-28#
                vcMessage = replace(vcMessage, "$", "&").
                vcMessage = substitute(vcMessage,{&PROJECTSYSTEMSTATUS-OPEN-TR}, {&PROJECTSYSTEMSTATUS-CLOSEDCOSTS-TR}).
            create tCOAErrorMessages.
            assign 
                tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
                tCOAErrorMessages.tcErrorMessage   = vcMessage
                tCOAErrorMessages.tiErrorCode      = -1.           
        end. /*  else if tqProjectByProjectStatus.tcProjectStatusSystemStatus <> {&PROJECTSYSTEMSTATUS-OPEN} */
    end. /* if tCOAValidation.tcProjectCode <> "" */  
   
    /* ================================== */ 
    /* hit next if any of the above fails */
    /* ================================== */ 
    if vlCOAElementError = true
    then next.

    /* ========================== */            
    /* COA GL Analysis Limitation */
    /* ========================== */            
    
    /* ================= */
    /* Check Cost Centre */
    /* ================= */
    if tqGLForPostingLineCreation.tlGLIsCostCentreAccount = true and
      (tqGLForPostingLineCreation.tlGLIsProjectAccount = false or
       tqGLForPostingLineCreation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-BOTHREQUIRED}) 
    then do:                             
        /* ==================== */
        /* Find the CostCentre  */
        /* ==================== */
        if tqGLForPostingLineCreation.tlGLIsCostCentreAccount = true
        then do:
            /* ============================================================== */ 
            /* Retrieve cost center from default profile if it's not specified */ 
            /* ============================================================== */ 
            if tCOAValidation.tcCostCentreCode = ? or 
                tCOAValidation.tcCostCentreCode = ""
            then do:            
                if (tqGLForPostingLineCreation.tiCostCentreProfile_ID <> 0 and 
                    tqGLForPostingLineCreation.tiCostCentreProfile_ID <> ?)    and 
                   (tqGLForPostingLineCreation.tlGLIsProjectAccount = false or
                    tCOAValidation.tcProjectCode  = "":U  or
                    tCOAValidation.tcProjectCode  = ?)
                then do:                               
                    <Q-42 run GetCostCentreFromProfile (all) (Read) (Cache)
                       (input viCurrentCompanyID, (CompanyId)
                        input tqGLForPostingLineCreation.tiCostCentreProfile_ID, (CostCentreProfileId)
                        output dataset tqCostCentreFromProfile) in BProfile>
                    find first tqCostCentreFromProfile no-error.
                    if available tqCostCentreFromProfile
                    then assign tCOAValidation.tcCostCentreCode = tqCostCentreFromProfile.tcCostCentreCode.                                            
                end. /* (tqGLForPostingLineCreation.tiCostCentreProfile_ID <> 0 */
            end. /* if tCOAValidation.tcCostCentreCode = "" */     
            if tCOAValidation.tcCostCentreCode = ? or 
                tCOAValidation.tcCostCentreCode = ""
            then do:
                assign vcMessage = trim(subst(#T-73'The GL account &1 requires a cost center code.':150(3235)T-73#, tqGLForPostingLineCreation.tcGLCode)).
                create tCOAErrorMessages.
                assign 
                    tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
                    tCOAErrorMessages.tcErrorMessage   = vcMessage
                    tCOAErrorMessages.tiErrorCode      = -1.   
            end.  /* if tCOAValidation.tcCostCentreCode = "" */                 
        end.  /* if tqGLForPostingLineCreation.tlGLIsCostCentreAccount = true*/ 
    end. /* if tqGLByCode.tlGLIsCostCentreAccount  and ... */   
    
    if tqGLForPostingLineCreation.tlGLIsCostCentreAccount = false and   
        tCOAValidation.tcCostCentreCode <> ? and 
        tCOAValidation.tcCostCentreCode <> ""
    then do:
        assign vcMessage = trim(subst(#T-60'You cannot use a cost center code with GL account &1.':150(65717)T-60#, tqGLForPostingLineCreation.tcGLCode)).
        create tCOAErrorMessages.
        assign 
            tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
            tCOAErrorMessages.tcErrorMessage   = vcMessage
            tCOAErrorMessages.tiErrorCode      = -1.   
    end. /*  if tqGLByCode.tlGLIsCostCentreAccount = false */       
          
    /* ============= */
    /* Check Project */
    /* ============= */
    if tqGLForPostingLineCreation.tlGLIsProjectAccount  = true                                   and
      (tqGLForPostingLineCreation.tlGLIsCostCentreAccount  = false                                  or
       tqGLForPostingLineCreation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-BOTHREQUIRED}) 
    then do:             
        if tqGLForPostingLineCreation.tlGLIsProjectAccount = true
        then do:
            if tCOAValidation.tcProjectCode = "" or 
                tCOAValidation.tcProjectCode = ?
            then do:
                /* ================================= */            
                /* get the project from the profile */
                /* ================================= */            
                if (tqGLForPostingLineCreation.tiProjectProfile_ID <> 0 and 
                    tqGLForPostingLineCreation.tiProjectProfile_ID <> ?)    and 
                   (tqGLForPostingLineCreation.tlGLIsCostCentreAccount  = false or
                    tCOAValidation.tcProjectCode                                   = "":U  or
                    tCOAValidation.tcProjectCode                                   = ?)
                then do:                   
                    <Q-59 run GetProjectFromProfile (all) (Read) (Cache)
                       (input viCurrentCompanyID, (CompanyId)
                        input tqGLForPostingLineCreation.tiProjectProfile_ID, (ProjectProfileID)
                        output dataset tqProjectFromProfile) in BProfile>
                    find first tqProjectFromProfile no-error.
                    if available tqProjectFromProfile
                    then tCOAValidation.tcProjectCode = tqProjectFromProfile.tcProjectCode.                    
                end. /* if (tqGLForPostingLineCreation.tiProjectProfile_ID <> 0 and */
                if tCOAValidation.tcProjectCode = "" or 
                    tCOAValidation.tcProjectCode = ?
                then do:
                    assign vcMessage = trim(subst(#T-7'The GL account &1 requires a project code.':150(3240)T-7#, tqGLForPostingLineCreation.tcGLCode)).
                    create tCOAErrorMessages.
                    assign 
                        tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
                        tCOAErrorMessages.tcErrorMessage   = vcMessage
                        tCOAErrorMessages.tiErrorCode      = -1.   
                end. /* if tCOAValidation.tcProjectCode = "" */
            end. /* if tCOAValidation.tcProjectCode = "" */   
        end. /*  if tqGLForPostingLineCreation.tlGLIsProjectAccount = true */         
    end. /* if tqGLForPostingLineCreation.tlGLIsProjectAccount = true and... */
    
    if tqGLForPostingLineCreation.tlGLIsProjectAccount = false and
       tCOAValidation.tcProjectCode <> ?                   and
       tCOAValidation.tcProjectCode <> ""
    then do:                      
        assign vcMessage           = trim(subst(#T-13'You cannot use a project code with GL account &1.':150(65719)T-13#, tqGLForPostingLineCreation.tcGLCode)).
        create tCOAErrorMessages.
        assign 
            tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
            tCOAErrorMessages.tcErrorMessage   = vcMessage
            tCOAErrorMessages.tiErrorCode      = -1.   
    end. /* if tqGLForPostingLineCreation.tlGLIsProjectAccount = false and */
  
    /* ======================================= */                   
    /* Check Project / Cost Centre combination */
    /* ======================================= */
    if (tqGLForPostingLineCreation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-ATLEASTONE}     or
        tqGLForPostingLineCreation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-EXCLEACHOTHER}) and
       (tCOAValidation.tcCostCentreCode                = ""                                        or
        tCOAValidation.tcCostCentreCode                = ?)                                        and
       (tCOAValidation.tcProjectCode                   = ""                                        or
        tCOAValidation.tcProjectCode                   = ?)
    then do:                      
        assign vcMessage           = trim(subst(#T-33'The GL account &1 requires a cost center or project code.':150(3244)T-33#, tCOAValidation.tcGLCode)).
        create tCOAErrorMessages.
        assign 
            tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
            tCOAErrorMessages.tcErrorMessage   = vcMessage
            tCOAErrorMessages.tiErrorCode      = -1.   
    end. /* if (tqGLForPostingLineCreation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-ATLEASTONE}     or */
    
    if tqGLForPostingLineCreation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-EXCLEACHOTHER} and
       tCOAValidation.tcCostCentreCode                  <> ""                                    and
       tCOAValidation.tcCostCentreCode                  <> ?                                     and
       tCOAValidation.tcProjectCode                     <> ""                                    and
       tCOAValidation.tcProjectCode                     <> ?
    then do:                              
        assign vcMessage           = trim(subst(#T-79'The GL account &1 requires either cost center or project analysis.':150(3245)T-79#, tCOAValidation.tcGLCode)).
        create tCOAErrorMessages.
        assign 
            tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
            tCOAErrorMessages.tcErrorMessage   = vcMessage
            tCOAErrorMessages.tiErrorCode      = -1. 
    end. /* if tqGLForPostingLineCreation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-EXCLEACHOTHER} and */
       
    /* ===================================================================== */             
    /* If analysis limitation is ATLEASTCOSTCENTER (aka COSTCENTREREQUIRED)  */
    /* then throw error if no cost center is defined                         */
    /* ===================================================================== */                    
    
    if tqGLForPostingLineCreation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-ATLEASTCOSTCENTER} and
      ( tCOAValidation.tcCostCentreCode              = ""          or
        tCOAValidation.tcCostCentreCode              = ?         )                               
    then do:                                             
        assign vcMessage           = trim(subst(#T-77'The GL account &1 requires cost center analysis as it is defined with analysis limitation &2':150(599812732)T-77#,
                                             tCOAValidation.tcGLCode,
                                             {&GLANALYSISLIMITATION-ATLEASTCC-TR})).
        create tCOAErrorMessages.
        assign 
            tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
            tCOAErrorMessages.tcErrorMessage   = vcMessage
            tCOAErrorMessages.tiErrorCode      = -1. 
    end. /* if tqGLForPostingLineCreation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-ATLEASTCOSTCENTER} and */
        
    /* =================================================== */             
    /* If analysis limitation is PROJECTREQUIRED           */
    /* then throw error if no project codeis defined       */
    /* =================================================== */             
    
    if tqGLForPostingLineCreation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-PROJECTREQUIRED} and
      ( tCOAValidation.tcProjectCode               = ""          or
       tCOAValidation.tcProjectCode                = ?     )                                   
    then do:                            
        assign vcMessage           = trim(subst(#T-83'The GL account &1 requires project analysis as it is defined with analysis limitation &2':150(141078291)T-83#,
                                             tCOAValidation.tcGLCode,
                                             {&GLANALYSISLIMITATION-PROJECTREQUIRED-TR})).
        create tCOAErrorMessages.
        assign 
            tCOAErrorMessages.tcKeyCOA         = tCOAValidation.tcKeyCOA      
            tCOAErrorMessages.tcErrorMessage   = vcMessage
            tCOAErrorMessages.tiErrorCode      = -1. 
    end. /* if tqGLForPostingLineCreation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-PROJECTREQUIRED} and */

    /* =================================================== */                
    /* Start and open BCOAMask in another transaction.     */
    /* It will be ClosedAndStopped later.                  */
    /* =================================================== */
    if vlClassStartedAndOpenedBCOAMask = false
    then do :
        <I-69 {bFcStartAndOpenInstance
             &ADD-TO-TRANSACTION   = "false"
             &CLASS                = "BCOAMask"}>
        assign vlClassStartedAndOpenedBCOAMask = true.
    end. /* if vlClassStartedAndOpenedBCOAMask = false */

    <M-16 run ValidateCOAMask
       (input  tCOAValidation.tcGLCode (icGLCode), 
        input  tCOAValidation.tcSubAccountCode (icDivisionCode), 
        input  tCOAValidation.tcCostCentreCode (icCostCentreCode), 
        input  tCOAValidation.tcProjectCode (icProjectCode), 
        input  tCOAValidation.tcKeyCOA (icRowId), 
        input  viCurrentCompanyID (iiCompanyId), 
        input  ? (ilIsCOAMaskDiv), 
        input  ? (ilIsCOAMaskDivAll), 
        input  ? (ilIsCOAMaskCC), 
        input  ? (ilIsCOAMaskCCAll), 
        input  ? (ilIsCOAMaskProj), 
        input  ? (ilIsCOAMaskProjAll), 
        output viFcReturnSuper (oiReturnStatus)) in BCOAMask>

    /* ====================================================== */
    /*  ignore any error coming back from this method - all   */
    /*  errors will be accumulated from the messages later    */
    /* ====================================================== */     
end. /* for each */  

/* ====================================================== */             
/* accumulate all the error messages from ValidateCOAMask */
/* ====================================================== */             

for each tFcMessages:
    create tCOAErrorMessages.
    assign 
        tCOAErrorMessages.tcKeyCOA         = tFcMessages.tcFcRowid
        tCOAErrorMessages.tcErrorMessage   = tFcMessages.tcFcMessage
        tCOAErrorMessages.tiErrorCode      = -1.        
end. /* for each tFcMessages */          

/* ======================================== */
/* Stop the BCOAMask instance if opened     */
/* ======================================== */
if vlClassStartedAndOpenedBCOAMask = true
then do :
    <I-20 {bFcCloseAndStopInstance
         &CLASS           = "BCOAMask"}>
    assign vlClassStartedAndOpenedBCOAMask = false.
end. /* if vlClassStartedAndOpenedBCOAMask = false */