Description
Load the DI Posting
Parameters
iiDInvoiceId | input | integer | Debtor Invoice ID |
oiBJournalEntryId | output | integer | Instance of Journal Entry |
oiPostingId | output | integer | Posting ID of DI Posting |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program3/bdinvoice.p)
/* ====================== */
/* replace unknown values */
/* ====================== */
if iiDInvoiceId = ? then assign iiDInvoiceId = 0.
/* ======================== */
/* validate input parameter */
/* ======================== */
if iiDInvoiceId = 0
then do:
assign vcMessage = trim(#T-11'The customer invoice ID is mandatory.':150(49410)T-11#)
oiReturnStatus = -1.
<M-1 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-634':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
return.
end.
find first tDInvoice where
tDInvoice.DInvoice_ID = iiDInvoiceId
no-error.
if not available tDInvoice
then do:
assign vcMessage = trim(#T-12'The specified customer invoice is not defined in the system':150(49411)T-12#)
oiReturnStatus = -1.
<M-2 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-635':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
return.
end.
/* ============================== */
/* search the right DI Posting ID */
/* ============================== */
find first tDInvoicePosting where
tDInvoicePosting.DInvoice_Id = iiDInvoiceId
no-error.
if available tDInvoicePosting
then assign viPostingId = tDInvoicePosting.Posting_ID.
if viPostingId = 0
then do:
assign vcMessage = trim(#T-13'No CI posting record found for this customer invoice.':150(1762)T-13#)
oiReturnStatus = -1.
<M-4 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-636':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
return.
end.
/* ============================================ */
/* start and/or open the journal entry instance */
/* ============================================ */
if viBJournalEntryDIID = 0 or
viBJournalEntryDIID = ?
then do:
<I-5 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "true"
&CLASS = "BJournalEntry"}>
assign vlBJEIsStartedFromDI = true.
end.
else do:
<I-6 {bFcOpenInstance
&CLASS = "BJournalEntry"}>
end.
/* =============== */
/* load the record */
/* =============== */
<M-10 run DataLoad
(input '':U (icRowids),
input string(viPostingId) (icPkeys),
input '':U (icObjectIds),
input '' (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
/* ================================ */
/* close the journal entry instance */
/* ================================ */
<I-8 {bFcCloseInstance
&CLASS = "BJournalEntry"}>
if oiReturnStatus < 0
then do :
/* ======================= */
/* Stop external instances */
/* ======================= */
<M-14 run StopExternalInstances
(output viFcReturnSuper (oiReturnStatus)) in BDInvoice>
return.
end.
assign oiBJournalEntryID = viBJournalEntryDIID
oiPostingId = viPostingId.