I want to Validate that the Data is cleared and validate the calculate
Hi all -
We have a Labor Allocation Process that runs manually which we have seen some silent failures occur through our Api Calculate or Api Clear data. I am attempting to go through our business rules and add more complex logging to get a better understanding where/when these things occur.
Lets say I had this code block..
Dim sourceDims As String = "U2#None:U3#None:O#Import:I#None:F#None:V#Periodic:C#USD"Dim destinationDims As String = "U2#None:U3#None:O#Import:I#None:F#None:V#Periodic:C#USD"If args.CustomCalculateArgs.FunctionName.XFEqualsIgnoreCase("Copy3rdPartyImportData") Then'Only run for the Base Entities and local currencyIf (Not api.Entity.HasChildren()) And (api.Cons.IsLocalCurrencyForEntity())'Get the current scenario NameDim curScenarioName As String = api.Pov.Scenario.NameIf curScenarioName = "Rpt_Mar" Then'Clear previously calculated dataapi.Data.ClearCalculatedData(True, True, True, True,"A#3PFB_Capital","O#Import","I#None","V#Periodic","C#USD")api.Data.ClearCalculatedData(True, True, True, True,"A#3PFB_Expense","O#Import","I#None","V#Periodic","C#USD")api.Data.ClearCalculatedData(True, True, True, True,"A#Travel_Capital","O#Import","I#None","V#Periodic","C#USD")api.Data.ClearCalculatedData(True, True, True, True,"A#Travel_Expense","O#Import","I#None","V#Periodic","C#USD")'Seed Current Scenario with previous imported 3rd party dataapi.Data.Calculate("S#" & curScenarioName & ":A#3PFB_Capital:" & destinationDims & " = RemoveZeros(S#Rpt_Feb:A#3PFB_Capital:" & sourceDims & ")",True)api.Data.Calculate("S#" & curScenarioName & ":A#3PFB_Expense:" & destinationDims & " = RemoveZeros(S#Rpt_Feb:A#3PFB_Expense:" & sourceDims & ")",True)api.Data.Calculate("S#" & curScenarioName & ":A#Travel_Capital:" & destinationDims & " = RemoveZeros(S#Rpt_Feb:A#Travel_Capital:" & sourceDims & ")",True)api.Data.Calculate("S#" & curScenarioName & ":A#Travel_Expense:" & destinationDims & " = RemoveZeros(S#Rpt_Feb:A#Travel_Expense:" & sourceDims & ")",True)
I have tried:
Dim srcCap As Decimal = api.Data.GetDataCell("S#Rpt_Nov:A#3PFB_Capital:U1#TotUD1:U2#None:U3#None:U4#TotUD4:U5#None:U6#None:U7#None:U8#None:O#Import:I#None:F#None:V#Periodic:C#USD:E#CHN000").CellAmount
BRApi.ErrorLog.LogMessage(si, "SOURCE 3PFB_Capital=" & srcCap.ToString("N2"))
Which results in 0.
api.Data.Calculate(formula1, True)
Dim verify1 As Decimal = api.Data.GetDataCell("S#Rpt_Dec:A#3PFB_Capital:U1#TotUD1:U2#None:U3#None:U4#TotUD4:...E#" & api.Pov.Entity.Name).CellAmount
BRApi.ErrorLog.LogMessage(si, "DEST read-back=" & verify1.ToString("N2"))
same with something like this.