| iiPostingID | input | integer | Posting ID; mandtaory; identification of the posting If empty or there is no such posting then all output will be zero and no error will be raised |
| ocCurrencyCode | output | character | Currency code of the posting. This parameter is filled in only when all posting lines where a TC-amount is filled have the same currencly. Otherwise it is blank. |
| odTCLCExchangeRate | output | decimal | TCLCExchangeRate: filled if all postinglines have the same currency and all lines have the same Rate/Scale between TC and LC. If this is not the case then the output will be zero. |
| odTCLCExchangeScale | output | decimal | TCLCExchangeScale: filled if all postinglines have the same currency and all lines have the same Rate/Scale between TC and LC. If this is not the case then the output will be zero. |
| odTCCCExchangeRate | output | decimal | TCCCExchangeRate: filled if all postinglines have the same currency and all lines have the same Rate/Scale between TC and CC. If this is not the case then the output will be zero. |
| odTCCCExchangeScale | output | decimal | TCCCExchangeScale: filled if all postinglines have the same currency and all lines have the same Rate/Scale between TC and CC. If this is not the case then the output will be zero. |
| odPostingAmountDebitTC | output | decimal | PostingAmountDebitTC |
| odPostingAmountCreditTC | output | decimal | Posting Amount in CreditTC |
| odPostingAmountDebitLC | output | decimal | PostingAmountDebitLC |
| odPostingAmountCreditLC | output | decimal | Posting Amount in CreditLC; |
| odPostingAmountDebitCC | output | decimal | PostingAmountDebitCC |
| odPostingAmountCreditCC | output | decimal | Posting Amount in CreditCC |
| oiReturnStatus | output | integer | Return status of the method. |
QadFinancials
/* ========================= */
/* Exception handling */
/* ========================= */
assign oiReturnStatus = -98
viLocalReturn = 0.
/* ========================================================================== */
/* Default output parameters */
/* Set all to unknown as an indication that it has not yet been assigned once */
/* ========================================================================== */
assign ocCurrencyCode = ?
odTCCCExchangeRate = ?
odTCCCExchangeScale = ?
odTCLCExchangeRate = ?
odTCLCExchangeScale = ?.
/* ========================= */
/* Start processing block */
/* ========================= */
PLCALCULATIONBLOCK: do on error undo, leave:
/* =============== */
/* get the posting */
/* =============== */
find first tPosting where
tPosting.Posting_ID = iiPostingId
no-error.
if not available tPosting or
tPosting.tc_Status = "D":U
then return.
/* ============================================= */
/* Go through all undeleted lines of the posting */
/* ============================================= */
for each tPostingLine where
tPostingLine.tc_ParentRowid = tPosting.tc_Rowid and
tPostingLine.tc_Status <> "D":U :
/* ====================================================================================================== */
/* Set ocCurrencyCode: it has to be a single currency in case all posting-lines contain the same currency */
/* If multiple currencies are used then ocCurrency will be set to blank */
/* Only take posting-lines into account where TC-amoutns are filled */
/* Same applies for filling the output params on the rate/scale */
/* ====================================================================================================== */
if (tPostingLine.PostingLineCreditTC <> 0 and
tPostingLine.PostingLineCreditTC <> ?) or
(tPostingLine.PostingLineDebitTC <> 0 and
tPostingLine.PostingLineDebitTC <> ?)
then do :
if ocCurrencyCode = ? /* this means this is the first posting-line */
then assign ocCurrencyCode = tPostingLine.tcCurrencyCode.
if ocCurrencyCode <> "":U and /* blank means we already detected multiple currencies and we want to keep that indication */
ocCurrencyCode <> tPostingLine.tcCurrencyCode
then assign ocCurrencyCode = "":U.
if odTCLCExchangeRate = ? and
odTCLCExchangeScale = ? /* this means this is the first posting-line */
then assign odTCLCExchangeRate = (if tPostingLine.PostingLineExchangeRate = ? then 0 else tPostingLine.PostingLineExchangeRate)
odTCLCExchangeScale = (if tPostingLine.PostingLineRateScale = ? then 0 else tPostingLine.PostingLineRateScale).
if odTCLCExchangeRate <> 0 and /* zero means we already detected multiple rates/scales and we want to keep that indication */
odTCLCExchangeScale <> 0 and
(odTCLCExchangeRate <> tPostingLine.PostingLineExchangeRate or
odTCLCExchangeScale <> tPostingLine.PostingLineRateScale)
then assign odTCLCExchangeRate = 0
odTCLCExchangeScale = 0.
if odTCCCExchangeRate = ? and
odTCCCExchangeScale = ? /* this means this is the first posting-line */
then assign odTCCCExchangeRate = (if tPostingLine.PostingLineCCRate = ? then 0 else tPostingLine.PostingLineCCRate)
odTCCCExchangeScale = (if tPostingLine.PostingLineCCScale = ? then 0 else tPostingLine.PostingLineCCScale).
if odTCCCExchangeRate <> 0 and /* zero means we already detected multiple rates/scales and we want to keep that indication */
odTCCCExchangeScale <> 0 and
(odTCCCExchangeRate <> tPostingLine.PostingLineCCRate or
odTCCCExchangeScale <> tPostingLine.PostingLineCCScale)
then assign odTCCCExchangeRate = 0
odTCCCExchangeScale = 0.
end. /* if (tPostingLine.PostingLineCreditTC <> 0 and */
/* ======================== */
/* Cumulate posting amounts */
/* ======================== */
accumulate tPostingLine.PostingLineDebitTC(TOTAL).
accumulate tPostingLine.PostingLineCreditTC(TOTAL).
accumulate tPostingLine.PostingLineDebitLC(TOTAL).
accumulate tPostingLine.PostingLineCreditLC(TOTAL).
accumulate tPostingLine.PostingLineDebitCC(TOTAL).
accumulate tPostingLine.PostingLineCreditCC(TOTAL).
end. /* for each tPostingLine where */
/* ============================= */
/* Output parameters assignment */
/* ============================= */
assign odPostingAmountDebitTC = accum total tPostingLine.PostingLineDebitTC
odPostingAmountCreditTC = accum total tPostingLine.PostingLineCreditTC
odPostingAmountDebitLC = accum total tPostingLine.PostingLineDebitLC
odPostingAmountCreditLC = accum total tPostingLine.PostingLineCreditLC
odPostingAmountDebitCC = accum total tPostingLine.PostingLineDebitCC
odPostingAmountCreditCC = accum total tPostingLine.PostingLineCreditCC.
END. /* of PLCALCULATIONBLOCK */
/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturn.