Skip to Content
avatar image
Former Member

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Jun 26, 2010 at 06:06 AM

    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

    Add comment
    10|10000 characters needed characters exceeded