Add a Column to a system matrix

Erik van Dongen

In the order form, we want to show the available stock of the SELECTED warehouse. SAP is only showing the available stock of all the warehouses together.

The calculation of the stock is no problem. The thing is that I don't want to create a UDF for the showing of the value, because there's no need to save the data in the database and this field will show up in all the other document forms which we don't want.

To create the column, i added the following code in the formload:

Matrix matrix = Matrix.GetFromUID(e.Form, "38");

// Column ItemCode
matrix.Columns["1"].AddHandler_Validate(ModeComponent.FormModes.ALL, validateItemCode);

// Column WhsCode
matrix.Columns["24"].AddHandler_Validate(ModeComponent.FormModes.ALL, null, validateWarehouse);

// Remove rows to add column
matrix.Rows.Clear();

// Add a user datasource
e.Form.AddUserDatasource(UserDatasource.CreateNew("udWhsQty"));
e.Form.Update();

// Create and add the column
MatrixColumn whsQty = MatrixColumn.CreateNew("U_WhsQty");
whsQty.DataBind = DataBind.CreateNew("udWhsQty");
whsQty.DataBind.DataBound = true;
whsQty.DataBind.SetBind(true, "udWhsQty");
whsQty.Type = MatrixColumn.MatrixItemType.TextEdit;
whsQty.DisplayDesc = true;
whsQty.Description = "WhsQty";
matrix.Columns.Add(whsQty);

e.Form.Update();

// Add a row again
matrix.Rows.Add(1);


The problem is that at the end of the onload function. The databind is correct but as soon as the validate itemcode or warehousecode is triggerd, the databind is gone and no columnheader is showing up.....

All help on this problem is appreciated.
Erik van Dongen

Marco Schweighauser

Hello Erik,

I don't think it is possible to add a column to a system matrix in a stable way. The best thing would be to use a UDF with the drawback of unused saved data.



Kind regards,

Marco
0

Comments

0 comments

Please sign in to leave a comment.

Didn't find what you were looking for?

New post