Showing results for 
Search instead for 
Did you mean: 

How to fast iterate DataTabel with 4k rows?


I have big DataTable (4k rows) bind to Matrix which I have to iterate after the event "validate" some columns.

I have to use only rows where column "Quantity" more than 0.

How I can fast filter DataTable with this condition and remainder rows iterate through operating "for"

I am waiting for some piece of advice, thanks!

Accepted Solutions (0)

Answers (1)

Answers (1)

Active Contributor


Drawing the matrix is the biggest job, and B1's graphical interface is notoriously slow. One solution that comes to mind, is to unbind the datatable from the matrix, perform the iteration and then rebind it again.

Another is to use a JIT system, where you load rows from the DataTable only at the moment they become visible.



0 Kudos

How first way(unbinding the DataTable(from SDK API UI) from the matrix) can help to make this fast, if I simply iterate DataTable(from SDK API UI), please explain this?

I think the problem with the way what I have chosen

SAPbouiCOM.DataTable mtrxDT = UIAPIRawForm.DataSources.DataTables.Item("mtrxDT"); 
Matrix4.FlushToDataSource(); SAPbouiCOM.Form oForm = UIAPIRawForm as SAPbouiCOM.Form;
Double TVolume = 0; Double SUM = 0; Double TWeight = 0;
for (int num_row = 0; num_row < mtrxDT.Rows.Count; num_row++) //this loop is very slow { if (Convert.ToDouble(mtrxDT.GetValue(17, num_row)) > 0) { TVolume = TVolume + Convert.ToDouble(mtrxDT.GetValue(5, num_row)) * Convert.ToDouble(mtrxDT.GetValue(17, num_row)); //TQuan = TQuan + Convert.ToDouble(mtrxDT.GetValue(17, num_row)); TWeight = TWeight + Convert.ToDouble(mtrxDT.GetValue(6, num_row)) * Convert.ToDouble(mtrxDT.GetValue(17, num_row)); SUM = SUM + Convert.ToDouble(mtrxDT.GetValue(13, num_row)) * Convert.ToDouble(mtrxDT.GetValue(17, num_row)); } } oForm.DataSources.UserDataSources.Item("SYS_5").Value = TVolume.ToString(); //oForm.DataSources.UserDataSources.Item("SYS_6").Value = TQuan.ToString(); oForm.DataSources.UserDataSources.Item("SYS_8").Value = TWeight.ToString(); oForm.DataSources.UserDataSources.Item("SYS_7").Value = SUM.ToString();
Active Contributor

Changes to the datatable itself is fast enough, but when you bind the datatable to the grid, each time anything changes in the datatable, the grid will react instantly and be redrawn.

In other words, it is best to separate the manipulation of the data from showing the data.

0 Kudos

Thank you very much for explain!