Description
Actions to take after writing current instance to the database, and before final commit of the transaction.
Use the field tc_status to test the status of the updated records:
'' = unchanged
'N' = new
'C' = changed
'D' = deleted
Parameters
oiReturnStatus | output | integer | |
Internal usage
unused
program code (program/bposting.p)
<ANCESTOR-CODE>
/* ================================================ */
/* Return in case the ancestor-code raised an error */
/* ================================================ */
if oiReturnStatus < 0
then return.
/* ================================================ */
/* Commit the numbers as now the posting gets saved */
/* ================================================ */
BNUMBERCOMMITBLOCK:
for each tposting
no-lock :
/* ================================= */
/* Commit the general posting number */
/* ================================= */
if can-find (tCommitNumber where
tCommitNumber.tcNumberType = {&COMMITNUMBERTYPE-POSTINGVOUCHER} and
tCommitNumber.tcPostingRowID = tPosting.tc_Rowid) and
tPosting.PostingVoucher <> 0 and tPosting.PostingVoucher <> ?
then do:
/* Start&Open BNumber (AddToTrx=false) as in a loop below we will be calling BNumber repetively and this */
/* is more performing then using vhFcComponent=?. BNumber will be closed and stopped after the loop */
if viBNumberFromBPostingID = 0 or viBNumberFromBPostingID = ?
then do :
<I-63 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "false"
&CLASS = "BNumber"}>
end. /* if viBNumberFromBPostingID = 0 or viBNumberFromBPostingID = ? */
<M-1 run CommitNumber
(input tPosting.Company_ID (iiCompanyID),
input tPosting.PostingYear (iiNumbrYear),
input tPosting.tcJournalCode (icNumbrType),
input tPosting.PostingVoucher (iiNumbr),
input viFcCurrentInstanceId (iiInstanceId),
input vcFcComponentName (icClassName),
output oiReturnStatus (oiReturnStatus)) in BNumber>
if viFcReturnSuper <> 0
then assign viBlockReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave BNUMBERCOMMITBLOCK.
end. /* if tPosting.PostingVoucher <> 0 and tPosting.PostingVoucher <> ? */
/* ================================== */
/* Commit the Additional GL Numbering */
/* ================================== */
if can-find (tCommitNumber where
tCommitNumber.tcNumberType = {&COMMITNUMBERTYPE-POSTINGADDGLNBR} and
tCommitNumber.tcPostingRowID = tPosting.tc_Rowid) and
tPosting.PostingAddGLNbr <> 0 and tPosting.PostingAddGLNbr <> ?
then do:
/* Start&Open BNumber (AddToTrx=false) as in a loop below we will be calling BNumber repetively and this */
/* is more performing then using vhFcComponent=?. BNumber will be closed and stopped after the loop */
if viBNumberFromBPostingID = 0 or viBNumberFromBPostingID = ?
then do :
<I-90 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "false"
&CLASS = "BNumber"}>
end. /* if viBNumberFromBPostingID = 0 or viBNumberFromBPostingID = ? */
<M-4 run CommitNumber
(input tPosting.tiSharedCompanyId (iiCompanyID),
input tPosting.tiYearForNbr (iiNumbrYear),
input {&FIXEDJOURNALTYPE} (icNumbrType),
input tPosting.PostingAddGLNbr (iiNumbr),
input viFcCurrentInstanceId (iiInstanceId),
input vcFcComponentName (icClassName),
output viFcReturnSuper (oiReturnStatus)) in BNumber>
if viFcReturnSuper <> 0
then assign viBlockReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then Leave BNUMBERCOMMITBLOCK.
end. /* if tPosting.PostingAddGLNbr <> 0 and tPosting.PostingAddGLNbr <> ? */
end. /* for each tposting where */
/* Close&Stop BNumber that is started with a different transaction before the previous loop */
if viBNumberFromBPostingID <> 0 and
viBNumberFromBPostingID <> ?
then do :
<I-44 {bFcCloseAndStopInstance
&CLASS = "BNumber"}>
end. /* if viBNumberFromBPostingID <> 0 and viBNumberFromBPostingID <> ? */
if viBlockReturnStatus <> 0
then assign oiReturnStatus = viBlockReturnStatus.
if oiReturnStatus < 0
then Return.
/* ==================================================== */
/* Update the Originator reference for chnaged postings */
/* ==================================================== */
for each tposting where
tPosting.tc_Status = 'C':U
no-lock :
/* Find the original posting */
find t_iPosting where
t_iPosting.tc_RowId = tPosting.tc_RowId
no-error.
if not available t_iPosting
then do:
assign vcSetMessage = #T-7'Original Posting records not available.':255(733714483)T-7#.
<M-8 run SetMessage
(input vcSetMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-9501':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
assign oiReturnStatus = -1.
return.
end. /* if not available t_iPosting */
/* execute this change, only when: */
/* a) The daybook has been changed. */
/* b) The posting year. */
/* c) The voucher has been changed. */
if tPosting.PostingYear <> t_iPosting.PostingYear or
tPosting.tcJournalCode <> t_iPosting.tcJournalCode or
tPosting.PostingVoucher <> t_iPosting.PostingVoucher
then do:
assign vcOriginalOriginatorReference = substitute("&1/&2/&3":U,
string(t_iPosting.PostingYear,"9999":U),
t_iPosting.tcJournalCode,
string(t_iPosting.PostingVoucher,"999999999":U))
vcStatement = 'for each Posting where ':U +
'Posting.Company_ID = &1 and Posting.PostingOriginatorReference = ''&2''':U
vcStatement = substitute(vcStatement, viCompanyId, vcOriginalOriginatorReference)
vcNewOriginatorReference = substitute("&1/&2/&3":U,
tPosting.PostingYear,
tPosting.tcJournalCode,
string(tPosting.PostingVoucher,"999999999":U)).
/* check if there is another posting which refered this posting, otherwise WriteDirect method will give error */
<Q-10 assign vlFcQueryRecordsAvailable = PostingByReverseOriginatorRef (NoCache)
(input tPosting.Company_ID, (CompanyId)
input vcOriginalOriginatorReference, (PostingOriginatorReference)
input ?, (PostingIsReplacement)
input ?, (PostingIsReversing)
input '':U, (SkipRowid)) in BPosting >
if vlFcQueryRecordsAvailable <> false
then do:
if vcOriginalOriginatorReference <> vcNewOriginatorReference
then do :
<M-5 run StartPersistence
(output vhFcComponent (ohPersistence),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-6 run WriteDirect
(input 'Posting':U (icTableName),
input vcStatement (icPrepare),
input 'PostingOriginatorReference':U (icFieldList),
input 'c':U (icFieldListDataTypes),
input vcNewOriginatorReference (icAbsolute),
input '':U (icIncremental),
input {&TARGETPROCEDURE} (ihClass),
input vcUserLogin (icUserLogin),
output viFcReturnSuper (oiReturnStatus)) in Progress>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
end. /* if vcOriginalOriginatorReference <> vcNewOriginatorReference */
end. /* if vlFcQueryRecordsAvailable <> false */
end. /* if tPosting.PostingYear <> t_iPosting.PostingYear */
end. /* for each tposting where tPosting.tc_Status = 'C':U */
/* ====================================================================================================================== */
/* IMPORTANT NOTE: */
/* The normal process is that updates towards other classes are done through the normal approach with Starting&Opening */
/* the external instance and then call a method in there. But as that decreases the performance to much for frequently */
/* used actions like the creation of the QPostingLine- and QPostingSaf-records, we will here do the creation of these */
/* records here via dynamic buffers. */
/* Note that the tApiQPostingLineBank-records (same as the QPostingLine-records but using Banl-GL-accounts) are still */
/* processed using the standard approach as they don't need to be just created but also on-line processed; they still */
/* will use the normal calls through the normal process in AdditionalUpdatesBQPosting */
/* All temp-tables records (tApiQPostingLine, tApiQPostingSaf, tApiQPostingLineBank and tApiQPostingSafBank) are still */
/* created in AdditionalUpdatesCreateQPostingLineN) regardless how they are created in the db later on */
/* ====================================================================================================================== */
<M-87 run PostSaveDynamicCreations
(output viDummy (oiNbrOfCreatedQPostingLine),
output viDummy (oiNbrOfCreatedQPostingSaf),
output viDummy (oiNbrOfCreatedQBudgetLinkActual),
output viFcReturnSuper (oiReturnStatus)) in BPosting>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.