icDraftReference | input | character | Description for the draft instance. This parameter will have a value when creating a draft instance. |
icDraftFormName | input | character | This parameter will have a value when creating a draft instance. |
ilDraftIsShared | input | logical | This parameter will have a value when creating a draft instance. |
oiReturnStatus | output | integer | Return status of the method. |
<ANCESTOR-CODE> /* ================================================================= */ /* If the instance contains uncommitted dinvoices, do not wait for */ /* housekeeping to release the reserved number. Release it now. */ /* When saving a draft instance, store the number to protect it */ /* from being released by housekeeping. */ /* (do not release numbr when cancelling a draft) */ /* ================================================================= */ if viCurrentDraftInstanceId = 0 then for each tDInvoice where tDInvoice.tc_Status = "N":U and tDInvoice.DInvoiceVoucher <> 0 and tDInvoice.DInvoiceVoucher <> ?: if vlJOurnalQueryStarted = FALSE then do: <Q-64 run JournalBeginsForJEDefault (Start) in BJournal > assign vlJOurnalQueryStarted = TRUE. end. /* if vlJOurnalQueryStarted = FALSE */ <Q-97 run JournalBeginsForJEDefault (all) (Read) (NoCache) (input viCompanyId, (CompanyId) input tDInvoice.tcJournalCode, (JournalCode) input {&JOURNALCONTROL-LOGISTIC}, (JournalControl) input '':U, (JournalTypeCode) output dataset tqJournalBeginsForJEDefault) in BJournal > /* Obtain the type ofthe daybook to be used. */ find first tqJournalBeginsForJEDefault where tqJournalBeginsForJEDefault.tcJournalCode = tDInvoice.tcJournalCode and tqJournalBeginsForJEDefault.tcJournalControl = {&JOURNALCONTROL-LOGISTIC} no-lock no-error. if available tqJournalBeginsForJEDefault then assign vlJournalIsOperational = TRUE. else assign vlJournalIsOperational = FALSE. assign vhFcComponent = ?. if icDraftReference = "" then do: /* Release the voucher number */ if vlCCNIsConsecutNr = FALSE or vlJournalIsOperational = TRUE then do: <M-1 run ReleaseNumber (input viCompanyId (iiCompanyId), input tDInvoice.DInvoicePostingYear (iiNumbrYear), input tDInvoice.tcJournalCode (icNumbrType), input tDInvoice.DInvoiceVoucher (iiNumbr), input viFcCurrentInstanceId (iiInstanceId), input vcFcComponentName (icClassName), output viFcReturnSuper (oiReturnStatus)) in BNumber> /* ===================================================================================================== */ /* Following test is needed in case the posting was created externaly (methods ApiStdMaintainTT() */ /* and ApiStdMaintainMultiTT() in BCInvoiceJournalEntry, BDInvoiceJournalEntry and BPosting */ /* If the number was provided externaly and the action was 'validate', then Transaction.AbortTransaction */ /* is called (end thus ExitInstance in all components) which will try to release a number that was never */ /* picked-up by a call towards BNumber.GetNumber() */ /* ===================================================================================================== */ if viFcReturnSuper = -4 /* -4 means an invalid read : thus the number-record does not yet even exists */ then assign viFcReturnSuper = 0. end. /* if vlCCNIsConsecutNr = FALSE */ end. else do: if vlCCNIsConsecutNr = FALSE or vlJournalIsOperational = TRUE then do: <M-3 run StoreNumber (input viCompanyId (iiCompanyID), input tDInvoice.DInvoicePostingYear (iiNumbrYear), input tDInvoice.tcJournalCode (icNumbrType), input tDInvoice.DInvoiceVoucher (iiNumbr), output viFcReturnSuper (oiReturnStatus)) in BNumber> end. /* if vlCCNIsConsecutNr = FALSE */ end. if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0) then assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return. end. if viCurrentDraftInstanceId = 0 then for each tDInvoice where tDInvoice.tc_Status = "N":U and tDInvoice.DInvoiceType = {&INVOICETYPE-CREDITNOTE} and tDInvoice.tiDAVoucher <> 0 and tDInvoice.tiDAVoucher <> ?: if vlJOurnalQueryStarted = FALSE then do: <Q-60 run JournalBeginsForJEDefault (Start) in BJournal > assign vlJOurnalQueryStarted = TRUE. end. /* if vlJOurnalQueryStarted = FALSE */ /* Obtain the type of daybook to be used. */ <Q-61 run JournalBeginsForJEDefault (all) (Read) (NoCache) (input viCompanyId, (CompanyId) input tDInvoice.tcDAJournalCode, (JournalCode) input {&JOURNALCONTROL-LOGISTIC}, (JournalControl) input '':U, (JournalTypeCode) output dataset tqJournalBeginsForJEDefault) in BJournal > find first tqJournalBeginsForJEDefault where tqJournalBeginsForJEDefault.tcJournalCode = tDInvoice.tcDAJournalCode and tqJournalBeginsForJEDefault.tcJournalControl = {&JOURNALCONTROL-LOGISTIC} no-lock no-error. if available tqJournalBeginsForJEDefault then assign vlJournalIsOperational = TRUE. else assign vlJournalIsOperational = FALSE. assign vhFcComponent = ?. if icDraftReference = "" then do: /* Release the voucher number. */ if vlCCNIsConsecutNr = FALSE or vlJournalIsOperational = TRUE then do: <M-2 run ReleaseNumber (input viCompanyId (iiCompanyId), input tDInvoice.DInvoicePostingYear (iiNumbrYear), input tDInvoice.tcDAJournalCode (icNumbrType), input tDInvoice.tiDAVoucher (iiNumbr), input viFcCurrentInstanceId (iiInstanceId), input vcFcComponentName (icClassName), output viFcReturnSuper (oiReturnStatus)) in BNumber> /* ===================================================================================================== */ /* Following test is needed in case the posting was created externaly (methods ApiStdMaintainTT() */ /* and ApiStdMaintainMultiTT() in BCInvoiceJournalEntry, BDInvoiceJournalEntry and BPosting */ /* If the number was provided externaly and the action was 'validate', then Transaction.AbortTransaction */ /* is called (end thus ExitInstance in all components) which will try to release a number that was never */ /* picked-up by a call towards BNumber.GetNumber() */ /* ===================================================================================================== */ if viFcReturnSuper = -4 /* -4 means an invalid read : thus the number-record does not yet even exists */ then assign viFcReturnSuper = 0. end. /* if vlCCNIsConsecutNr = FALSE */ end. /* if icDraftReference = "" */ else do: if vlCCNIsConsecutNr = FALSE or vlJournalIsOperational = TRUE then do: <M-4 run StoreNumber (input viCompanyId (iiCompanyID), input tDInvoice.DInvoicePostingYear (iiNumbrYear), input tDInvoice.tcDAJournalCode (icNumbrType), input tDInvoice.tiDAVoucher (iiNumbr), output viFcReturnSuper (oiReturnStatus)) in BNumber> end. /* if vlCCNIsConsecutNr = FALSE */ end. /* NOT if icDraftReference = "" */ if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0) then assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return. end. /* if viCurrentDraftInstanceId = 0 */ if vlJOurnalQueryStarted = TRUE then do: <Q-82 run JournalBeginsForJEDefault (Stop) in BJournal > assign vlJOurnalQueryStarted = FALSE. end. /* if vlJOurnalQueryStarted = TRUE */