Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Globalization
Imports System.IO
Imports System.Linq
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Imports OneStream.Finance.Database
Imports OneStream.Finance.Engine
Imports OneStream.Shared.Common
Imports OneStream.Shared.Database
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Wcf
Imports OneStream.Stage.Database
Imports OneStream.Stage.Engine
Namespace OneStream.BusinessRule.Finance.MF_Copy
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As FinanceRulesApi, ByVal args As FinanceRulesArgs) As Object
Try
Dim bLogEnabled As Boolean = True 'Change to true only in development for logging values
Dim strLogName As String = Me.GetType.Namespace 'Uniquely identifies where the log is coming from, no change required. Get the name from the current namespace for identification of log entry
Dim sbLogMessage As New System.Text.StringBuilder 'Holds the log - use appendline to add to the logstring
sbLogMessage.appendline ("*** Log ***") 'Header for easy finding log entries
Select Case api.FunctionType
Case Is = FinanceFunctionType.CustomCalculate
If args.CustomCalculateArgs.FunctionName.XFEqualsIgnoreCase("CopyETC_Actual_Test") Then
'-------------------------------------------------------------------------
'---CopyETC_Actual_Test---Start
'-------------------------------------------------------------------------
sbLogMessage.appendline ("CopyETC_Actual_Test")
sbLogMessage.appendline ("POV:" & api.Pov.Entity.Name & "_" & api.Pov.Scenario.Name & "_" & api.Pov.Time.Name)
'Run for base Entities and local currency only
If ((Not api.Entity.HasChildren()) And (api.Cons.IsLocalCurrencyforEntity())) Then
'Copy data
sbLogMessage.AppendLine("CopyData")
'Dim databuffer As DataBuffer = api.Data.GetDataBufferUsingFormula("FilterMembers(T#2023M6,S#Actual,A#AC890000.Base,F#None,U1#PR999998.Base,U1#None,U2#EQ0599.Base,U2#None,U3#None,U4#None,U5#Tot_Reporting.Base,U6#None,U7#None,U8#Actual)",,False)
'Dim databuffer As DataBuffer = api.Data.GetDataBufferUsingFormula("FilterMembers(S#Actual,A#AC890000.Base,F#None,U1#PR999998.Base,U1#None,U2#EQ0599.Base,U2#None,U3#None,U4#None,U5#Tot_Reporting.Base,U6#None,U7#None,U8#Actual)",,False)
Dim databuffer As DataBuffer = api.Data.GetDataBufferUsingFormula("FilterMembers(T#2023M6,A#AC890000.Base,F#None,U1#PR999998.Base,U1#None,U2#EQ0599.Base,U2#None,U3#None,U4#None,U5#Tot_Reporting.Base,U6#None,U7#None,U8#Actual)",,False)
If Not databuffer Is Nothing Then
For Each SourceCell As databuffercell In databuffer.DataBufferCells.Values
If Not SourceCell Is Nothing And SourceCell.CellAmount <> 0 Then
Dim sSourceMemberscript As String = sourcecell.DataBufferCellPk.GetMemberScript(api)
sbLogMessage.AppendLine("CalculatedCell: " & sSourceMemberscript)
End If
Next
End If
End If
'-------------------------------------------------------------------------
'---CopyETC_Actual_Test---End
'-------------------------------------------------------------------------
End If
End Select
If bLogEnabled Then brapi.ErrorLog.LogMessage(si,strLogName,sbLogMessage.ToString)
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
End Namespace
This is the finance rule with the test custom calc. The code is used for testing and it prints out in the error log the combinations found by the getdatabufferusingformula.