GetDataBufferDataCells with no data

Marco
Contributor

Hi Everyone.

I have the following section of code.

'Search for values for the DataBufferCellPK, they are not empty.
Dim dbcpk As New DataBufferCellPk(
    mbrRefIdAcc, 
    mbrRefIdFlow, 
    intOriginId, 
    mbrRefIdIC, 
    mbrRefIdUd1, 
    mbrRefIdUd2, 
    mbrRefIdUd3, 
    mbrRefIdUd4, 
    mbrRefIdUd5, 
    mbrRefIdUd6, 
    mbrRefIdUd7, 
    mbrRefIdUd8
)

'BRApi.ErrorLog.LogMessage(si, $"values of DataBufferCellPk: 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: " & dupk.ToString & " * " & intViewId)

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

BRApi.ErrorLog.LogMessage(si, $"listDc values json: {JsonConvert.SerializeObject(listDc, Formatting.Indented)}")

Dim intTotDc As Int64 = listDc.Count
Dim k As Int64 = 0
For i = listDc.Count - 1 To 0 Step -1
    Dim dc As DataCell = listDc(i)
    If (dc.CellAmount = Decimal.Zero) OrElse Not (1 = 1 _
        And listIntAcc.Contains(dc.DataCellPk.AccountId) _
        And listIntFlow.Contains(dc.DataCellPk.FlowId) _
        And listIntIC.Contains(dc.DataCellPk.ICId) _
        And listIntUd1.Contains(dc.DataCellPk.UD1Id) _
        And listIntUd2.Contains(dc.DataCellPk.UD2Id) _
        And listIntUd3.Contains(dc.DataCellPk.UD3Id) _
        And listIntUd4.Contains(dc.DataCellPk.UD4Id) _
        And listIntUd5.Contains(dc.DataCellPk.UD5Id) _
        And listIntUd6.Contains(dc.DataCellPk.UD6Id) _
        And listIntUd7.Contains(dc.DataCellPk.UD7Id) _
        And listIntUd8.Contains(dc.DataCellPk.UD8Id)) Then
        strLog.AppendLine($"{strBRName} - Removing {Me.PrintDataCell(si, dc)}")
        listDc.RemoveAt(i)
        k += 1
    End If
Next

It doesn't give me any results, so I wanted to know where I can add the information to get results.

 

1 ACCEPTED SOLUTION

RobbSalzmann
Valued Contributor

The way I would troubleshoot this is two fold:
1. create a quickview in Excel using exactly the same members you're passing in to the databuffer.  This is a sanity check to say "Yes data exists where I expect it to" or "Oops, I thought it was there but I have this one thing off..." 

2. You said this works perfectly in another system.  Same code, different application.  its not the code.  look at what else might be different.

View solution in original post

20 REPLIES 20

Steven
Contributor

@Marco,

Have you tried to write listDc out to a file, or to the log?  Are you sure that you have data in the buffer?

Hi Steven, If there is data in 'listDc' and to check if there is data in the buffer, where could I verify it?

Marco,

I would do something like this:  (not tested)...

For Each dc In listDc
     'write this to log file:  convert this from binary (dc.Bytes)
Next

 

Oh, that, yes, I checked that 'listDc' doesn't have values, as it returns 0 when applying the count.

Dim intTotDc As Int64 = listDc.Count
Dim k As Int64 = 0
For i=listDc.Count-1 To 0 Step -1
 Dim dc As DataCell = listDc(i)
Next

 

RobbSalzmann
Valued Contributor

Hi @Marco 

To loop over the cells in the databuffer look at amounts (for example):

Dim amounts As New List(Of String) 
For Each dc As DataCell In listDc
	amounts.Add(dc.CellAmountAsText)	
Next
BRApi.ErrorLog.LogMessage(si, $"amounts: {JsonConvert.SerializeObject(amounts, Formatting.Indented)}")

To view the contents of your databuffer, listDc, use the following:

BRApi.ErrorLog.LogMessage(si, $"listDc: {JsonConvert.SerializeObject(listDc, Formatting.Indented)}")

 be sure to include the Newtonsoft imports:

RobbSalzmann_0-1704320735187.png

 

Hi robb, the result is empty.

Marco_0-1704321773386.png

 

RobbSalzmann
Valued Contributor

Couple of things, don't put the BRApi.ErrorLog.LogMessage calls inside of loops.  They are for after the loop completes.

To help you troubleshoot the empty problem, you'll need to post the rest of your code.

I have modified the question with a bit more code.

RobbSalzmann
Valued Contributor

what results are you expecting to see?  What does the loop do? Does it remove datacells where the amount = 0?

If I want to see the amounts, the loop removes the zeros where the amount is 0, but listDc doesn't contain anything. So, for now, the loop doesn't work. I mean that I'm modifying something that I didn't create; I'm trying to solve this problem that arose when switching environments.

Steven
Contributor

@Marco,

Is the data in the data buffer derived?

How do you know there is data in the data buffer?

I'm not sure what data I have or where the GetDataBufferDataCells function extracts it from; I want to verify that.

JackLacava
Community Manager
Community Manager

Chances are you're simply working with the wrong cellPk parameters, or just don't have the rights to read those cells.

Regardless, sorry to be "that guy", but going cell by cell is a recipe for poor performance, and should be a last resort. Using GetDataBufferDataCells, while supported, is typically a bad idea; it tells me you're in an Extender of some type, which really shouldn't mess with cube data.

  • If you're doing data-manipulation, put your code in a Custom Calculation routine instead, preferably triggered by DataManagement jobs. That gives you the api object, with all its goodies like efficient filtering via databuffers.
  • If you're doing data-extraction, use parameterized Data Management extract tasks, Export* calls, or FdxExecute* calls.

/end of rant.

yes, it's in a Dashboard Extender BR, and I don't have complete knowledge of this, as it's a functionality that already existed. It worked perfectly in another working environment, but when I moved it to the one I'm in now, I'm having issues with this.

Is there another function that allows me to do this? Apparently, the process I'm working on has to do with the drivers.

FdxExecuteDataUnit will return your data unit in a datatable:

BRApi.Import.Data.FdxExecuteDataUnit(si, cubeName, entityMemFilter, consName, scenarioTypeId, scenarioMemFilter, timeMemFilter, viewName, suppressNoData, filter, parallelQueryCount, logStatistics)

chul
Contributor III

I may not understand what you're trying to do. Calling a data buffer only returns intersections with data so if you're calling a data buffer of intersections with no data, it will return nothing.

cds

All the data that the function receives is not empty.

RobbSalzmann
Valued Contributor

The way I would troubleshoot this is two fold:
1. create a quickview in Excel using exactly the same members you're passing in to the databuffer.  This is a sanity check to say "Yes data exists where I expect it to" or "Oops, I thought it was there but I have this one thing off..." 

2. You said this works perfectly in another system.  Same code, different application.  its not the code.  look at what else might be different.

I will check all the components that were passed to see if something is not failing. Thank you very much for responding