Skip to Content

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

Combo in XML

Hello to all, I need to relate a combobox to another table. The code that I have is the following one. Thank you very much

<item AffectsFormMode="1" " type="113"...

<AutoManagedAttribute />

<specific AffectsFormMode="1" TabOrder="0">


<action type="add"/>


<databind alias="U_TGV_FIIBB_CODE" databound="0" table="@TGV_TIIBB_CODES_BP" />



<item AffectsFormMode="1" type="8"...

<specific caption="Codigo de IIBB" />


Former Member
Former Member replied


Here is an example of combo.

<column uid="eUMyField" type="113" title="My Combo Field" description="My Combo Field" 
                     visible="1" AffectsFormMode="1" width="8" disp_desc="1" editable="1"  
                     right_just="0" val_on="" val_off="" backcolor="-1" forecolor="-1" 
                     text_style="0" font_size="-1">
   <databind databound="1" table="@USER_TABLE" alias="U_MyField"></databind>

To load data into combo from some table on database you need to initilize combo box when you load your form.

Here 2 examples:

- 1) into combo cType we load data from table .

- 2) into comto cTypeSog we load predefined data.

In the 1) example: your need to do for ... next.

In the 2) example: you can also do this using xml (look example posted before).

3° case: also you can load data into combobox field when you have UDF with defined ValidValues.

In this case you need to said in your code what field is of type combobox (113) and binded to table attribute with ValidValues.

Private Sub LoadMyComboBoxes(ByRef oForm As SAPbouiCOM.Form)

  Dim oRS As SAPbobsCOM.Recordset
      Dim oCombo As SAPbouiCOM.ComboBox

      ' ************************************
      ' 1) ComboBox 
      ' ************************************
      oCombo = oForm.Items.Item("cType").Specific
      If oCombo.ValidValues.Count = 0 Then
	  Dim sSQL As String = ""
	  sSQL = "SELECT Code, Name FROM [@MY_TABLE] ORDER BY Name"

	  oRS = SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

	  If oRS.RecordCount > 0 Then

	      Dim sCode As String = ""
	      Dim sName As String = ""

	      While Not oRS.EoF
		  If Not oRS.Fields.Item(0).Value Is Nothing Then
		      sCode = oRS.Fields.Item(0).Value
		      If Not oRS.Fields.Item(1).Value Is Nothing Then
			  sName = oRS.Fields.Item(1).Value
			  sName = "--Not defined-- "
		      End If
			  oCombo.ValidValues.Add(sCode, sName)
		      Catch ex As Exception
		      End Try

		  End If
	      End While
	  End If

      End If
      If oCombo.ValidValues.Count > 0 Then oCombo.Select(0, BoSearchKey.psk_Index)
      oCombo = Nothing

      ' ************************************
      ' 2) ComboBox 
      ' ************************************
      oCombo = oForm.Items.Item("cTypeSog").Specific
      If oCombo.ValidValues.Count = 0 Then
	  oCombo.ValidValues.Add("BP", "Business Partner")
	  oCombo.ValidValues.Add("AG", "Agent")
	  oCombo.ValidValues.Add("CO", "Corporation")
      End If
      If oCombo.ValidValues.Count > 0 Then oCombo.Select(0, BoSearchKey.psk_Index)
      oCombo = Nothing

  Catch ex As Exception
      ' log exception
      SBO_Application.StatusBar.SetText(ex.Message, BoMessageTime.bmt_Long, BoStatusBarMessageType.smt_Error)
      If Not oRS Is Nothing Then
	  oRS = Nothing
      End If
      System.GC.Collect() 'Release the handle to the table 
  End Try

End Sub

Also, look this [Thread: ComboBox and DataTable|;.

Hope this can help you.


Sierdna S.

Edited by: Sierdna S on Oct 21, 2008 11:23 AM

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