project QadFinancials > class BPosting > method ValidateComponentPostCrossCompany

Description

ValidateComponentPostCrossCompany


Parameters


blQueryStartedJournalByJournalinput-outputlogical
blQueryStartedCompanyPriminput-outputlogical
blQueryStartedGLByCyBRinput-outputlogical
blQueryStartedCompanyPropertyinput-outputlogical
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPosting.ValidateComponentPost


program code (program4/bposting.p)

/* ===================== */
/* Exception handling    */
/* ===================== */
assign oiReturnStatus      = -98
       viLocalReturnStatus = 0.

/* ================================================================================ */
/* State the tPostingLine.CrossCompany_ID based on tPostingLine.tcCrossCompanyCode. */
/* This cannot be done using the RKBF because then the current-cy is used as param. */
/* ================================================================================ */
CROSSCOMPANYBLOCK:
do:
    /* =================================================================================================================== */
    /* Warning when moving a posting from Transient to non-transient layer and cross company posting is still in transient */
    /* =================================================================================================================== */
    if t_sPosting.tc_Status                   = "C"                        and
       t_sPosting.tcLayerTypeCode            <> {&LAYERTYPECODE-TRANSIENT} and
       t_sPostingLine.CrossCompanyPosting_ID <> 0                          and
       t_sPostingLine.CrossCompanyPosting_ID <> ?
    then do:
        find t_iPosting where
             t_iPosting.tc_Rowid = t_sPosting.tc_Rowid
             no-error.
        if available t_iPosting and
            t_iPosting.tcLayerTypeCode = {&LAYERTYPECODE-TRANSIENT}
        then do:
            if can-find(first bCrossCyPosting where
                 bCrossCyPosting.Posting_ID = t_sPostingLine.CrossCompanyPosting_ID and
                 bCrossCyPosting.tc_Status <> "D"                                   and
                 bCrossCyPosting.tcLayerTypeCode = {&LAYERTYPECODE-TRANSIENT})
            then do:
                assign vcMessage = #T-80'A cross-company posting line links to a transient posting.  Make sure to transfer that posting to a management or official layer as well.':255(444049900)T-80#
                       viLocalReturnStatus = (if viLocalReturnStatus >= 0 then 1 else viLocalReturnStatus).
                <M-83 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '' (icArguments), 
                    input  'tPostingLine.CrossCompanyPosting_ID' (icFieldName), 
                    input  t_sPostingLine.CrossCompanyPosting_ID (icFieldValue), 
                    input  'W' (icType), 
                    input  3 (iiSeverity), 
                    input  t_sPostingLine.tc_Rowid (icRowid), 
                    input  'qadfin-452749':U (icFcMsgNumber), 
                    input  '' (icFcExplanation), 
                    input  '' (icFcIdentification), 
                    input  '' (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BPosting> 
            end. /* if can-find(first bCrossCyPosting where */
               
            if not can-find(first bCrossCyPosting where
                bCrossCyPosting.Posting_ID = t_sPostingLine.CrossCompanyPosting_ID)
            then do:
                assign vcTransientLayerType = {&LAYERTYPECODE-TRANSIENT}.
                <Q-69 assign vlFcQueryRecordsAvailable = PostingByIdAndLayerType (NoCache)
                   (input t_sPostingLine.CrossCompany_ID, (CompanyId)
                    input t_sPostingLine.CrossCompanyPosting_ID, (PostingId)
                    input vcTransientLayerType, (LayerTypeCode)) in BPosting> 
                if vlFcQueryRecordsAvailable <> false
                then do:
                    assign vcMessage = #T-46'A cross-company posting line links to a transient posting.  Make sure to transfer that posting to a management or official layer as well.':255(444049900)T-46#
                           viLocalReturnStatus = (if viLocalReturnStatus >= 0 then 1 else viLocalReturnStatus).
                    <M-70 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '' (icArguments), 
                        input  'tPostingLine.CrossCompanyPosting_ID' (icFieldName), 
                        input  t_sPostingLine.CrossCompanyPosting_ID (icFieldValue), 
                        input  'W' (icType), 
                        input  3 (iiSeverity), 
                        input  t_sPostingLine.tc_Rowid (icRowid), 
                        input  'qadfin-280816':U (icFcMsgNumber), 
                        input  '' (icFcExplanation), 
                        input  '' (icFcIdentification), 
                        input  '' (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BPosting>                     
                end. /* if vlFcQueryRecordsAvailable = true */                        
            end. /* if not can-find(first bCrossCyPosting where */
        end. /* if available t_iPosting and */
    end. /* if t_sPosting.tc_Status = "C" and */
        
    if t_sPosting.tc_Status <> "D":U and
      (t_sPostingLine.tc_Status      = "N":U or
       t_sPostingLine.tc_Status      = "C":U)
    then do:

        /* =================================== */
        /* Skip if CrossCompany is not changed */
        /* =================================== */
        if t_sPostingLine.tc_Status = "C":U
        then do:
            find t_iPostingLine where
                 t_iPostingLine.tc_Rowid = t_sPostingLine.tc_Rowid
                 no-error.
    
            if available t_iPostingLine and
               t_iPostingLine.tcCrossCompanyCode = t_sPostingLine.tcCrossCompanyCode
            then leave CROSSCOMPANYBLOCK.
        end. /* if t_sPostingLine.tc_Status = "C":U */

        /* ======================================================================================================= */
        /* Skip journal types Cash Entry, Bank Entry, Debtor Payment, Creditor Payment, Creditor Adjustment,       */
        /* Debtor Adjustment Year Closing and Matching (CIREC).                                                    */
        /* For those journals, the cross company info is not yet available because the daemon needs to create that */
        /* ======================================================================================================= */
        if ((t_sPosting.tcJournalTypeCode             = {&JOURNALTYPE-CASHENTRY}          or
           t_sPosting.tcJournalTypeCode               = {&JOURNALTYPE-BANKINGENTRY}       or
           t_sPosting.tcJournalTypeCode               = {&JOURNALTYPE-CREDITORADJUSTMENT} or
           t_sPosting.tcJournalTypeCode               = {&JOURNALTYPE-CREDITORPAYMENT}    or
           t_sPosting.tcJournalTypeCode               = {&JOURNALTYPE-DEBTORADJUSTMENT}   or
           t_sPosting.tcJournalTypeCode               = {&JOURNALTYPE-DEBTORPAYMENT}      or
           t_sPosting.tcJournalTypeCode               = {&JOURNALTYPE-DEDUCTION}      or
           (t_sPosting.tcJournalTypeCode              = {&JOURNALTYPE-CIREC}              and 
            t_sPosting.PostingParentText              = {&POSTINGPARENTTEXT-APMATCHING})) and
           t_sPostingLine.tlLinkedCrCyDaemonReqExists = true)                             or
           (t_sPosting.tcJournalTypeCode              = {&JOURNALTYPE-YEARLYCLOSING})
        then leave CROSSCOMPANYBLOCK.
        
        /* ============================================================================================= */                                                                                                       
        /* PostingLineCrossExternRef can only be filled in case tPosting.PostingOriginIsExternal is true */
        /* ============================================================================================= */
        if t_sPosting.PostingOriginIsExternal        = false and
           t_sPostingLine.PostingLineCrossExternRef <> '':U  and
           t_sPostingLine.PostingLineCrossExternRef <> ?
        then do:
            assign vcMsgExplanation = <M-11 GetErrorExplanation
                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
            assign vcMessage           = trim(#T-112'You can only specify a cross-company external reference when the posting is marked as external.':200(31617)T-112#)
                   viLocalReturnStatus = -1.

            <M-106 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'QadFin-7405':U (icFcMsgNumber), 
                input  vcMsgExplanation (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BPosting>
        end. /* if t_sPosting.PostingOriginIsExternal = false and */

        /* ============================== */  
        /* Resolve the cross-company-code */
        /* ============================== */
        if t_sPostingLine.tcCrossCompanyCode = "":U or
           t_sPostingLine.tcCrossCompanyCode = ?
        then assign t_sPostingLine.CrossCompany_ID = 0.
        else do:
            if blQueryStartedCompanyPrim = false
            then do:
                <Q-95 run CompanyPrim  (Start) in BCompany >
                assign blQueryStartedCompanyPrim = true.
            end. /* if blQueryStartedCompanyPrim = false */
    
            <Q-85 run CompanyPrim (all) (Read) (Cache)
               (input ?, (LookupCompanyId)
                input t_sPostingLine.tcCrossCompanyCode, (CompanyCode)
                output dataset tqCompanyPrim) in BCompany >
    
            find tqCompanyPrim where
                 tqCompanyPrim.tcCompanyCode = t_sPostingLine.tcCrossCompanyCode
                 no-error.
    
            if available tqCompanyPrim
            then assign t_sPostingLine.CrossCompany_ID = tqCompanyPrim.tiCompany_ID.
            else do: 
                assign vcMsgExplanation = <M-96 GetErrorExplanation
                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                                        
                <M-86 run SetMessage
                   (input  trim(#T-135'Invalid Cross-Company Code (&1) was specified.':250(999890428)T-135#) (icMessage), 
                    input  t_sPostingLine.tcCrossCompanyCode (icArguments), 
                    input  'tPostingLine.tcCrossCompanyCode':U (icFieldName), 
                    input  t_sPostingLine.tcCrossCompanyCode (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sPostingLine.tc_Rowid (icRowid), 
                    input  'QadFin-7396':U (icFcMsgNumber), 
                    input  vcMsgExplanation (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BPosting>
                assign viLocalReturnStatus = -1.
                leave CROSSCOMPANYBLOCK.
            end. /* else do */
        end. /* Resolve the cross-company-code */ 

        /* ====================================================================================================== */
        /* Validation: Cross-cy fields on posting-line can only be filled for CrossCy G/L codes. (and vice-versa) */
        /* ====================================================================================================== */
        if t_sPostingLine.tcGLTypeCode = {&GLTYPECODE-CROSS}
        then do:
            /*TRANSIENT LAYER POSTINGS SHOULD NOT BE ALLOWED*/
            <Q-7 run JournalByJournalLayerType (all) (Read) (Cache)
               (input t_sPosting.Journal_ID, (JournalId)
                input '':U, (JournalCode)
                input ?, (CompanyId)
                input '':U, (LayerTypeCode)
                output dataset tqJournalByJournalLayerType) in BJournal>
            
            find first tqJournalByJournalLayerType where 
                       tqJournalByJournalLayerType.tiJournal_ID = t_sPosting.Journal_ID 
                       no-error.
            
            if available tqJournalByJournalLayerType and 
               tqJournalByJournalLayerType.tcLayerTypeCode    = {&LAYERTYPECODE-TRANSIENT} and
               tqJournalByJournalLayerType.tcJournalTypeCode <> {&JOURNALTYPE-PERIODICCOSTING}
            then do:
                 assign vcMsgExplanation = <M-98 GetErrorExplanation
                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
                 assign vcMessage = #T-48'You cannot use a cross-company GL account &1 when posting to the transient layer.':255(617301066)T-48#
                        vcMessage = substitute(vcMessage, t_sPostingLine.tcGLCode).
                 <M-54 run SetMessage
                    (input  vcMessage (icMessage), 
                     input  '':U (icArguments), 
                     input  't_spostingLine.tcGLCode':U (icFieldName), 
                     input  t_sPostingLine.tcGLCode (icFieldValue), 
                     input  'E':U (icType), 
                     input  3 (iiSeverity), 
                     input  t_sPostingLine.tc_Rowid (icRowid), 
                     input  'QadFin-324445':U (icFcMsgNumber), 
                     input  vcMsgExplanation (icFcExplanation), 
                     input  '':U (icFcIdentification), 
                     input  '':U (icFcContext), 
                     output viFcReturnSuper (oiReturnStatus)) in BPosting>       
                assign viLocalReturnStatus = -1.
                leave CROSSCOMPANYBLOCK.
            end. /*if available tqJournalByJournalLayerType and */
            
            if (t_sPostingLine.CrossCompanyPostingLine_ID = 0    or
                t_sPostingLine.CrossCompanyPostingLine_ID = ?    or
                t_sPostingLine.CrossCompanyPosting_ID     = 0    or
                t_sPostingLine.CrossCompanyPosting_ID     = ?    or
                t_sPostingLine.CrossCompany_ID            = 0    or
                t_sPostingLine.CrossCompany_ID            = ?    or
                t_sPostingLine.tcCrossCompanyCode         = "":U or
                t_sPostingLine.tcCrossCompanyCode         = ?    or
                t_sPostingLine.tcCrossCompanyCurrencyCode = "":U or
                t_sPostingLine.tcCrossCompanyCurrencyCode = ?    or
                t_sPostingLine.tcCrossCompanyGLCode       = "":U or
                t_sPostingLine.tcCrossCompanyGLCode       = ?)       and
               (t_sPostingLine.PostingLineCrossExternRef = '':U or
                t_sPostingLine.PostingLineCrossExternRef = ?)        and
                t_sPosting.PostingIsReversing             = false
            then do:
                assign vcMsgExplanation = <M-32 GetErrorExplanation
                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
                assign vcMessage = trim(#T-134'Cross-Company fields on a postingline should be filled when the GL is a Cross-Company account.':255(733741047)T-134#)
                       vcContext = "t_sPostingLine.CrossCompanyPostingLine_ID=&1|t_sPostingLine.CrossCompanyPosting_ID=&2|t_sPostingLine.CrossCompany_ID=&3|t_sPostingLine.tcCrossCompanyCode=&4|t_sPostingLine.tcCrossCompanyCurrencyCode=&5|t_sPostingLine.tcCrossCompanyGLCode=&6|t_sPostingLine.PostingLineCrossExternRef=&7":U
                       vcContext = substitute(vcContext, t_sPostingLine.CrossCompanyPostingLine_ID, t_sPostingLine.CrossCompanyPosting_ID, t_sPostingLine.CrossCompany_ID, t_sPostingLine.tcCrossCompanyCode, t_sPostingLine.tcCrossCompanyCurrencyCode, t_sPostingLine.tcCrossCompanyGLCode, t_sPostingLine.PostingLineCrossExternRef)
                       vcContext = replace(vcContext, "|":U, chr(2)).
                <M-87 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'tPostingLine.tcGLCode':U (icFieldName), 
                    input  t_sPostingLine.tcGLCode (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sPostingLine.tc_Rowid (icRowid), 
                    input  'QadFin-7397':U (icFcMsgNumber), 
                    input  vcMsgExplanation (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  vcContext (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BPosting>
                assign viLocalReturnStatus = -1.
                leave CROSSCOMPANYBLOCK.
            end.

            if t_sPostingLine.CrossCompany_ID = t_sPostingLine.Company_ID
                and t_sPostingLine.PostingLineCrossExternRef = ""
            then do:
                assign vcMsgExplanation = <M-64 GetErrorExplanation
                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
                assign viLocalReturnStatus = -1.
                <M-92 run SetMessage
                   (input  #T-16'Cross-company should not be the same as the company itself':255(638276387)T-16# (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '':U (icRowid), 
                    input  'QadFin-630404':U (icFcMsgNumber), 
                    input  vcMsgExplanation (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BPosting>
                leave CROSSCOMPANYBLOCK.
            end. /*IF t_sPostingLine.CrossCompany_ID = t_sPostingLine.Company_ID*/
        end. /* if t_sPostingLine.tcGLTypeCode = {&GLTYPECODE-CROSS} */     

        else do:
            if (t_sPostingLine.CrossCompanyPostingLine_ID <> 0  and
                t_sPostingLine.CrossCompanyPostingLine_ID <> ?) or
               (t_sPostingLine.CrossCompanyPosting_ID     <> 0  and
                t_sPostingLine.CrossCompanyPosting_ID     <> ?) or
               (t_sPostingLine.CrossCompany_ID            <> 0  and
                t_sPostingLine.CrossCompany_ID            <> ?) or
               (t_sPostingLine.PostingLineCrossExternRef  <> '':U and
                t_sPostingLine.PostingLineCrossExternRef  <> ?)
            then do:
                assign vcMsgExplanation = <M-40 GetErrorExplanation
                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
                assign vcMessage      = trim(subst(#T-109'The GL account (&1) is of type &2 and does not create cross-company information.':255(3286)T-109#, t_sPostingLine.tcGLCode, t_sPostingLine.tcGLTypeCode)) + chr(10) +
                                        trim(subst(#T-110'Cross-company entity ID: &1.':255(3279)T-110#, string(t_sPostingLine.CrossCompany_ID)))                                                              + chr(10) +
                                        trim(subst(#T-111'Cross-company posting ID: &1.':255(3280)T-111#, string(t_sPostingLine.CrossCompanyPosting_ID)))                                                       + chr(10) +
                                        trim(subst(#T-133'Cross-company posting line ID: &1.':255(3281)T-133#, string(t_sPostingLine.CrossCompanyPostingLine_ID)))
                       viLocalReturnStatus = -1.
                <M-88 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  't_sPostingLine.tcGLCode':U (icFieldName), 
                    input  t_sPostingLine.tcGLCode (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sPostingLine.tc_Rowid (icRowid), 
                    input  'QadFin-7398':U (icFcMsgNumber), 
                    input  vcMsgExplanation (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BPosting>
                leave CROSSCOMPANYBLOCK.
            end.
        end. /* else do */

        /* ========================================= */
        /* Next in case this is not a cross-cy story */
        /* ========================================= */
        if t_sPostingLine.tcGLTypeCode <> {&GLTYPECODE-CROSS}
        then leave CROSSCOMPANYBLOCK.

        /* ============================================ */
        /* Cross-cy is not allowed on posting-templates */
        /* ============================================ */
        if t_sPosting.tcTemplateCode <> "":U and
           t_sPosting.tcTemplateCode <> ?
        then do:
            assign vcMsgExplanation = <M-74 GetErrorExplanation
                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
            assign vcMessage      = trim(subst(#T-129'Posting templates &1 cannot contain cross-company GL accounts &2.':255(3287)T-129#, t_sPosting.tcTemplateCode, t_sPostingLine.tcGLCode)) + chr(10) +
                                    trim(subst(#T-130'Cross-company entity code: &1.':255(3288)T-130#, t_sPostingLine.tcCrossCompanyCode))
                   viLocalReturnStatus = -1.
            <M-89 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  't_sPostingLine.tcGLCode':U (icFieldName), 
                input  t_sPostingLine.tcGLCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sPostingLine.tc_Rowid (icRowid), 
                input  'QadFin-7399':U (icFcMsgNumber), 
                input  vcMsgExplanation (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BPosting>
            leave CROSSCOMPANYBLOCK.
        end. /* Cross-cy is not allowed on posting-templates */

        /* ======================================== */
        /* Skip validations  for external postings. */
        /* ======================================== */
        if t_sPosting.PostingOriginIsExternal = true        and
           t_sPostingLine.PostingLineCrossExternRef <> '':U and
           t_sPostingLine.PostingLineCrossExternRef <> ?
        then leave CROSSCOMPANYBLOCK.   
        
        /* ============================================================================================ */
        /* Get the G/L in the CrossCy                                                                   */
        /* Get a GL that will be used for the posting in the current company with following properties: */
        /* - SharedSet of the G/L should match the SharedSet of the company of the CI (<>CurrentCy)     */
        /* - GL.GLType should be CrossCompany                                                           */
        /* - GL.GLSystemType should be empty                                                            */
        /* - GL.GLIsIntercompany should be true                                                         */
        /* - GL.BusinessRelationCode should match the BusinessRelationCode of the current company       */
        /* ============================================================================================ */
        if blQueryStartedGLByCyBR = false
        then do:
            <Q-97 run GLByCyBusinessRelation  (Start) in BGL >
            assign blQueryStartedGLByCyBR = true.
        end. /* if blQueryStartedGLByCyBR = false */
                
        <Q-102 run GLByCyBusinessRelation (all) (Read) (Cache)
           (input t_sPostingLine.CrossCompany_ID, (CompanyId)
            input ?, (BusinessRelationID)
            input ?, (BusinessRelationCode)
            input t_sPostingLine.tcCrossCompanyGLCode, (GLCode)
            input ?, (GLID)
            input ?, (GLTypeCode)
            input '':U, (GLSystemTypeCode)
            output dataset tqGLByCyBusinessRelation) in BGL >
    
        find tqGLByCyBusinessRelation where
             tqGLByCyBusinessRelation.tcGLCode = t_sPostingLine.tcCrossCompanyGLCode
             no-error.
        if not available tqGLByCyBusinessRelation
        then do:
            assign vcMsgExplanation = <M-81 GetErrorExplanation
                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
            assign vcMessage      = trim(subst(#T-131'Cross-company error: the cross-company GL account &1 cannot be found.':255(3289)T-131#, t_sPostingLine.tcCrossCompanyGLCode)) + chr(10) +
                                    trim(subst(#T-132'Entity: &1/&2.':255(3290)T-132#, t_sPostingLine.tcCrossCompanyCode, string(t_sPostingLine.CrossCompany_ID)))
                   viLocalReturnStatus = -1.
            <M-103 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tPostingLine.tcCrossCompanyGLCode':U (icFieldName), 
                input  t_sPostingLine.tcCrossCompanyGLCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sPostingLine.tc_Rowid (icRowid), 
                input  'QadFin-7402':U (icFcMsgNumber), 
                input  vcMsgExplanation (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BPosting>
            leave CROSSCOMPANYBLOCK.
        end. /* if not available tqGLByCyBusinessRelation */

        if tqGLByCyBusinessRelation.tcGLTypeCode <> {&GLTYPECODE-CROSS}
        then do:
            assign vcMsgExplanation = <M-51 GetErrorExplanation
                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
            assign vcMessage      = trim(substitute(#T-107'Cross-company error: the cross-company GL account &1 must be defined for cross-company transactions.':255(60921)T-107#, t_sPostingLine.tcCrossCompanyGLCode)) + chr(10) +
                                    trim(substitute(#T-108'Entity: &1/&2.':255(3290)T-108#, t_sPostingLine.tcCrossCompanyCode, string(t_sPostingLine.CrossCompany_ID)))
                   viLocalReturnStatus = -1.
            <M-101 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tPostingLine.tcCrossCompanyGLCode':U (icFieldName), 
                input  t_sPostingLine.tcCrossCompanyGLCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sPostingLine.tc_Rowid (icRowid), 
                input  'QadFin-7401':U (icFcMsgNumber), 
                input  vcMsgExplanation (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BPosting>
            leave CROSSCOMPANYBLOCK.
        end. /* if tqGLByCyBusinessRelation.tcGLTypeCode <> {&GLTYPECODE-CROSS} */

        if tqGLByCyBusinessRelation.tlGLIsIntercoAccount <> true
        then do:
            assign vcMsgExplanation = <M-66 GetErrorExplanation
                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
            assign vcMessage      = trim(subst(#T-123'Cross-company error: the cross-company GL account &1 must be defined for intercompany usage.':255(3292)T-123#, t_sPostingLine.tcCrossCompanyGLCode)) + chr(10) +
                                    trim(subst(#T-124'Entity: &1/&2.':255(3290)T-124#, t_sPostingLine.tcCrossCompanyCode, string(t_sPostingLine.CrossCompany_ID)))
                   viLocalReturnStatus = -1.
            <M-104 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tPostingLine.tcCrossCompanyGLCode':U (icFieldName), 
                input  t_sPostingLine.tcCrossCompanyGLCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sPostingLine.tc_Rowid (icRowid), 
                input  'QadFin-7403':U (icFcMsgNumber), 
                input  vcMsgExplanation (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BPosting>
            leave CROSSCOMPANYBLOCK.
        end. /* if tqGLByCyBusinessRelation.tlGLIsIntercoAccount <> true */

        if tqGLByCyBusinessRelation.tlGLIsActive <> true
        then do:
            assign vcMsgExplanation = <M-12 GetErrorExplanation
                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
            assign vcMessage      = trim(subst(#T-125'Cross-company error: the cross-company GL account &1 is not active.':255(3293)T-125#, t_sPostingLine.tcCrossCompanyGLCode)) + chr(10) +
                                    trim(subst(#T-126'Entity: &1/&2.':255(3290)T-126#, t_sPostingLine.tcCrossCompanyCode, string(t_sPostingLine.CrossCompany_ID)))
                   viLocalReturnStatus = -1.
            <M-105 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tPostingLine.tcCrossCompanyGLCode':U (icFieldName), 
                input  t_sPostingLine.tcCrossCompanyGLCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sPostingLine.tc_Rowid (icRowid), 
                input  'QadFin-7404':U (icFcMsgNumber), 
                input  vcMsgExplanation (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BPosting>
            leave CROSSCOMPANYBLOCK.
        end. /*  if tqGLByCyBusinessRelation.tlGLIsActive <> true */


        /* ======================================================================================= */
        /* Check if the G/L in the target company allows postings on the local currency of that cy */
        /* ======================================================================================= */
        if blQueryStartedCompanyProperty = false
        then do:
            <Q-99 run CompanyPropertyByCompany  (Start) in BCompanyProperty >
            assign blQueryStartedCompanyProperty = true.
        end. /* if blQueryStartedCompanyProperty = false */
    
        <Q-90 run CompanyPropertyByCompany (all) (Read) (Cache)
           (input t_sPostingLine.CrossCompany_ID, (CompanyId)
            input ?, (CompanyCode)
            input ?, (CurrencyCode)
            output dataset tqCompanyPropertyByCompany) in BCompanyProperty >
    
        find tqCompanyPropertyByCompany where
             tqCompanyPropertyByCompany.tiCompany_ID = t_sPostingLine.CrossCompany_ID
             no-error.
        if not available tqCompanyPropertyByCompany
        then leave CROSSCOMPANYBLOCK.

        if tqGLByCyBusinessRelation.tiCurrency_ID <> 0 and
           tqGLByCyBusinessRelation.tiCurrency_ID <> ? and
           tqGLByCyBusinessRelation.tiCurrency_ID <> tqCompanyPropertyByCompany.tiCurrency_ID
        then do:
            assign vcMsgExplanation = <M-67 GetErrorExplanation
                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
            assign vcMessage      = trim(subst(#T-127'Cross-company error: GL account &1 does not allow postings on the base currency &2 of the target entity &3.':255(2773)T-127#, t_sPostingLine.tcCrossCompanyGLCode, tqCompanyPropertyByCompany.tcCurrencyCode, tqCompanyPropertyByCompany.tcCompanyCode)) + chr(10) +
                                    trim(subst(#T-128'Entity: &1/&2.':255(3290)T-128#, t_sPostingLine.tcCrossCompanyCode, string(t_sPostingLine.CrossCompany_ID)))
                   viLocalReturnStatus = -1.
            <M-91 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tPostingLine.tcCrossCompanyGLCode':U (icFieldName), 
                input  t_sPostingLine.tcCrossCompanyGLCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sPostingLine.tc_Rowid (icRowid), 
                input  'QadFin-7400':U (icFcMsgNumber), 
                input  vcMsgExplanation (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BPosting>
            leave CROSSCOMPANYBLOCK.
        end. /* if tqGLByCyBusinessRelation.tiCurrency_ID <> 0 and */
    end. /* if t_sPosting.tc_Status <> "D":U and */
end. /* CROSSCOMPANYBLOCK */

/* ===================== */
/* Exception handling    */
/* ===================== */
assign oiReturnStatus = viLocalReturnStatus.