project QadFinancials > class BCInvoice > method ValidateComponentPostPO

validation procedure

Description

This method is a submethod of ValidateComponentPost.
This method does some validations on table CInvoicePO that are done after the ancestor code of method ValidateComponent.
Note: the method is called from within a loop on tCInvoice and shoudl thus be in the same segment.


Parameters


blStart15input-outputlogicalIs query tqPurchaseOrderByDomianNbrVend already started or not ?
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.ValidateComponentPost


program code (program5/bcinvoice.p)

/* PODomain should be the same as vcDomainCode */
if (t_sCInvoice.tc_Status         = "N":U                         or
    t_sCInvoice.tc_Status         = "C":U                         and
    t_sCInvoice.CInvoicePoDomain <> t_iCInvoice.CInvoicePoDomain) and
    t_sCInvoice.CInvoicePoDomain <> "":U                          and
    t_sCInvoice.CInvoicePoDomain <> ?                             and
    t_sCInvoice.CInvoicePoDomain <> vcDomainCode
then do:
    <M-29 run SetMessage
       (input  trim(subst(#T-34'The PO domain (&1) does not match the invoice domain.':100(61374)t-34#, trim(t_sCInvoice.CInvoicePoDomain))) (icMessage), 
        input  '':U (icArguments), 
        input  'tCInvoice.CInvoicePoDomain':U (icFieldName), 
        input  t_sCInvoice.CInvoicePoDomain (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  t_sCInvoice.tc_Rowid (icRowid), 
        input  'QadFin-7183':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    assign oiReturnStatus = -1.
end.

if (t_sCInvoice.tc_Status                  = "N":U                                 or
    t_sCInvoice.tc_Status                  = "C":U                                 and
   (t_sCInvoice.Creditor_ID               <> t_iCInvoice.Creditor_ID               or
    t_sCInvoice.CInvoiceCurrency_ID       <> t_iCInvoice.CInvoiceCurrency_ID       or
    t_sCInvoice.NormalPaymentCondition_ID <> t_iCInvoice.NormalPaymentCondition_ID or
    t_sCInvoice.CInvoicePoDomain          <> t_iCInvoice.CInvoicePoDomain          or
    t_sCInvoice.CInvoicePoNbr             <> t_iCInvoice.CInvoicePoNbr))           and
    t_sCInvoice.CInvoicePoDomain          <> "":U                                  and
    t_sCInvoice.CInvoicePoDomain          <> ?                                     and
    t_sCInvoice.CInvoicePoNbr             <> "":U                                  and
    t_sCInvoice.CInvoicePoNbr             <> ?
then do:
    if not blStart15
    then do:
        <Q-38 run PurchaseOrderByDomainNbrVend  (Start) in BMfgPO >
        assign blStart15 = true.
    end.
    <Q-30 run PurchaseOrderByDomainNbrVend (all) (Read) (Cache)
       (input t_sCInvoice.CInvoicePoDomain, (DomainCode)
        input t_sCInvoice.CInvoicePoNbr, (PONbr)
        input ?, (POVendor)
        input ?, (POCurrency)
        input ?, (POType)
        output dataset tqPurchaseOrderByDomainNbrVend) in BMfgPO >
    find tqPurchaseOrderByDomainNbrVend where
         tqPurchaseOrderByDomainNbrVend.tcpo_domain = t_sCInvoice.CInvoicePoDomain and
         tqPurchaseOrderByDomainNbrVend.tcpo_nbr    = t_sCInvoice.CInvoicePoNbr
         no-error.
    if not available tqPurchaseOrderByDomainNbrVend
    then do:
        assign vcMessage      = trim(subst(#T-35'The system cannot find the purchase order based on the PO domain (&1) and PO number (&2) specified on the invoice (&3/&4/&5).':255(62536)t-35#, trim(t_sCInvoice.CInvoicePoDomain),trim(t_sCInvoice.CInvoicePoNbr), string(t_sCInvoice.CInvoicePostingYear),trim(t_sCInvoice.tcJournalCode), string(t_sCInvoice.CInvoiceVoucher)))
               oiReturnStatus = -1.
        <M-31 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tCInvoice.CInvoicePoNbr':U (icFieldName), 
            input  t_sCInvoice.CInvoicePoNbr (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sCInvoice.tc_Rowid (icRowid), 
            input  'QadFin-7184':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    end.
end.

/* Supplier and currency of the PO should match the corresponding field in the CI: error for the currency - warning for the supplier */
if available tqPurchaseOrderByDomainNbrVend and 
   (t_sCInvoice.tc_Status            = "N":U                                    or
    t_sCInvoice.tc_Status            = "C":U                                    and
   (t_sCInvoice.Creditor_ID         <> t_iCInvoice.Creditor_ID                  or
    t_sCInvoice.CInvoiceCurrency_ID <> t_iCInvoice.CInvoiceCurrency_ID          or
    t_sCInvoice.CInvoicePoDomain    <> t_iCInvoice.CInvoicePoDomain             or
    t_sCInvoice.CInvoicePoNbr       <> t_iCInvoice.CInvoicePoNbr))              and
    t_sCInvoice.CInvoicePoDomain    <> "":U                                     and
    t_sCInvoice.CInvoicePoDomain    <> ?                                        and
    t_sCInvoice.CInvoicePoNbr       <> "":U                                     and
    t_sCInvoice.CInvoicePoNbr       <> ? 
then do :
    if t_sCInvoice.tcCurrencyCode <> tqPurchaseOrderByDomainNbrVend.tcpo_curr
    then do :
        assign vcMessage      = trim(subst(#T-36'The currency &1 of the invoice &2 does not match the currency &3 of the purchase order &4/&5 defined in the matching scope of the invoice.':255(68782)t-36#,
                                           t_sCInvoice.tcCurrencyCode,
                                           string(t_sCInvoice.CInvoicePostingYear) + "/":U + t_sCInvoice.tcJournalCode + string(t_sCInvoice.CInvoiceVoucher, "999999999":U),
                                           tqPurchaseOrderByDomainNbrVend.tcpo_curr,
                                           t_sCInvoice.CInvoicePoDomain,
                                           t_sCInvoice.CInvoicePoNbr))
               oiReturnStatus = -1.
        <M-32 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tCInvoice.CInvoicePoNbr':U (icFieldName), 
            input  t_sCInvoice.CInvoicePoNbr (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sCInvoice.tc_Rowid (icRowid), 
            input  'QadFin-7185':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    end. /* if t_sCInvoice.tcCurrencyCode <> tqPurchaseOrderByDomainNbrVend.tcpo_curr */
    else 
        if t_sCInvoice.tcCreditorCode <> tqPurchaseOrderByDomainNbrVend.tcpo_vend 
        then do :
            assign vcMessage      = trim(subst(#T-41'The supplier (&1) of the invoice (&2) does not match the supplier (&3) of the purchase order (&4/&5) defined in the matching scope of the invoice':255(68778)T-41#,
                                               t_sCInvoice.tcCreditorCode,
                                               string(t_sCInvoice.CInvoicePostingYear) + "/":U + t_sCInvoice.tcJournalCode + string(t_sCInvoice.CInvoiceVoucher, "999999999":U),
                                               tqPurchaseOrderByDomainNbrVend.tcpo_vend,
                                               t_sCInvoice.CInvoicePoDomain,
                                               t_sCInvoice.CInvoicePoNbr))
                   oiReturnStatus = (if oiReturnStatus = 0 then +1 else oiReturnStatus).
            <M-40 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tCInvoice.CInvoicePoNbr':U (icFieldName), 
                input  t_sCInvoice.CInvoicePoNbr (icFieldValue), 
                input  'W':U (icType), 
                input  3 (iiSeverity), 
                input  t_sCInvoice.tc_Rowid (icRowid), 
                input  'QadFin-7826':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        end. /* if t_sCInvoice.tcCreditorCode <> tqPurchaseOrderByDomainNbrVend.tcpo_vend */
end. /* if (t_sCInvoice.tc_Status            = "N":U */

/* Payment condition (credit term) would match the corresponding field in the CI */
if available tqPurchaseOrderByDomainNbrVend and 
   (t_sCInvoice.tc_Status                     = "N":U                                 or
    t_sCInvoice.tc_Status                     = "C":U                                 and
   (t_sCInvoice.NormalPaymentCondition_ID    <> t_iCInvoice.NormalPaymentCondition_ID or
    t_sCInvoice.CInvoicePoDomain             <> t_iCInvoice.CInvoicePoDomain          or
    t_sCInvoice.CInvoicePoNbr                <> t_iCInvoice.CInvoicePoNbr))           and
    t_sCInvoice.CInvoicePoDomain             <> "":U                                  and
    t_sCInvoice.CInvoicePoDomain             <> ?                                     and
    t_sCInvoice.CInvoicePoNbr                <> "":U                                  and
    t_sCInvoice.CInvoicePoNbr                <> ?                                     and
    t_sCInvoice.tcNormalPaymentConditionCode <> tqPurchaseOrderByDomainNbrVend.tcpo_cr_terms
then do:
    assign vcMessage = trim(subst(#T-37'The payment condition (credit terms) (&1) of the invoice (&2) does not match the payment condition (&3) of the purchase order (&4/&5) defined in the matching scope of the invoice.':255(60875)t-37#,
                                  t_sCInvoice.tcNormalPaymentConditionCode,
                                  string(t_sCInvoice.CInvoicePostingYear) + "/":U + t_sCInvoice.tcJournalCode + string(t_sCInvoice.CInvoiceVoucher, "999999999":U),
                                  tqPurchaseOrderByDomainNbrVend.tcpo_cr_terms,
                                  t_sCInvoice.CInvoicePoDomain,
                                  t_sCInvoice.CInvoicePoNbr)).
    <M-33 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  'tCInvoice.CInvoicePoNbr':U (icFieldName), 
        input  t_sCInvoice.CInvoicePoNbr (icFieldValue), 
        input  'W':U (icType), 
        input  3 (iiSeverity), 
        input  t_sCInvoice.tc_Rowid (icRowid), 
        input  'QadFin-7186':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
    if oiReturnStatus = 0
    then assign oiReturnStatus = 1.
end.

for each t_sCInvoicePO where
         t_sCInvoicePO.tc_ParentRowid = t_sCInvoice.tc_Rowid and
        (t_sCInvoicePO.tc_status      = "N":U                or
         t_sCInvoicePO.tc_status      = "C":U):
    if t_sCInvoicePO.tc_Status = "C":U
    then do:
        find t_iCInvoicePO where
             t_iCInvoicePO.tc_Rowid = t_sCInvoicePO.tc_Rowid
             no-error.
        if not available t_iCInvoicePO
        then do:
            <M-27 run SetMessage
               (input  trim(#T-28'The system cannot find initial values for supplier invoice PO with purchase order $1 (Supplier Invoice $2 $3 $4).':255(65537)t-28#) (icMessage), 
                input  t_sCInvoicePO.CInvoicePOPoDomain + ' ':U + t_sCInvoicePO.CInvoicePOPoNbr + chr(2) + string(t_sCInvoice.CInvoicePostingYear) + chr(2) + t_sCInvoice.tcJournalCode + chr(2) + string(t_sCInvoice.CInvoiceVoucher) (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  '':U (iiSeverity), 
                input  t_sCInvoiceBank.tc_Rowid (icRowid), 
                input  'QadFin-7129':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
            assign oiReturnStatus = -1.
            next.
        end.
    end.
    /* PODomain should be the same as vcDomainCode */
    if (t_sCInvoicePO.tc_Status           = "N":U                             or
        t_sCInvoicePO.tc_Status           = "C":U                             and
        t_sCInvoicePO.CInvoicePOPoDomain <> t_iCInvoicePO.CInvoicePOPoDomain) and
        t_sCInvoicePO.CInvoicePOPoDomain <> vcDomainCode
    then do:
        <M-18 run SetMessage
           (input  trim(subst(#T-17'The PO domain (&1) does not match the invoice domain.':100(61374)t-17#, trim(t_sCInvoicePO.CInvoicePOPoDomain))) (icMessage), 
            input  '':U (icArguments), 
            input  'tCInvoicePO.CInvoicePOPoDomain':U (icFieldName), 
            input  t_sCInvoicePO.CInvoicePOPoDomain (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sCInvoicePO.tc_Rowid (icRowid), 
            input  'QadFin-6264':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        assign oiReturnStatus = -1.
    end.
    if (t_sCInvoice.tc_Status = "N":U or
        (t_sCInvoice.tc_Status = "C":U  and
         (t_sCInvoice.Creditor_ID               <> t_iCInvoice.Creditor_ID          or
          t_sCInvoice.CInvoiceCurrency_ID       <> t_iCInvoice.CInvoiceCurrency_ID  or
          t_sCInvoice.NormalPaymentCondition_ID <> t_iCInvoice.NormalPaymentCondition_ID)))  Or
       (t_sCInvoicePO.tc_Status = "N":U or
        (t_sCInvoicePO.tc_Status = "C":U and
         (t_sCInvoicePO.CInvoicePOPoDomain <> t_iCInvoicePO.CInvoicePOPoDomain or
          t_sCInvoicePO.CInvoicePOPoNbr    <> t_iCInvoicePO.CInvoicePOPoNbr)))
    then do:
        if not blStart15
        then do:
            <Q-39 run PurchaseOrderByDomainNbrVend  (Start) in BMfgPO >
            assign blStart15 = true.
        end.
        <Q-1 run PurchaseOrderByDomainNbrVend (all) (Read) (Cache)
           (input t_sCInvoicePO.CInvoicePOPoDomain, (DomainCode)
            input t_sCInvoicePO.CInvoicePOPoNbr, (PONbr)
            input ?, (POVendor)
            input ?, (POCurrency)
            input ?, (POType)
            output dataset tqPurchaseOrderByDomainNbrVend) in BMfgPO >
        find tqPurchaseOrderByDomainNbrVend where
             tqPurchaseOrderByDomainNbrVend.tcpo_domain = t_sCInvoicePO.CInvoicePOPoDomain and
             tqPurchaseOrderByDomainNbrVend.tcpo_nbr    = t_sCInvoicePO.CInvoicePOPoNbr
             no-error.
        if not available tqPurchaseOrderByDomainNbrVend
        then do:
            assign vcMessage      = trim(subst(#T-25'The system cannot find the purchase order based on the PO domain (&1) and PO number (&2) that are specified on the invoice (&3/&4/&5).':255(62537)t-25#, trim(t_sCInvoicePO.CInvoicePOPoDomain),trim(t_sCInvoicePO.CInvoicePOPoNbr), string(t_sCInvoice.CInvoicePostingYear),trim(t_sCInvoice.tcJournalCode), string(t_sCInvoice.CInvoiceVoucher)))
                   oiReturnStatus = -1.
            <M-23 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tCInvoice.CInvoicePoNbr':U (icFieldName), 
                input  t_sCInvoice.CInvoicePoNbr (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sCInvoice.tc_Rowid (icRowid), 
                input  'QadFin-6363':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        end.
    end.
    /* Supplier and currency of the PO's should match the corresponding field in the CI: error for the currency - warning for the supplier */
    if available tqPurchaseOrderByDomainNbrVend and 
       ((t_sCInvoice.tc_Status             = "N":U                                    or
         t_sCInvoice.tc_Status             = "C":U                                    and
        (t_sCInvoice.Creditor_ID          <> t_iCInvoice.Creditor_ID                  or
         t_sCInvoice.CInvoiceCurrency_ID  <> t_iCInvoice.CInvoiceCurrency_ID))        or
        (t_sCInvoicePO.tc_Status           = "N":U                                    or
         t_sCInvoicePO.tc_Status           = "C":U                                    and
        (t_sCInvoicePO.CInvoicePOPoDomain <> t_iCInvoicePO.CInvoicePOPoDomain         or
         t_sCInvoicePO.CInvoicePOPoNbr    <> t_iCInvoicePO.CInvoicePOPoNbr)))
    then do :
        if t_sCInvoice.tcCurrencyCode <> tqPurchaseOrderByDomainNbrVend.tcpo_curr
        then do :
            assign vcMessage      = trim(subst(#T-2'The currency &1 of the invoice &2 does not match the currency &3 of the purchase order &4/&5 defined in the matching scope of the invoice.':255(68782)t-2#,
                                               t_sCInvoice.tcCurrencyCode,
                                               string(t_sCInvoice.CInvoicePostingYear) + "/":U + t_sCInvoice.tcJournalCode + string(t_sCInvoice.CInvoiceVoucher, "999999999":U),
                                               tqPurchaseOrderByDomainNbrVend.tcpo_curr,
                                               t_sCInvoicePO.CInvoicePOPoDomain,
                                               t_sCInvoicePO.CInvoicePOPoNbr))
                   oiReturnStatus = -1.
            <M-3 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tCInvoicePO.CInvoicePOPoNbr':U (icFieldName), 
                input  t_sCInvoicePO.CInvoicePOPoNbr (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sCInvoicePO.tc_Rowid (icRowid), 
                input  'QadFin-5904':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        end. /* if t_sCInvoice.tcCurrencyCode <> tqPurchaseOrderByDomainNbrVend.tcpo_curr */
        else 
            if t_sCInvoice.tcCreditorCode <> tqPurchaseOrderByDomainNbrVend.tcpo_vend 
            then do :
                assign vcMessage      = trim(subst(#T-43'The supplier (&1) of the invoice (&2) does not match the supplier (&3) of the purchase order (&4/&5) defined in the matching scope of the invoice':255(68778)T-43#,
                                                   t_sCInvoice.tcCreditorCode,
                                                   string(t_sCInvoice.CInvoicePostingYear) + "/":U + t_sCInvoice.tcJournalCode + string(t_sCInvoice.CInvoiceVoucher, "999999999":U),
                                                   tqPurchaseOrderByDomainNbrVend.tcpo_vend,
                                                   t_sCInvoicePO.CInvoicePOPoDomain,
                                                   t_sCInvoicePO.CInvoicePOPoNbr))
                       oiReturnStatus = (if oiReturnStatus = 0 then +1 else oiReturnStatus).
                <M-42 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'tCInvoicePO.CInvoicePOPoNbr':U (icFieldName), 
                    input  t_sCInvoicePO.CInvoicePOPoNbr (icFieldValue), 
                    input  'W':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sCInvoicePO.tc_Rowid (icRowid), 
                    input  'QadFin-7827':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
            end. /* t_sCInvoice.tcCreditorCode  <> tqPurchaseOrderByDomainNbrVend.tcpo_vend */
    end. /* if ((t_sCInvoice.tc_Status  = "N":U  */
    /* Payment condition (credit term) would match the corresponding field in the CI */
    if available tqPurchaseOrderByDomainNbrVend and 
       ((t_sCInvoice.tc_Status                     = "N":U                                  or
         t_sCInvoice.tc_Status                     = "C":U                                  and
         t_sCInvoice.NormalPaymentCondition_ID    <> t_iCInvoice.NormalPaymentCondition_ID) or
        (t_sCInvoicePO.tc_Status                   = "N":U                                  or
         t_sCInvoicePO.tc_Status                   = "C":U                                  and
        (t_sCInvoicePO.CInvoicePOPoDomain         <> t_iCInvoicePO.CInvoicePOPoDomain       or
         t_sCInvoicePO.CInvoicePOPoNbr            <> t_iCInvoicePO.CInvoicePOPoNbr)))       and
         t_sCInvoice.tcNormalPaymentConditionCode <> tqPurchaseOrderByDomainNbrVend.tcpo_cr_terms
    then do:
        assign vcMessage = trim(subst(#T-5'The payment condition (credit terms) (&1) of the invoice (&2) does not match the payment condition (&3) of the purchase order (&4/&5) defined in the matching scope of the invoice.':255(60875)t-5#,
                                      t_sCInvoice.tcNormalPaymentConditionCode,
                                      string(t_sCInvoice.CInvoicePostingYear) + "/":U + t_sCInvoice.tcJournalCode + string(t_sCInvoice.CInvoiceVoucher, "999999999":U),
                                      tqPurchaseOrderByDomainNbrVend.tcpo_cr_terms,
                                      t_sCInvoicePO.CInvoicePOPoDomain,
                                      t_sCInvoicePO.CInvoicePOPoNbr)).
        <M-6 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tCInvoicePO.CInvoicePOPoNbr':U (icFieldName), 
            input  t_sCInvoicePO.CInvoicePOPoNbr (icFieldValue), 
            input  'W':U (icType), 
            input  3 (iiSeverity), 
            input  t_sCInvoicePO.tc_Rowid (icRowid), 
            input  'QadFin-6172':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        if oiReturnStatus = 0
        then assign oiReturnStatus = 1.
    end.
    if vcActivityCode <> "Reverse":U            and 
       vcActivityCode <> "Replace":U            and 
       (t_sCInvoicePO.tc_Status = "N":U or
        (t_sCInvoicePO.tc_Status = "C":U and
         (t_sCInvoicePO.CInvoicePOPoDomain <> t_iCInvoicePO.CInvoicePOPoDomain or
          t_sCInvoicePO.CInvoicePOPoNbr    <> t_iCInvoicePO.CInvoicePOPoNbr)))
    then do :
        <Q-44 assign vlFcQueryRecordsAvailable = PendingVoucherForPoOpenPvo (NoCache)
           (input t_sCInvoicePO.CInvoicePOPoDomain, (PoDomainCode)
            input t_sCInvoicePO.CInvoicePOPoNbr, (PoNumber)) in BMfgPendingVoucher >
        if vlFcQueryRecordsAvailable = false
        then do : 
            assign vcMessage      = trim(substitute(#T-46'Purchase order (&1) of invoice (&2) has got nothing to be matched anymore. All pending invoices of the order may already be finished.':255(69607)t-46#,
                                                    trim(t_sCInvoicePO.CInvoicePOPoDomain) + "/":U + trim(t_sCInvoicePO.CInvoicePOPoNbr),
                                                    string(t_sCInvoice.CInvoicePostingYear) + "/":U + t_sCInvoice.tcJournalCode + "/":U + string(t_sCInvoice.CInvoiceVoucher,"999999999":U) + "/":U + string(t_sCInvoice.CInvoiceRegistrationNr)))
                   oiReturnStatus = (if oiReturnStatus = 0 then +1 else oiReturnStatus).
            <M-45 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tCInvoicePO.CInvoicePOPoNbr':U (icFieldName), 
                input  t_sCInvoicePO.CInvoicePOPoNbr (icFieldValue), 
                input  'W':U (icType), 
                input  3 (iiSeverity), 
                input  t_sCInvoicePO.tc_Rowid (icRowid), 
                input  'QadFin-8190':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        end. /* if vlFcQueryRecordsAvailable = false */
    end. /* if vcActivityCode <> "Reverse":U            and  */
    
end. /* for each */