Data Buffer in Stored Calc is not working during Condolidation
Hi All - I am trying to copy Base accounts from Actual to Plan Scenario but it is not working when I try to consolidate but it is working when I perform force consolidate. Below is the code and any help would be appreciated.
If ((Not api.Entity.HasChildren()) And (api.Cons.IsLocalCurrencyforEntity())) Then
If api.Pov.Scenario.Name = "Plan" Then
api.Data.Calculate("S#Plan = Eval(S#Actual:O#Top:I#Top:U1#Total_CostCenter:U2#Total_ProfitCenter)","A#[Corp_US_Sales].Base",,,,,,,,,,,,AddressOf OnEvalDataBufferScrFilter)
Brapi.ErrorLog.LogMessage(si,"APIDATA")
End If
End If
Private Sub OnEvalDataBufferScrFilter(ByVal api As FinanceRulesApi, ByVal evalName As String, ByVal eventArgs As EvalDataBufferEventArgs)
Try
eventArgs.DataBufferResult.DataBufferCells.Clear()
For Each sourceCell As DataBufferCell In eventArgs.DataBuffer1.DataBufferCells.Values
'Only process cells that have data
If (Not sourceCell.CellStatus.IsNoData) Then
'Apply filtered source cells with data as the new Data Buffer Cells
Dim resultCell As New DataBufferCell(sourceCell)
'Set cells for Data Buffer
eventArgs.DataBufferResult.SetCell(api.SI,resultCell,False)
End If
Next
Catch es As Exception
Throw ErrorHandler.LogWrite(api.SI, New XFException(api.SI,es))
End Try
End Sub
Thanks
You can modify the formula like this so you do not need the Eval. RemoveNoData will remove all no data cells from the source. In this formula though, you should specify a destination (left side) Origin, IC, U1, and U2.
If ((Not api.Entity.HasChildren()) And (api.Cons.IsLocalCurrencyforEntity())) Then
If api.Pov.Scenario.Name = "Plan" Then
api.Data.Calculate("S#Plan = RemoveNoData(S#Actual:O#Top:I#Top:U1#Total_CostCenter:U2#Total_ProfitCenter)","A#[Corp_US_Sales].Base")
'Brapi.ErrorLog.LogMessage(si,"APIDATA")End If
End IfBTW. I rewrite the code and below is working and still wondering why my EVAL is not working anyways thanks.
'Dim GlobalTime As String = BRApi.Workflow.General.GetGlobalTime(si)
Dim POVTime As String = api.Pov.Time.Name
Dim VallTots As String =
"S#Actual:O#Top:F#EndBalInput:I#Top:U1#Total_CostCenter:U2#Total_ProfitCenter:U3#None:U4#None:U5#None:U6#None:U7#None:U8#None"
Dim vAllNones As String =
":S#Plan:O#Import:F#EndBalInput:I#None:U1#None:U2#None:U3#None:U4#None:U5#None:U6#None:U7#None:U8#None"
Dim sourceBuffer As DataBuffer = api.Data.GetDataBufferUsingFormula("RemoveZeros(FilterMembers(" & VallTots & ",[A#Corp_US_Sales.base]))")
Dim vTotal As Decimal = 0If api.Entity.HasChildren=False And api.POV.Scenario.Name="Plan" Then
If Not sourceBuffer Is Nothing Then
Dim resultDataBuffer As DataBuffer = New DataBuffer()
For Each Cell As DataBufferCell In sourceBuffer.DataBufferCells.Values
Dim acctMemberName As String = Cell.DataBufferCellPk.GetAccountName(api)
Dim amount As Decimal = Cell.CellAmount
If amount<>0 Then
vTotal = vTotal + amount
End If
Next
End If'If GlobalTime = POVTime And vTotal <> 0 Then
api.Data.Calculate("A#ACT_Copy" & vAllNones & _
" = " & vTotal,True)
'End If
End If