project QadFinancials > class BCurrency > method UpdateNumberOfDecimals
Description
This method will use the rounding method ids as input parameter to find the currencies and update the Currency Number of Decimals.
Parameters
tCurrUpdatesFromRounding | input | temp-table | Temp-table containing Rounding Method Id. |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bcurrency.p)
<M-3 run ClearData
(output viFcReturnSuper (oiReturnStatus)) in BCurrency>
<Q-1 run CurrencyByRoundMethodId
(Start) in BCurrency >
UPDATEBLOCK:
for each tCurrUpdatesFromRounding:
<Q-2 run CurrencyByRoundMethodId (all) (Read) (NoCache)
(input tCurrUpdatesFromRounding.tiRoundingMethodID, (RoundingMethodId)
output dataset tqCurrencyByRoundMethodId) in BCurrency >
assign vcCurrencyIDList = "":U.
for each tqCurrencyByRoundMethodId where
tqCurrencyByRoundMethodId.tiRoundingMethod_ID = tCurrUpdatesFromRounding.tiRoundingMethodID:
assign vcCurrencyIDList = if vcCurrencyIDList = "":U
then string(tqCurrencyByRoundMethodId.tiCurrency_ID)
else vcCurrencyIDList + chr(4) + string(tqCurrencyByRoundMethodId.tiCurrency_ID).
end.
if vcCurrencyIDList <> "":U
then do:
<M-4 run DataLoad
(input '':U (icRowids),
input vcCurrencyIDList (icPkeys),
input '':U (icObjectIds),
input '':U (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BCurrency>
/* Update the currencies */
for each tqCurrencyByRoundMethodId where
tqCurrencyByRoundMethodId.tiRoundingMethod_ID = tCurrUpdatesFromRounding.tiRoundingMethodID:
find tCurrency where
tCurrency.Currency_ID = tqCurrencyByRoundMethodId.tiCurrency_ID
no-error.
if not available tCurrency
then do:
assign vcMessage = trim(substitute(#T-5'Cannot find currency with ID: &1':150(65132)t-5#,
string(tqCurrencyByRoundMethodId.tiCurrency_ID)))
oiReturnStatus = -3.
<M-6 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-6927':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCurrency>
leave UPDATEBLOCK.
end. /* if not available tCurrency */
assign tCurrency.CurrencyNumberOfDecimals = tCurrUpdatesFromRounding.tdCurrencyNumberOfDecimals
tCurrency.tc_Status = "C":U.
end. /* for each tqCurrencyByRoundMethodId */
end. /* if vcCurrencyIDList <> "" */
end. /* for each tCurrUpdatesFromRounding */
<Q-7 run CurrencyByRoundMethodId
(Stop) in BCurrency >
/* AdditionalUpdates is not needed since only CurrencyNumberOfDecimals needs to be updated */
<M-8 run ValidateBC
(output viFcReturnSuper (oiReturnStatus)) in BCurrency>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus >= 0)
then assign oiReturnStatus = viFcReturnSuper.