project QadFinancials > class BConsolid > method AdditionalUpdatesPosting

Description

Create Consolidation Postings


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BConsolid.AdditionalUpdates


program code (program6/bconsolid.p)

/* ======================================================================== */
/* In this method, the consolidation postings will be created               */
/* based on the temp-table that was created in the AdditionalUpdates        */
/* ======================================================================== */
/* Add Posting Header                                                       */
/* for each Detail:                                                         */
/*    get the account (GLByCode)                                            */
/*    if Debit <> 0 then AddStandardPosting and create ConsolidPostingXref  */
/*    if Credit <> 0 then AddStandardPosting and create ConsolidPostingXref */
/* end                                                                      */
/* ValidateBCAndAdditionalUpdates                                           */
/* ======================================================================== */
assign oiReturnStatus = -98.

/* start and/or open the journal entry instance */
if viBJournalEntryConsolidID = 0 or viBJournalEntryConsolidID = ?
then do:
    <I-17 {bFcStartAndOpenInstance
            &ADD-TO-TRANSACTION = "true"
            &CLASS              = "BJournalEntry"}>
end.
else do:
    <I-18 {bFcOpenInstance
            &CLASS           = "BJournalEntry"}>
end.        

assign vdDebitLC  = 0
       vdCreditLC = 0
       vdDebitTC  = 0
       vdCreditTC = 0.

