project QadFinancials > class BAPMatching > method CancelAPMatching

Description

This method cancels the AP Matchings related to specified Supplier Invoice


Parameters


iiCInvoiceIdinputinteger
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.AdditionalUpdatesAllAPMatching


program code (program8/bapmatching.p)

/* =================================================================================================== */
/* Method      : CancelAPMatching                                                                      */
/* Desc        : This method cancels the AP Matchings related to specified Supplier Invoice            */
/* --------------------------------------------------------------------------------------------------- */
/* Params:  (I)  CInvoiceId           ID of the Supplier Invoice to be canceled                        */
/* =================================================================================================== */

/* =================================================================================================== */
/* Initialiaztion                                                                                      */
/* =================================================================================================== */
assign oiReturnStatus = -98.

/* =================================================================================================== */
/* Find AP Matching By Supplier Invoice ID                                                             */
/* =================================================================================================== */
<Q-5 run APMatchingByCInvoice (all) (Read) (NoCache)
   (input ?, (CompanyId)
    input iiCInvoiceId, (CInvoiceId)
    input ?, (CInvoiceYear)
    input ?, (CInvoiceJournalCode)
    input ?, (CInvoiceVoucher)
    output dataset tqAPMatchingByCInvoice) in BAPMatching >
for each tqAPMatchingByCInvoice no-lock:
    find tAPMatching where
         tAPMatching.APMatching_ID = tqAPMatchingByCInvoice.tiAPMatching_ID
         no-error.
    if not available tAPMatching
    then do:
        if vcList = "":U
        then assign vcList = string (tqAPMatchingByCInvoice.tiAPMatching_ID).
        else if lookup (string(tqAPMatchingByCInvoice.tiAPMatching_ID), vcList, chr(4)) = 0
             then assign vcList = vcList + chr(4) + string(tqAPMatchingByCInvoice.tiAPMatching_ID).
    end.
end.

/* =================================================================================================== */
/* Load AP Matching Records related to the Supplier Invoice                                            */
/* =================================================================================================== */
if vcList <> "":U
then do:
    <M-1 run DataLoad
       (input  '':U (icRowids), 
        input  vcList (icPkeys), 
        input  '':U (icObjectIds), 
        input  '':U (icFreeform), 
        input  false (ilKeepPrevious), 
        output viFcReturnSuper (oiReturnStatus)) in BAPMatching>
    if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0 then return.
end.

/* =================================================================================================== */
/* Set status of loaded AP Matching records to "Cancel"                                                */
/* =================================================================================================== */
for each tAPMatching where 
         tAPMatching.CInvoice_ID = iiCInvoiceId:
    assign tAPMatching.APMatchingStatus = {&APMATCHINGSTATUS-CANCEL}
           tAPMatching.tc_Status        = 'C':U.
end.

/* =================================================================================================== */
/* Return                                                                                              */
/* =================================================================================================== */
if oiReturnStatus = -98 then assign oiReturnStatus = 0.