on 10-07-2013 6:19 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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");
}
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.