Forum Discussion

Krishna's avatar
Krishna
Valued Contributor
3 years ago
Solved

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 h...
  • EricOsmanski's avatar
    3 years ago

    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 If

  • Krishna's avatar
    Krishna
    3 years ago

    BTW. 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 = 0

    If 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