The OneStream Community is temporarily frozen until June 29th due to the ongoing maintenance. Please read the blog post here to learn more.
Forum Discussion
Sai_Maganti
4 years agoContributor II
FdxExecuteCubeView Function
What is the purpose of timeMemFilter, entityMemFilter and scenarioMemFilter parameters for the below function as these will be defined in the cube view?
Is there a way to extract aggregated membe...
ChrisLoran
OneStream Employee
4 years agoPublic Class MainClass
Private dctLastMemberName As New Dictionary(Of DimTypeId, (Integer, String))
Private Function GetMemberScript(ByVal si As SessionInfo, ByVal cpk As DataBufferCellpk) As String
Dim sb As New Text.StringBuilder(1000)
For Each dt As DimType In DimType.GetRightHandDimTypes()
Dim strMemberName = String.Empty
If dctLastMemberName.ContainsKey(dt.id) Then
If dctLastMemberName(dt.id).Item1 = cpk.Item(dt.id) Then
strMemberName = dctLastMemberName(dt.id).Item2
Else
Dim memberId As Integer = cpk.Item(dt.id)
strMemberName = BRApi.Finance.Members.GetMemberName(si, dt.Id, memberId)
Dim vt As ValueTuple(Of Integer, String) =(memberId, strMemberName)
dctLastMemberName(dt.id) = vt
End If
Else
Dim memberId As Integer = cpk.Item(dt.id)
strMemberName = BRApi.Finance.Members.GetMemberName(si, dt.Id, memberId)
Dim vt As ValueTuple(Of Integer, String) =(memberId, strMemberName)
dctLastMemberName.Add(dt.id, vt)
End If
sb.Append(strmemberName & ",")
Next
Return sb.ToString
End Function
Private Sub ExtractSampleData(ByVal si As SessionInfo)
Dim dupk As New DataUnitPk()
dupk.CubeId = BRApi.Finance.Cubes.GetCubeInfo(si, "GolfStream").Cube.CubeId
dupk.EntityId = BRApi.Finance.Members.GetMemberId(si, DimTypeId.Entity, "Houston")
dupk.ParentId = DimConstants.Unknown
dupk.ConsId = ConsMemberId.Local
dupk.ScenarioId = BRApi.Finance.Members.GetMemberId(si, DimTypeId.Scenario, "Actual")
dupk.TimeId = TimeDimHelper.GetIdFromName("2018M2")
Dim id_TopAcctMember = BRApi.Finance.Members.GetMemberId(si, dimTypeId.Account, "61000")
Dim iTopCellPk As New DataBufferCellPk(DimConstants.All)
iTopCellPk.AccountId = id_TopAcctMember
Dim lstCells As List(Of DataCell) = brapi.Finance.Data.GetDataBufferDataCells(si, dupk, ViewMemberId.YTD, iTopCellPk, False, True)
Dim resultBuf As New DataBuffer()
For Each cellToAgg In lstCells
cellToAgg.DataCellPk.AccountId = id_TopAcctMember
resultBuf.SetCell(si, cellToAgg, True)
Next
Dim strFolder As String = brapi.FileSystem.GetFileShareFolder(si, FileShareFolderTypes.ApplicationOutgoing, Nothing)
Dim strFilename As String = "testExtract.csv"
Dim strFullPath As String = path.Combine(strFolder, strFilename)
Using fs As New FileStream(strFullPath, Filemode.Create, FileAccess.Write)
Using sw As New StreamWriter(fs, Text.Encoding.Default)
For Each aggCell In resultBuf.DataBufferCells.Values
sw.WriteLine(Me.GetMemberScript(si, aggCell.DataBufferCellPk) & "," & aggCell.CellAmount.XFToStringForFormula)
Next
End Using
End Using
End Sub
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object
Try
Select Case args.FunctionType
Case Is = ExtenderFunctionType.Unknown
Me.ExtractSampleData(si)
End Select
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
Related Content
- 2 years ago
- 3 years ago
- 4 months ago