cancel
Showing results for 
Search instead for 
Did you mean: 

how to add valid values in column of matrix.

former_member917522
Participant
0 Kudos

Hi Expert

I added one user defined field in matrix of standard Purchase order.and i want to insert values in that column

for that i write following code.but it doesnot work.

can please tell me whats the wrong in my code.

  if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_LOAD && pVal.BeforeAction == false)

                    {

                        oForm = clsAddOn.LDNA_Application.Forms.GetForm("142", pVal.FormTypeCount);

                      

                        //Colum - Type of Weight

                        oColumn = oColumns.Add("edtTypeWt", SAPbouiCOM.BoFormItemTypes.it_EDIT);

                        oColumn.TitleObject.Caption = "Type Of Weight";

                        oForm.DataSources.DBDataSources.Add("POR1");

                        oColumn.DataBind.SetBound(true, "POR1", "U_TypeofWt");

                        oColumn = oItem.Specific;

                        oItem.DisplayDesc = false;

                        for (int i = oColumn.ValidValues.Count; i < 1; i++)

                        {

                            oColumn.ValidValues.Add("E", "Weight At Ex Factory");

                            oColumn.ValidValues.Add("O", "Weight At Our Factory");

                        }

                    }

                    #endregion

Accepted Solutions (0)

Answers (1)

Answers (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Akshaya,

First of all you haven't described that are you getting any error when you try to add the valid values.

Secondly if you need to add only 2 valid values as you described like this

"E", "Weight At Ex Factory"

"O", "Weight At Our Factory"

Then why don't you use User Defined Fields- Management. For this you need to do as follows:

Go to Tools->Customization Tools->User Defined Fields-Management after clicking select your table or Marketing Documents. Here you will get the option as 'Rows'. Select that field in which you want to add valid values and update this field.

Still if you want to do this by Code use this:

private void FillValidValues()

        {

            SAPbobsCOM.Recordset oRecSet = default(SAPbobsCOM.Recordset);

            SAPbouiCOM.ComboBox oCombo = default(SAPbouiCOM.ComboBox);

            try

            {

                int count;

                oCombo = (SAPbouiCOM.ComboBox)this.m_SBO_Form.Items.Item(enControlName.Locations).Specific;

                oRecSet = (Recordset)this.SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                oRecSet.DoQuery("SELECT Code, Name FROM [@Locations] order by Code");

                if (oCombo.ValidValues.Count > 0)

                {

                    count = oCombo.ValidValues.Count;

                    for (int k = 1; k <= count; k++)

                    {

                        oCombo.ValidValues.Remove(count - k - 0, SAPbouiCOM.BoSearchKey.psk_Index);

                    }

                }

                oCombo.ValidValues.Add("", "");

                if (oRecSet.RecordCount > 0)

                {

                    while (oRecSet.EoF == false)

                    {

                        oCombo.ValidValues.Add(oRecSet.Fields.Item(0).Value.ToString().Trim(), oRecSet.Fields.Item(1).Value.ToString().Trim());

                        oRecSet.MoveNext();

                    }

                }

            }

            catch (Exception ex)

            {

                this.SBO_Application.SetStatusBarMessage(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, true);

            }

        }

Hope it helps....

Thanks & Regards

Ankit Chauhan

former_member917522
Participant
0 Kudos

Hi Sir

Through Code, I want add one column in Purchase order and want to set two values in that column.

using this code  field get added in Purchase order matrix but values not Set.

code show Exception : Object reference not set to an instance of an object.

                      

                       //Colum - Type of Weight

                        oColumn = oColumns.Add("edtTypeWt", SAPbouiCOM.BoFormItemTypes.it_EDIT);

                        oColumn.TitleObject.Caption = "Type Of Weight";

                        oForm.DataSources.DBDataSources.Add("POR1");

                        oColumn.DataBind.SetBound(true, "POR1", "U_TypeofWt");

                        oColumn = oItem.Specific;

                        oItem.DisplayDesc = false;

                        for (int i = oColumn.ValidValues.Count; i < 1; i++)

                        {

                            oColumn.ValidValues.Add("E", "Weight At Ex Factory");

                            oColumn.ValidValues.Add("O", "Weight At Our Factory");

                        }

edy_simon
Active Contributor
0 Kudos

Hi akshaya,

For system form, you need only add the user field in the User Field Management screen.

Provide your valid values in there also.

Column + Valid values will be automatically handled by SBO.

No need for code.

Regards

Edy

former_member917522
Participant
0 Kudos

Hi

Thanks for Reply but Sir i want add (UDF) Column + Valid values through Code.

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Akshaya,

In your code, you haven't given any reference to ComboBox. So initialize that as

SAPbouiCOM.ComboBox oCombo = (SAPbouiCOM.ComboBox)oForm.Items.Item("UID").Specific;

After this try to use my code accordingly.

Hope it helps..

Thanks & Regards

Ankit Chauhan

edy_simon
Active Contributor
0 Kudos

Hi Akshaya,

When you add a UDF into SBO System, the column is already there.

Why do you need to add it through code ?

AFAIK, you cannot add a column manually in the system matrix.

Regards
Edy