01-03-2024 04:28 PM - last edited on 01-12-2024 02:51 AM by JackLacava
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.
Solved! Go to Solution.
01-05-2024 12:36 PM
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.
01-03-2024 04:46 PM
Have you tried to write listDc out to a file, or to the log? Are you sure that you have data in the buffer?
01-03-2024 04:51 PM
Hi Steven, If there is data in 'listDc' and to check if there is data in the buffer, where could I verify it?
01-03-2024 05:05 PM
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
01-03-2024 05:10 PM - edited 01-03-2024 05:12 PM
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
01-03-2024 05:27 PM - edited 01-03-2024 05:34 PM
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:
01-03-2024 05:43 PM
Hi robb, the result is empty.
01-03-2024 06:04 PM
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.
01-03-2024 06:11 PM
I have modified the question with a bit more code.
01-03-2024 06:21 PM
what results are you expecting to see? What does the loop do? Does it remove datacells where the amount = 0?
01-04-2024 11:12 AM
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.
01-04-2024 12:04 AM
Is the data in the data buffer derived?
How do you know there is data in the data buffer?
01-04-2024 11:25 AM
I'm not sure what data I have or where the GetDataBufferDataCells function extracts it from; I want to verify that.
01-04-2024 05:35 AM
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.
/end of rant.
01-04-2024 11:08 AM
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.
01-04-2024 06:08 PM
Is there another function that allows me to do this? Apparently, the process I'm working on has to do with the drivers.
01-05-2024 01:46 AM
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)
01-05-2024 11:49 AM
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.
01-05-2024 12:30 PM
All the data that the function receives is not empty.
01-05-2024 12:36 PM
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.
01-05-2024 01:30 PM
I will check all the components that were passed to see if something is not failing. Thank you very much for responding