Forum Discussion

Marco's avatar
Marco
Contributor II
12 months ago

GetDataBufferDataCells with no data

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.

 

  • 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.

  • JackLacava's avatar
    JackLacava
    Honored Contributor

    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.

    • Marco's avatar
      Marco
      Contributor II

      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.

    • Marco's avatar
      Marco
      Contributor II

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

      • Steven's avatar
        Steven
        Contributor II

        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)

  • Steven's avatar
    Steven
    Contributor II

    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?

    • Marco's avatar
      Marco
      Contributor II

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

      • Steven's avatar
        Steven
        Contributor II

        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

         

  • RobbSalzmann's avatar
    RobbSalzmann
    Valued Contributor II

    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:

     

    • Marco's avatar
      Marco
      Contributor II

      Hi robb, the result is empty.

       

  • RobbSalzmann's avatar
    RobbSalzmann
    Valued Contributor II

    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.

    • Marco's avatar
      Marco
      Contributor II

      I have modified the question with a bit more code.

  • RobbSalzmann's avatar
    RobbSalzmann
    Valued Contributor II

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

    • Marco's avatar
      Marco
      Contributor II

      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's avatar
    Steven
    Contributor II

    Marco,

    Is the data in the data buffer derived?

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

    • Marco's avatar
      Marco
      Contributor II

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

  • chul's avatar
    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.

    • Marco's avatar
      Marco
      Contributor II

      All the data that the function receives is not empty.

      • RobbSalzmann's avatar
        RobbSalzmann
        Valued Contributor II

        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.