Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Datatable databind to matrix auto round????

Hello All:

Come into some pretty serious problem with my addon in one of our clients that they found the data loaded into the matrix I build for them are all rounded to 2 place decimal place.. Below is my code

Global.odatatable.ExecuteQuery("select itemcode, price, quantity from rdr1")
                Global.omatrix = (SAPbouiCOM.Matrix)(Global.oapplication.Forms.Item("myform").Items.Item("umatrix").Specific);
                Global.omatrix.Clear();
                Global.omatrix.Columns.Item("itemcode").DataBind.Bind("U_fill", "itemcde");
                Global.omatrix.Columns.Item("price").DataBind.Bind("U_fill", "price");
                Global.omatrix.Columns.Item("quantity").DataBind.Bind("U_fill", "quantity");

                Global.omatrix.LoadFromDataSource();
                Global.omatrix.AutoResizeColumns();

I know that going into the sql... quantity can have something like 0.24444.. But when it come out of the matrix it became 0.24... Thus all the calculation afterwards are discrepent... All the column in the matrix are simple edittext. I builded in screen printer. I kept on looking at the

I tried to do something like

Global.odatatable.Columns.Item("quantity").Type = SAPbouiCOM.BoFieldsType.ft_Float;

But then it tells me that .type is read only property.... How do I just make it not round

replied

Hello Bo,

It is due to your decimal setting for quanity in General Setting. it is 2 in your case The addon matrix and matrix in Sales order will round to 2 decimal. That is a system behavior.

If it is not what you expected, the solution is to convert the datatype from decimal to nvarchar in SQL, then the quantity will be displayed as string.

select itemcode, price, convert(nvarchar(20),quantity) qantity from rdr1

Kind Regards

-Yatsea

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question