Skip to main content
June 6, 2025
Question

Periodic data copy from YTD scenario

  • June 6, 2025
  • 1 reply
  • 0 views

i have blow code to copy the periodic values from YTD scenario but it didn't work

Dim sourceBuffer1a As DataBuffer = api.Data.GetDataBufferUsingFormula("FilterMembers(S#" & sSourceForecast & ",V#PERIODIC,A#Top.Base,O#AdjInput)", DataApiScriptMethodType.Calculate, False, destination)
 Dim sourceBuffer1b As DataBuffer = api.Data.GetDataBufferUsingFormula("FilterMembers(S#" & sSourceForecast & ",V#PERIODIC,A#Top.Base,O#Forms)", DataApiScriptMethodType.Calculate, False, destination)
                                
Dim sourceBuffer1 As DataBuffer = sourceBuffer1a + sourceBuffer1b
                                
                                If (Not sourceBuffer1 Is Nothing) Then
                                    Dim resultBuffer1 As New DataBuffer()
                                    For Each sourceCell As DataBufferCell In sourceBuffer1.DataBufferCells.Values
                                        Dim resultCell As New DataBufferCell(sourceCell)
                                        If sourceCell.CellStatus.StorageType=DataCellStorageType.Input _ 
                                            Or sourceCell.CellStatus.StorageType=DataCellStorageType.Journals _
                                            Or sourceCell.CellStatus.StorageType=DataCellStorageType.DurableCalculation Then
                                            resultCell.CellAmount = sourceCell.CellAmount
                                            resultBuffer1.SetCell(si, resultCell,True)
                                        End If
                                    Next
                                    api.Data.SetDataBuffer(resultBuffer1, destination,,,,,,,,,,,,,True)
                                End If 

 

is there any other code suggestion?

1 reply

June 10, 2025

Something like this should work

Dim sourceBuffer1 As DataBuffer = api.Data.GetDataBufferUsingFormula("FilterMembers(S#" & sSourceForecast & ":V#PERIODIC,A#Top.Base,O#AdjInput,O#Forms)")
    sourceBuffer1.LogDataBuffer(api,"sourceBuffer1",10000)                           
                                If (Not sourceBuffer1 Is Nothing) Then
                                    Dim resultBuffer1 As New DataBuffer()
                                    For Each sourceCell As DataBufferCell In sourceBuffer1.DataBufferCells.Values
                                        Dim resultCell As New DataBufferCell(sourceCell)
                                        If sourceCell.CellStatus.StorageType=DataCellStorageType.Input _ 
                                            Or sourceCell.CellStatus.StorageType=DataCellStorageType.Journals _
                                            Or sourceCell.CellStatus.StorageType=DataCellStorageType.DurableCalculation Then
                                            resultCell.CellAmount = sourceCell.CellAmount
                                            resultBuffer1.SetCell(si, resultCell,True)
                                        End If
                                    Next
							Dim destination As ExpressionDestinationInfo = api.Data.GetExpressionDestinationInfo("V#PERIODIC")
                             api.Data.SetDataBuffer(resultBuffer1, destination,,,,,,,,,,,,,True)
                                End If 

The sourceBuffer1.LogDataBuffer(api,"sourceBuffer1",10000)  line logs the data on the error log so you can see what is coming through. You can also pull all the data within one databuffer. If you ever need to combine them, you can do this: sourceBuffer1a += sourceBuffer1b. This will combine 1a with 1b.