How to extract OneStream data and load it to an external table


In this post, we will look at how to extract data from OneStream and load it to an external table.

I’m going to repurpose the rule from How to load a delimited file to a table in OneStream

We will cover how to create a data management sequence, DM step, and how to get files from Data Management export folder from a business rule.

Here is how it can be done.

Here is the code that I wrote during the video.

Private Sub LoadOSDataToTable (ByVal si As SessionInfo)
	Try
		Dim fileName As String = BRApi.Utilities.GetFileShareFolder(si, FileShareFolderTypes.ApplicationIncoming, Nothing).Replace("Incoming", String.Empty) & 
		"\Datamanagement\Export\" & StringHelper.RemoveInvalidNameCharacters(si.UserName, False, False) & "\BI_DATA\Profit.csv"
		Dim fieldTokens As New List(Of String)
		fieldTokens.Add("xfText#:Geography")
		fieldTokens.Add("xfText#:Cons")
		fieldTokens.Add("xfText#:Scenario")
		fieldTokens.Add("xfText#:Time")
		fieldTokens.Add("xfText#:View")
		fieldTokens.Add("xfText#:Account")
		fieldTokens.Add("xfText#:Flow")
		fieldTokens.Add("xfText#:Origin")
		fieldTokens.Add("xfText#:IC")
		fieldTokens.Add("xfText#:Products")
		fieldTokens.Add("xfDec#:Amount")
		fieldTokens.Add("xfText#:LastUpdatedBy:[" & si.UserName & "]")
		fieldTokens.Add("xfText#:Annotation")
		fieldTokens.Add("xfText#:Assumptions")
		fieldTokens.Add("xfText#:AuditComment")
		fieldTokens.Add("xfText#:LastUpdateDate:[" & DateTime.Now.ToString("yyyy/mm/dd") & "]")
		
		BRApi.Utilities.LoadCustomTableUsingDelimitedFile(si, SourceDataOriginTypes.FromFileShare, fileName, File.ReadAllBytes(fileName), ",", "External Tables", "Sample_Profit", "Replace", fieldTokens, True)
	Catch ex As Exception
		Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
	End Try			
End Sub	

Leave a comment

Your email address will not be published. Required fields are marked *