POSTINGBLOCK:
for each tConsPosting
    break by tConsPosting.tcConsPostingSourceCompanyCode
          by tConsPosting.tcConsPostingJournalCode:

    if first-of(tConsPosting.tcConsPostingJournalCode)
    then do:
        assign vdTotalDebitTC  = 0
               vdTotalCreditTC = 0
               vdTotalDebitLC  = 0
               vdTotalCreditLC = 0
               viCnt           = 0.

        /* =========================================== */
        /* Get PostingDate (= End date of 'To Period') */
        /* =========================================== */
        <Q-2 run PeriodByYearPeriod (all) (Read) (NoCache)
           (input tConsPosting.tiCompanyId, (CompanyId)
            input tConsPosting.tiConsPostingPeriodYear, (PeriodYear)
            input tConsPosting.tiConsPostingPeriodPeriod, (PeriodPeriod)
            input 0, (PeriodId)
            output dataset tqPeriodByYearPeriod) in BPeriod >

        find tqPeriodByYearPeriod where
             tqPeriodByYearPeriod.tiCompany_ID   = tConsPosting.tiCompanyId             and
             tqPeriodByYearPeriod.tiPeriodYear   = tConsPosting.tiConsPostingPeriodYear and
             tqPeriodByYearPeriod.tiPeriodPeriod = tConsPosting.tiConsPostingPeriodPeriod
             no-lock no-error.

        if not available tqPeriodByYearPeriod
        then do:
            assign vcMessage  = trim(substitute(#T-26'The consolidation period (&1/&2) is not defined in the system.':200(1315)T-26#, trim(string(tConsPosting.tiConsPostingPeriodYear)), trim(string(tConsPosting.tiConsPostingPeriodPeriod)) ))
                   oiReturnStatus = -1.
            <M-3 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-2327':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BConsolid>
        end.
        
        /* ================== */
        /* Add Posting Header */
        /* ================== */
        <M-7 run AddPostingHeader
           (input  tConsPosting.tiCompanyId (iiCompanyId), 
            input  tConsPosting.tiConsPostingPeriodYear (iiPeriodYear), 
            input  tConsPosting.tiConsPostingPeriodPeriod (iiPeriodPeriod), 
            input  tConsPosting.tcConsPostingJournalCode (icJournalCode), 
            input  '' (icReportingJournalCode), 
            input  0 (iiVoucher), 
            input  tqPeriodByYearPeriod.ttPeriodEndDate (itPostingDate), 
            input  ? (itValueDate), 
            input  trim(#T-27'Consolidation':40(1316)t-27#) (icPostingText), 
            input  '':U (icPostingBusinessRelationText), 
            input  '':U (icPostingInvoiceReferenceText), 
            input  '':U (icPostingParentText), 
            input  0 (iiBPeriodId), 
            input  ? (icPostingOriginAddressCode), 
            input  ? (icPostingOriginDocument), 
            input  ? (icPostingOriginDocumentType), 
            input  '':U (icBatchNumber), 
            input  ? (icBankImpLineRef), 
            output viPostingID (oiPostingId), 
            output vcPostingRowid (ocRowid), 
            output viPostingVoucher (oiPostingVoucher), 
            output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>

        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
        then assign oiReturnStatus = viFcReturnSuper.
        if oiReturnStatus < 0 and oiReturnStatus <> -98
        then leave POSTINGBLOCK.

        find tConsolid where
             tConsolid.tc_Rowid = tConsPosting.tcConsPostingConsolidRowid
             no-error.
        if available tConsolid
        then assign tConsolid.Posting_ID = viPostingID.

        /* Retrieve the default tax code from the consolidation cycle */
        <Q-46 run ConsolidCycleByConsolidCycleID (all) (Read) (NoCache)
           (input viCompanyId, (CompanyId)
            input 0, (ConsolidCycleID)
            output dataset tqConsolidCycleByConsolidCycleID) in BConsolidCycle >

        find tqConsolidCycleByConsolidCycleID where
             tqConsolidCycleByConsolidCycleID.tiCompany_ID = tConsPosting.tiCompanyId
             no-lock no-error.

        if available tqConsolidCycleByConsolidCycleID
        then assign vcDefaultTaxCode = tqConsolidCycleByConsolidCycleID.tcConsolidCycleDefTaxCode.
        empty temp-table tqConsolidCycleByConsolidCycleID.

    end. /* first of tconsPosting */

    /* ==================================================== */
    /* Check which type of GL and fill in the amounts + Qty */
    /* ==================================================== */
    <Q-12 run GLAnalysisSettings (all) (Read) (NoCache)
       (input tConsPosting.tiCompanyId, (CompanyId)
        input tConsPosting.tcConsPostingGLCode, (GLCode)
        input ?, (GLID)
        output dataset tqGLAnalysisSettings) in BGL>

    find tqGLAnalysisSettings where
         tqGLAnalysisSettings.tcGLCode = tConsPosting.tcConsPostingGLCode 
         no-lock no-error.
    if not available tqGLAnalysisSettings
    then do:
        assign vcMessage  = trim(substitute(#T-28'The GL account &1 cannot be found.':150(1231)T-28#, trim(tConsPosting.tcConsPostingGLCode) ))
               oiReturnStatus = -1.
        <M-11 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-2344':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BConsolid>
        leave POSTINGBLOCK.
    end.
    
    assign vctempsafstructurecode = "":U.

    empty temp-table tConsolidSafs.

    if tConsPosting.tcSafStructureCode <> '':U and
       tConsPosting.tcSafStructureCode <> ?
    then do:
        assign vcTempSafStructureCode = tConsPosting.tcSafStructureCode.
        if tConsPosting.tcSafConcept1Code <> ? and
           tConsPosting.tcSafConcept1Code <> '':U
        then do:
            create tConsolidSafs.
            assign tConsolidSafs.tcSafConceptCode = tConsPosting.tcSafConcept1Code
                   tConsolidSafs.tcSafCode        = tConsPosting.tcSaf1Code.
        end. /* if tConsPosting.tcSafConcept1Code <> ? and */
        if tConsPosting.tcSafConcept2Code <> ? and
           tConsPosting.tcSafConcept2Code <> '':U
        then do:
            create tConsolidSafs.
            assign tConsolidSafs.tcSafConceptCode = tConsPosting.tcSafConcept2Code
                   tConsolidSafs.tcSafCode        = tConsPosting.tcSaf2Code.
        end. /* if tConsPosting.tcSafConcept2Code <> ? and */
        if tConsPosting.tcSafConcept3Code <> ? and
           tConsPosting.tcSafConcept3Code <> '':U
        then do:
            create tConsolidSafs.
            assign tConsolidSafs.tcSafConceptCode = tConsPosting.tcSafConcept3Code
                   tConsolidSafs.tcSafCode        = tConsPosting.tcSaf3Code.
        end. /* if tConsPosting.tcSafConcept3Code <> ? and */
        if tConsPosting.tcSafConcept4Code <> ? and
           tConsPosting.tcSafConcept4Code <> '':U
        then do:
            create tConsolidSafs.
            assign tConsolidSafs.tcSafConceptCode = tConsPosting.tcSafConcept4Code
                   tConsolidSafs.tcSafCode        = tConsPosting.tcSaf4Code.
        end. /* if tConsPosting.tcSafConcept4Code <> ? and */
        if tConsPosting.tcSafConcept5Code <> ? and
           tConsPosting.tcSafConcept5Code <> '':U
        then do:
            create tConsolidSafs.
            assign tConsolidSafs.tcSafConceptCode = tConsPosting.tcSafConcept5Code
                   tConsolidSafs.tcSafCode        = tConsPosting.tcSaf5Code.
        end. /* if tConsPosting.tcSafConcept5Code <> ? and */
    end. /* if tConsPosting.tcSafStructureCode <> '':U and */

    assign vdDebitTC  = <M-38 RoundAmount
                           (input  tConsPosting.tdConsPostingMovementDebitTC * (tConsPosting.tdConsPostingPercentage / 100) (idUnroundedAmount), 
                            input  0 (iiCurrencyID), 
                            input  tConsPosting.tcCurrencyCode (icCurrencyCode)) in BConsolid>        
           vdCreditTC = <M-39 RoundAmount
                           (input  tConsPosting.tdConsPostingMovementCreditTC * (tConsPosting.tdConsPostingPercentage / 100) (idUnroundedAmount), 
                            input  0 (iiCurrencyID), 
                            input  tConsPosting.tcCurrencyCode (icCurrencyCode)) in BConsolid>
           vdDebitLC  = <M-34 RoundAmount
                           (input  tConsPosting.tdConsPostingMovementDebitLC * (tConsPosting.tdConsPostingPercentage / 100) (idUnroundedAmount), 
                            input  viCompanyLCid (iiCurrencyID), 
                            input  vcCompanyLC (icCurrencyCode)) in BConsolid>
           vdCreditLC = <M-35 RoundAmount
                           (input  tConsPosting.tdConsPostingMovementCreditLC * (tConsPosting.tdConsPostingPercentage / 100) (idUnroundedAmount), 
                            input  viCompanyLCid (iiCurrencyID), 
                            input  vcCompanyLC (icCurrencyCode)) in BConsolid>
           vdQty      = tConsPosting.tdConsPostingMovementQTY
           vdTotalDebitTC  = vdTotalDebitTC  + vdDebitTC
           vdTotalCreditTC = vdTotalCreditTC + vdCreditTC
           vdTotalDebitLC  = vdTotalDebitLC  + vdDebitLC
           vdTotalCreditLC = vdTotalCreditLC + vdCreditLC.       
  
    /* ================ */
    /* Add PostingLines */
    /* ================ */
    if vdDebitTC <> 0
    then do:        
        assign viCnt = viCnt + 1
               vcKey = trim("PostingId-":U) + trim(string(viPostingID)) + trim("-Nbr-":U) + trim(string(viCnt))
               vdExchangeRate = vdDebitLC / vdDebitTC no-error.

        <M-9 run AddStandardPosting
           (input  vcPostingRowid (icPostingtcRowid), 
            input  tConsPosting.tcConsPostingGLCode (icGLCode), 
            input  tConsPosting.tcConsPostingDivisionCode (icDivisionCode), 
            input  tConsPosting.tcConsPostingCostCenterCode (icCostCentreCode), 
            input  '':U (icCostCentreText), 
            input  tConsPosting.tcConsPostingProjectCode (icProjectCode), 
            input  '':U (icProjectText), 
            input  tConsPosting.tcConsPostingIntercoRelation (icIntercoBusinessRelationCode), 
            input  tConsPosting.tcCurrencyCode (icCurrencyCode), 
            input  vdDebitTC (idDebitTC), 
            input  vdDebitLC (idDebitLC), 
            input  0 (idDebitCC), 
            input  0 (idDebitPC), 
            input  0 (idCreditTC), 
            input  0 (idCreditLC), 
            input  0 (idCreditCC), 
            input  0 (idCreditPC), 
            input  vdQty (idQty), 
            input  '':U (icLineText), 
            input  '':U (icSafText), 
            input  tConsolidSafs (tDefaultSafs), 
            input  {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateType), 
            input  vdExchangeRate (idExchangeRate), 
            input  1 (idExchangeRateScale), 
            output viPostingLineID (oiPostingLineId), 
            input  0 (iiSafStructureId), 
            input  vcTempSafStructureCode (icSafStructureCode), 
            input  vcKey (icAllocationKey), 
            output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>

        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
        then assign oiReturnStatus = viFcReturnSuper.
        if oiReturnStatus < 0 and oiReturnStatus <> -98
        then leave POSTINGBLOCK.

        /* Create Tax Accounts if necessary */
        if tqGLAnalysisSettings.tcGLTypeCode = {&GLTYPECODE-VAT}
        then do:        
            <M-49 run AdditionalUpdatesPostingTaxAccount
               (input  tConsPosting.tiCompanyId (iiCompanyId), 
                input  vcDefaultTaxCode (icDefaultTaxCode), 
                input  vcPostingRowid (icPostingtcRowid), 
                input  viPostingLineID (iiPostingLineId), 
                input  tConsPosting.tcCurrencyCode (icCurrencyCode), 
                input  tqPeriodByYearPeriod.ttPeriodEndDate (itTaxPointDate), 
                input  tConsPosting.tcConsPostingGLCode (icTaxGLCode), 
                input  vdExchangeRate (idExchangeRate), 
                output viFcReturnSuper (oiReturnStatus)) in BConsolid>

            if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
            then assign oiReturnStatus = viFcReturnSuper.
            if oiReturnStatus < 0 and oiReturnStatus <> -98
            then leave POSTINGBLOCK.

        end.

        /* Create tConsolidPostingXref records */
        for each tConsPostingXref where
                 tConsPostingXref.tc_ParentRowid = tConsPosting.tc_Rowid:
            <M-43 run AddDetailLine
               (input  'ConsolidPostingXref':U (icTable), 
                input  tConsolid.tc_Rowid (icParentRowid), 
                output viFcReturnSuper (oiReturnStatus)) in BConsolid>

            if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
            then assign oiReturnStatus = viFcReturnSuper.
            if oiReturnStatus < 0 and oiReturnStatus <> -98
            then leave POSTINGBLOCK.

            assign tConsolidPostingXref.PostingLine_ID = viPostingLineID
                   tConsolidPostingXref.PostingHist_ID = tConsPostingXref.PostingHist_ID.

        end. /* for each tConsPostingXref where */

    end. /*     if vdDebitTC <> 0 */

    if vdCreditTC <> 0
    then do:
        assign viCnt = viCnt + 1
               vcKey = trim("PostingId-":U) + trim(string(viPostingID)) + trim("-Nbr-":U) + trim(string(viCnt))
               vdExchangeRate = vdCreditLC / vdCreditTC no-error.

        <M-21 run AddStandardPosting
           (input  vcPostingRowid (icPostingtcRowid), 
            input  tConsPosting.tcConsPostingGLCode (icGLCode), 
            input  tConsPosting.tcConsPostingDivisionCode (icDivisionCode), 
            input  tConsPosting.tcConsPostingCostCenterCode (icCostCentreCode), 
            input  '':U (icCostCentreText), 
            input  tConsPosting.tcConsPostingProjectCode (icProjectCode), 
            input  '':U (icProjectText), 
            input  tConsPosting.tcConsPostingIntercoRelation (icIntercoBusinessRelationCode), 
            input  tConsPosting.tcCurrencyCode (icCurrencyCode), 
            input  0 (idDebitTC), 
            input  0 (idDebitLC), 
            input  0 (idDebitCC), 
            input  0 (idDebitPC), 
            input  vdCreditTC (idCreditTC), 
            input  vdCreditLC (idCreditLC), 
            input  0 (idCreditCC), 
            input  0 (idCreditPC), 
            input  vdQty (idQty), 
            input  '':U (icLineText), 
            input  '':U (icSafText), 
            input  tConsolidSafs (tDefaultSafs), 
            input  {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateType), 
            input  vdExchangeRate (idExchangeRate), 
            input  1 (idExchangeRateScale), 
            output viPostingLineID (oiPostingLineId), 
            input  0 (iiSafStructureId), 
            input  vcTempSafStructureCode (icSafStructureCode), 
            input  vcKey (icAllocationKey), 
            output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>

        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
        then assign oiReturnStatus = viFcReturnSuper.
        if oiReturnStatus < 0 and oiReturnStatus <> -98
        then leave POSTINGBLOCK.

        /* Create Tax Accounts if necessary */
        if tqGLAnalysisSettings.tcGLTypeCode = {&GLTYPECODE-VAT}
        then do:
            <M-50 run AdditionalUpdatesPostingTaxAccount
               (input  tConsPosting.tiCompanyId (iiCompanyId), 
                input  vcDefaultTaxCode (icDefaultTaxCode), 
                input  vcPostingRowid (icPostingtcRowid), 
                input  viPostingLineID (iiPostingLineId), 
                input  tConsPosting.tcCurrencyCode (icCurrencyCode), 
                input  tqPeriodByYearPeriod.ttPeriodEndDate (itTaxPointDate), 
                input  tConsPosting.tcConsPostingGLCode (icTaxGLCode), 
                input  vdExchangeRate (idExchangeRate), 
                output viFcReturnSuper (oiReturnStatus)) in BConsolid>

            if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
            then assign oiReturnStatus = viFcReturnSuper.
            if oiReturnStatus < 0 and oiReturnStatus <> -98
            then leave POSTINGBLOCK.
        end.

        /* Create tConsolidPostingXref records */
        for each tConsPostingXref where
                 tConsPostingXref.tc_ParentRowid = tConsPosting.tc_Rowid:

            <M-44 run AddDetailLine
               (input  'ConsolidPostingXref':U (icTable), 
                input  tConsolid.tc_Rowid (icParentRowid), 
                output viFcReturnSuper (oiReturnStatus)) in BConsolid>

            if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
            then assign oiReturnStatus = viFcReturnSuper.
            if oiReturnStatus < 0 and oiReturnStatus <> -98
            then leave POSTINGBLOCK.

            assign tConsolidPostingXref.PostingLine_ID = viPostingLineID
                   tConsolidPostingXref.PostingHist_ID = tConsPostingXref.PostingHist_ID.

        end. /* for each tConsPostingXref where */

    end. /* if vdCreditTC <> 0 */

    /* Post the currency translation adjustment amount in LC and CC the the correct account */
    if last-of(tConsPosting.tcConsPostingJournalCode)
    then do:
        if vdTotalDebitLC < vdTotalCreditLC
        then assign vdRoundDebitLC = vdTotalCreditLC - vdTotalDebitLC
                    vdRoundCreditLC  = 0.
        else assign vdRoundDebitLC = 0
                    vdRoundCreditLC = vdTotalDebitLC - vdTotalCreditLC.
        
        empty temp-table tConsolidSafs.

        /* Exchange rate difference for debit amounts */
        if vdRoundDebitLC <> 0
        then do:
            <M-40 run AddStandardPosting
               (input  vcPostingRowid (icPostingtcRowid), 
                input  tConsPosting.tcConsPostingRoundGLCode (icGLCode), 
                input  '':U (icDivisionCode), 
                input  '':U (icCostCentreCode), 
                input  '':U (icCostCentreText), 
                input  '':U (icProjectCode), 
                input  '':U (icProjectText), 
                input  '':U (icIntercoBusinessRelationCode), 
                input  tConsPosting.tcCurrencyCode (icCurrencyCode), 
                input  0 (idDebitTC), 
                input  vdRoundDebitLC (idDebitLC), 
                input  if vlDomainIsStatutory then 0 else vdRoundDebitLC (idDebitCC), 
                input  0 (idDebitPC), 
                input  0 (idCreditTC), 
                input  0 (idCreditLC), 
                input  0 (idCreditCC), 
                input  0 (idCreditPC), 
                input  0 (idQty), 
                input  '':U (icLineText), 
                input  '':U (icSafText), 
                input  tConsolidSafs (tDefaultSafs), 
                input  '':U (icExchangeRateType), 
                input  0 (idExchangeRate), 
                input  0 (idExchangeRateScale), 
                input  ? (idPostingLineCCRate), 
                input  ? (idPostingLineCCScale), 
                output viPostingLineID (oiPostingLineId), 
                input  0 (iiSafStructureId), 
                input  '':U (icSafStructureCode), 
                input  ? (icAllocationKey), 
                input  false (ilLinkedCrCyDaemonReqExists), 
                input  ? (itExchangeRateDate), 
                output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>

            if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
            then assign oiReturnStatus = viFcReturnSuper.
            if oiReturnStatus < 0 and oiReturnStatus <> -98
            then leave POSTINGBLOCK.
        end.

        /* Rounding Posting for credit amounts */
        if vdRoundCreditLC <> 0
        then do:
            <M-42 run AddStandardPosting
               (input  vcPostingRowid (icPostingtcRowid), 
                input  tConsPosting.tcConsPostingRoundGLCode (icGLCode), 
                input  '':U (icDivisionCode), 
                input  '':U (icCostCentreCode), 
                input  '':U (icCostCentreText), 
                input  '':U (icProjectCode), 
                input  '':U (icProjectText), 
                input  '':U (icIntercoBusinessRelationCode), 
                input  tConsPosting.tcCurrencyCode (icCurrencyCode), 
                input  0 (idDebitTC), 
                input  0 (idDebitLC), 
                input  0 (idDebitCC), 
                input  0 (idDebitPC), 
                input  0 (idCreditTC), 
                input  vdRoundCreditLC (idCreditLC), 
                input  if vlDomainIsStatutory then 0 else vdRoundCreditLC (idCreditCC), 
                input  0 (idCreditPC), 
                input  0 (idQty), 
                input  '':U (icLineText), 
                input  '':U (icSafText), 
                input  tConsolidSafs (tDefaultSafs), 
                input  '':U (icExchangeRateType), 
                input  0 (idExchangeRate), 
                input  0 (idExchangeRateScale), 
                input  ? (idPostingLineCCRate), 
                input  ? (idPostingLineCCScale), 
                output viPostingLineID (oiPostingLineId), 
                input  0 (iiSafStructureId), 
                input  '':U (icSafStructureCode), 
                input  ? (icAllocationKey), 
                input  false (ilLinkedCrCyDaemonReqExists), 
                input  ? (itExchangeRateDate), 
                output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>

            if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
            then assign oiReturnStatus = viFcReturnSuper.
            if oiReturnStatus < 0 and oiReturnStatus <> -98
            then leave POSTINGBLOCK.
        end.
    end. /* if last-of(tConsPosting.tcConsPostingJournalCode) */
end. /* POSTINGBLOCK: for each tConsPosting ... */

/* Validate the posting */
<M-20 run ValidateBCAndAdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
then assign oiReturnStatus = viFcReturnSuper.

/* Stop the journal entry instance */
if viBJournalEntryConsolidID <> 0 and viBJournalEntryConsolidID <> ?
then do:
    <I-19 {bFcCloseInstance
            &CLASS           = "BJournalEntry"}>                               
end.

if oiReturnStatus = -98
then assign oiReturnStatus = 0.