Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bcinvoiceapmatching.p)
/* =================================================================================================== */
/* Method : CreateCInvoiceRun */
/* Desc : Create supplier invoice(s) */
/* Method has to be in the same segment as CreateCInvoiceAPMatching */
/* =================================================================================================== */
assign oiReturnStatus = -98
viLocalReturn = 0.
CINVOICE_BLOCK:
do on error undo, return:
/* =============================================================================================== */
/* Check, if there are any Invoice records to be created */
/* =============================================================================================== */
if not can-find(first tCInvoiceRef)
then leave CINVOICE_BLOCK.
/* =============================================================================================== */
/* Start Supplier invoice Instance */
/* =============================================================================================== */
if viBCInvoiceFromBCIAPMID = 0 or
viBCInvoiceFromBCIAPMID = ?
then do:
<I-3 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "true"
&CLASS = "BCInvoice"}>
end.
else if not valid-handle(vhBCInvoiceFromBCIAPMInst)
then do:
<I-24 {bFcOpenInstance
&CLASS = "BCInvoice"}>
end.
/* =================================================================================================== */
/* Create supplier invoice */
/* =================================================================================================== */
for each tCInvoicePOBCIAPM :
assign vcPONbrForInv = tCInvoicePOBCIAPM.CInvoicePOPoNbr.
end. /* for each tCInvoicePOBCIAPM : */
<M-15 run CreateCInvoices
(input-output tCInvoiceBCIAPM (tOpenBalanceCI),
input ? (iiBJournalEntryId),
input ? (iiPostingId),
input vcPONbrForInv (icPONbrInv),
output vcInvoiceResult (ocNewRecordInfo),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper <> 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave CINVOICE_BLOCK.
/* Extract ID of created invoice */
find first tCInvoiceBCIAPM.
assign tCInvoiceRef.tiCInvoice_ID = tCInvoiceBCIAPM.tiInvoiceId.
if tCInvoiceRef.tiCInvoice_ID = ? or
tCInvoiceRef.tiCInvoice_ID = 0
then do:
assign vcContext = "tCInvoiceBCIAPM.tiInvoiceId.=" + string(tCInvoiceBCIAPM.tiInvoiceId).
<M-16 run SetMessage
(input #T-3'Cannot extract ID of created supplier invoice.':255(70386)T-3# (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-8402':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCInvoiceAPMatching>
assign viLocalReturn = -1.
leave CINVOICE_BLOCK.
end.
/* =================================================================================================== */
/* Create Supplier invoice PO details */
/* =================================================================================================== */
for each tCInvoicePOBCIAPM:
assign tCInvoicePOBCIAPM.CInvoice_ID = tCInvoiceRef.tiCInvoice_ID.
end.
if can-find(first tCInvoicePOBCIAPM)
then do:
<M-27 run AddCInvoicePO
(input tCInvoicePOBCIAPM (tCInvoicePOUpdate),
output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
if viFcReturnSuper <> 0 then assign viLocalReturn = viFcReturnSuper.
if viFcReturnSuper < 0 then leave CINVOICE_BLOCK.
end.
end. /* of CINVOICE_BLOCK: */
/* =================================================================================================== */
/* Return */
/* =================================================================================================== */
assign oiReturnStatus = viLocalReturn.