cancel
Showing results for 
Search instead for 
Did you mean: 

Combo in XML

Former Member
0 Kudos

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">

<ValidValues>

<action type="add"/>

</ValidValues>

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

</specific>

</item>

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

<specific caption="Codigo de IIBB" />

</item>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

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>
<ExtendedObject></ExtendedObject>
</column>

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
  Try
      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)
	  oRS.DoQuery(sSQL)

	  If oRS.RecordCount > 0 Then

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

	      oRS.MoveFirst()
	      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
		      Else
			  sName = "--Not defined-- "
		      End If
		      Try
			  oCombo.ValidValues.Add(sCode, sName)
		      Catch ex As Exception
		      End Try

		  End If
		  oRS.MoveNext()
	      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)
  Finally
      If Not oRS Is Nothing Then
	  System.Runtime.InteropServices.Marshal.ReleaseComObject(oRS)
	  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.

Regards

Sierdna S.

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

Answers (3)

Answers (3)

Former Member
0 Kudos

Thank you very much Sierdna, it has served me very much your help.

Andrés.-

Former Member
0 Kudos

Hi Andres,

we can add combo box in xml this way.

<validvalues>

<action type="add">

<ValidValue value="P" description="Prepaid"/>

<ValidValue value="C" description="Collect"/>

</action>

</ValidValues>

hope this helps you.

Regards,

OMPrakash

Former Member
0 Kudos

Hi..

Send me correct scenario.

Regards..

Billa 2007