Skip to Content

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

ComboBox with BusinessPartners

An apology for my English, I'm trying to do a comboBox filled with my Business Partners names and codes, but I can't.

I Modify part of the examples and this is the code that I use:

SAPbobsCOM.BusinessPartners oBusinessPartner;
SAPbobsCOM.Recordset oRecordSet;

oRecordSet = (SAPbobsCOM.Recordset) SAPConn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

oBusinessPartner = (SAPbobsCOM.BusinessPartners) SAPConn.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);

try
{
   Combo1.Items.Clear();

   while (!(oRecordSet.EoF == true))
   {
      oBusinessPartner.GetByKey(oRecordSet.Fields.Item(0).Value.ToString());
      Combo1.Items.Add(oBusinessPartner.CardCode);

      oRecordSet.MoveNext();
   }
}
catch (Exception ex)
{
   MessageBox.Show(ex.ToString());
}

Edited by: gaestudio on Jun 25, 2010 9:17 PM

Former Member
Former Member replied

Hi,

The way you have written code to get the Business Partners is not correct. You should bind both value and description to combobox. Use this below code.

DimoComboBox As SAPbouiCOM.ComboBox
Dim RS As SAPbobsCOM.Recordset       

        RS = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)     

        RS.DoQuery("SELECT T0.[CardCode], T0.[CardName] FROM OCRD T0")

        RS.MoveFirst()
        While RS.EoF = False
            oComboBox.ValidValues.Add(RS.Fields.Item("CardCode").Value, RS.Fields.Item("CardName").Value)
            RS.MoveNext()
        End While

Note:Your combobox should be bound with datasource

Regards,

Noor Hussain

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