how DataBufferCellPk works in this segment

Marco
Contributor II

Hi Everyone.

I would appreciate some help in understanding how the DataBufferCellPk works in the following code, and in general. I’m currently reviewing a business rule where entities are charged to others—essentially an allocation. However, I haven't found any use of CALCULATE or similar functions that would typically handle this process. This leads me to believe that DataBufferCellPk might be responsible for it. Could you please assist me in understanding this better and provide more context on the issue I'm trying to resolve?

Dim dbcpk As New DataBufferCellPk(
					mbrRefIdAcc, 
					mbrRefIdFlow, 
					intOriginId, 
					mbrRefIdIC, 
					mbrRefIdUd1, 
					mbrRefIdUd2, 
					mbrRefIdUd3, 
					mbrRefIdUd4, 
					mbrRefIdUd5, 
					mbrRefIdUd6, 
					mbrRefIdUd7, 
					mbrRefIdUd8
				)
				
				'BRApi.ErrorLog.LogMessage(si,$"Valores de DataBufferCellPk 2023M3: MbrRefIdAcc: {mbrRefIdAcc}, MbrRefIdFlow: {mbrRefIdFlow}, IntOriginId: {intOriginId}, MbrRefIdIC: {mbrRefIdIC}, MbrRefIdUd1: {mbrRefIdUd1}, MbrRefIdUd2: {mbrRefIdUd2}, MbrRefIdUd3: {mbrRefIdUd3}, MbrRefIdUd4: {mbrRefIdUd4}, MbrRefIdUd5: {mbrRefIdUd5}, MbrRefIdUd6: {mbrRefIdUd6}, MbrRefIdUd7: {mbrRefIdUd7}, MbrRefIdUd8: {mbrRefIdUd8}")
				'BRApi.ErrorLog.LogMessage(si,"Parameters bufferdatacell 46: " & dupk.ToString & " * " & intViewId.ToString)
				Using dbConnFW As DBConnInfo = BRApi.Database.CreateFrameworkDbConnInfo(si)
					Using dbConnApp As DBConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si)
						listDc = BRApi.Finance.Data.GetDataBufferDataCells(dbConnFW, dbConnApp, dupk, intViewId, dbcpk, False, True)
					End Using
				End Using

 

4 REPLIES 4

TheJonG
Contributor II

The DataBufferCellPk is simply a unique ID associated with a data buffer cell. Think of it as an address on a map. That address is unique and can only point to one location. 

If you are trying to allocate data across entities where you are running the calculation from the Source Entity and 'pushing' data to other entities, an api.Data.Calculate or SetDataBuffer will not work since they will only write data to the entity currently being processed (the Source Entity in this case). To do this, the best practice is to execute a CustomCalculate Business Rule directly from your business rule and pass in the target entities through the parameter dictionary. You can also pass through data buffers or other object through the param dictionary or Global Variables.

Dim brParamDict As New Dictionary(Of String, String) From {
   {"Cube", api.Pov.Cube.name},
   {"Entity", entity.Name},
   {"Consolidation", "Local"},
   {"Scenario", api.Pov.Scenario.Name},
   {"Time", timedimhelper.GetYearFromId(api.Pov.Time.MemberId)},				
   {"View", "YTD"}}

'Trigger custom calculate
BRApi.Finance.Calculate.ExecuteCustomCalculateBusinessRule(si, _
    "Chapter8Examples", "RentAllocation2", brParamDict, CustomCalculateTimeType.AllInYear)

Alternatively, you could trigger the allocation from the Target entities and 'Pull' data from the Entity which holds the pre-allocated data. So you're DM sequence would have the Target entities defined and your source script of your api.Data.Calculate would contain the Source Entity.

Another comment on the rule you posted is that you should refrain from using BRApi functions when equivalent API functions are available due to performance impact of using BRApi. In your example, the api.Data.GetDataBuffer should be used instead of BrApi.Finance.Data.GetDataBufferDataCells. 

Marco
Contributor II

Hi Jon.

Where the process is being carried out is within a Business Rule (BR) of Dashboard Extender. However, I have not fully understood how the allocation process works there, including how the entire process is executed and how the billing is handled. I would greatly appreciate it if you could explain a bit more about how this might work.

TheJonG
Contributor II

Hi Marco - I am not sure I understand what you are asking. Are you trying to perform a calculation i.e. write data to the Cube via a Dashboard Extender? If so, this is generally not recommended and should be performed in a Finance Rule due to performance, data quality, and overall complexity.

That being said, there is a BRAPI function which will write data to the Cube - BRApi.Finance.Data.SetDataCells which can be used by passing in a list of Data Cells.

 

TheJonG_0-1723665221673.png

 

Marco
Contributor II

Hi JonG.
What I wanted to do was an allocation, but due to certain situations, we can no longer use IC (I didn't create the process to perform the allocation). So, I wanted to find a way for it to work by switching from using IC to UD5.