CA5
7 months agoNew Contributor
Data Buffer Calculation
Hi everyone,
I'm trying to create a formula for an account member that includes different accounts and UDs. I'm trying to do something like this: (A#COMMODITY_GM = A#GROSS_MARGIN - A#NET_INCOME:U2#WC - A#NET_INCOME:U2#US + A#503099:U2#EC - A#FINANCE_EXPENSE:U3#OTHERGRN)
I found in the book Finance Rules and Calculations a possible solution using a Data Buffer, so I came up with the following formula:
Dim grossmarginDataBuffer As DataBuffer = api.Data.GetDataBufferUsingFormula("A#GROSS_MARGIN:U8#None")
api.Data.FormulaVariables.SetDataBufferVariable("GROSS_MARGIN",grossmarginDataBuffer, False)
Dim netincomeWCDataBuffer As DataBuffer = api.Data.GetDataBufferUsingFormula("A#NET_INCOME:U2#WC:U8#None")
api.Data.FormulaVariables.SetDataBufferVariable("NET_INCOME_WC" , netincomeWCDataBuffer , False)
Dim netincomeUSDataBuffer As DataBuffer = api.Data.GetDataBufferUsingFormula("A#NET_INCOME:U2#US:U8#NONE")
api.Data.FormulaVariables.SetDataBufferVariable("NET_INCOME_US" , netincomeUSDataBuffer , False)
Dim grainposDataBuffer As DataBuffer = api.Data.GetDataBufferUsingFormula("A#503099:U2#EC:U8#NONE")
api.Data.FormulaVariables.SetDataBufferVariable("GRAIN_POSITIONING" , grainposDataBuffer , False)
Dim finexpDataBuffer As DataBuffer = api.Data.GetDataBufferUsingFormula("A#FINANCE_EXPENSE:U3#OTHERGRN:U8#NONE")
api.Data.FormulaVariables.SetDataBufferVariable("FINANCE_EXPENSE" , finexpDataBuffer , False)
Return api.Data.Calculate("A#TEST_GM_GRAIN = $GROSS_MARGIN*1 , $NET_INCOME_WC*-1 , $NET_INCOME_US*1, $GRAIN_POSITIONING*1 , $FINANCE_EXPENSE*-1")
It calculates but only retrieves the result of the first argument $GROSS_MARGIN*1. Am I missing any step in the formula?
Thanks in advance,
Camila
I