cancel
Showing results for 
Search instead for 
Did you mean: 

Sales Order Form Add Unbound Checkbox to Matrix

Former Member
0 Kudos

Hi,

When I open the Sales Order form I would like to add an Unbound Checkbox column. The purpose of this column is to allow a user to select rows from the sales order grid. I would rather not bind this to a UDF field as this is not really necessary.

So far I have managed to add the column, but this has an issue when opening an existing order, the oMatrix.Clear(); clears all line items

Can I add an unbound checkbox column to the sales order matrix grid?.

Can I then use this unbound column for selecting one or more line items to perform a task ?

The below code adds the checkbox colum and clears the grid.


            SAPbouiCOM.Matrix oMatrix;

            oMatrix = (SAPbouiCOM.Matrix)oForm.Items.Item("38").Specific;

            SAPbouiCOM.Column oColumn;

            oMatrix.Clear();

            oMatrix.Columns.Add("chkShpDte", SAPbouiCOM.BoFormItemTypes.it_CHECK_BOX);

            oColumn = oMatrix.Columns.Item("chkShpDte");

            oColumn.TitleObject.Caption = "Ship Sel";

            oColumn.DataBind.SetBound(false, "", "U_ShipDate");

            oMatrix.AddRow(1, oMatrix.RowCount);

Accepted Solutions (1)

Accepted Solutions (1)

former_member185682
Active Contributor
0 Kudos

Hello Edward,

What is the moment that you try adds the new column to your matrix?

I have tested the following condition and it works. In the ItemEvent I add the following condition:


            if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_LOAD && pVal.FormTypeEx.Equals("139") && pVal.BeforeAction)

            {

                SAPbouiCOM.Form oForm = objApp.Forms.GetFormByTypeAndCount(Convert.ToInt32(pVal.FormTypeEx), pVal.FormTypeCount);

                SAPbouiCOM.Matrix oMatrix = (SAPbouiCOM.Matrix)oForm.Items.Item("38").Specific;

                int count = oMatrix.RowCount;

                oMatrix.Clear();

                oMatrix.Columns.Add("chkShpDte", SAPbouiCOM.BoFormItemTypes.it_CHECK_BOX);

                SAPbouiCOM.Column oColumn = oMatrix.Columns.Item("chkShpDte");

                oColumn.TitleObject.Caption = "Ship Sel";

                oColumn.DataBind.SetBound(false, "", "U_ShipDate");

                oMatrix.AddRow(count, oMatrix.RowCount);

            }

There is a trick in the code, before clear your matrix, gets the current matrix row count, and when you call add rows in the last line of code, you should add the number of rows that you obtained before clear your matrix.

Hope it helps.


Best regards,

Diego Lother


View Diego Lother's profile on LinkedIn

Former Member
0 Kudos

Hi Diego,

Many thanks for the response.

I have added the code as an ItemEvent.

1. It creates the checkboxes. However it still clears all existing Sales Order data.

2. You can only select one checkbox on the grid at a time.

If I have to create a UDF on the RDR1 table I will if this solves the issue.

Regards

former_member185682
Active Contributor
0 Kudos

Hi Edward,

1. The order of events are the following:

ItemEvent - FormLoad - BeforeAction = true

FormDataEvent - FormDataLoad - BeforeAction = true

FormDataEvent - FormDataLoad - BeforeAction = false

ItemEvent - FormLoad - BeforeAction = false

In the last sample code, we clear the matrix before SAP loads the data for the form, then your matrix shouldn't be empty. (I use SAP B1 9.0 PL 11). For me, it works.

2. About select more than one checkbox, I created a UserDataSource and use it to bound my checkbox column.

Looks the code:


            if(pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_LOAD && pVal.FormTypeEx.Equals("139") && pVal.BeforeAction)

            {

                SAPbouiCOM.Form oForm = objApp.Forms.GetFormByTypeAndCount(Convert.ToInt32(pVal.FormTypeEx), pVal.FormTypeCount);

                SAPbouiCOM.UserDataSource oUds = oForm.DataSources.UserDataSources.Add("U_Selected", SAPbouiCOM.BoDataType.dt_LONG_TEXT, 2);

                SAPbouiCOM.Matrix oMatrix = (SAPbouiCOM.Matrix)oForm.Items.Item("38").Specific;

                int count = oMatrix.RowCount;

                oMatrix.Clear();

                oMatrix.Columns.Add("chkShpDte", SAPbouiCOM.BoFormItemTypes.it_CHECK_BOX);

                SAPbouiCOM.Column oColumn = oMatrix.Columns.Item("chkShpDte");

                oColumn.TitleObject.Caption = "Ship Sel";

                oColumn.DataBind.SetBound(true, "", "U_Selected");

                oMatrix.AddRow(count, oMatrix.RowCount);

            }

But, I believe that the right way is to create an UDF as you mentioned. The code above works as expected in my SAP B1 version.

Hope it helps.


Best regards,

Diego Lother


View Diego Lother's profile on LinkedIn

Answers (1)

Answers (1)

pedro_magueija
Active Contributor
0 Kudos

Hi Edward,

You should create the UDF and bind it otherwise data is not maintained in the UI object. Note that a UserDataSource can only store one single value so it's not adequate for Grid/Matrix. The simplest solution is to create a UDF on the table and use that to bind. If you absolutely can't/won't create a UDF, then you can use a DataTable (you can add one to the form) with one single column and bind to that. But this is more complex than just creating the UDF.

Good luck.


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

Former Member
0 Kudos

Hi Diego, Pedro,

Really appreciate both of your help on this issue. I have managed to figure this out.

Just to bring some understanding to what the overall goal was. I wanted to add a way to update on Sales Orders line item ship dates in a more logical way for our business. I know in SAP you can change all rows on a Sales Order on mass. But this creates issues. Our Sales Orders are shipped over a period of weeks, with items having different dates for shipment. Our sales orders can have many rows, so having the change sales order lines can be a time consuming process.

So what I have done is the following.

1. I have added a new row of check boxes to the matrix. This check box is not bound to the underlying data source.

2. I have added a field where a user can enter a number of days. In the case showing, I have 1, which equates to one day. The user can hit the apply button, and this will iterate over each checked row changing the ship date from its current date adding +1 day in this case. So if the previous ship date was 31-05-2015, its now shifted by one day. It also takes into consideration weekends. So if the new date falls on a weekend, it moves this ship date to the next Monday.

3. There is also a check box to update the purchase order. When checked, on hitting the Update button on the Sales Order, this will update any related purchase order ship dates to reflect the new sales order ship date.

There is one weird thing I still dont understand. Which is one of my original issues. If I try and open a Sales Order using just the Doc Number form the Global Search Bar, this doesn't open the Sales Order correctly. What it does is load the form without any rows.

If I go into the Sales Order form and open a sales order, this loads the Matrix Grid correctly. Not sure why this is the case

Hopefully, the above make sense and maybe helpful for someone in the future.