on 06-27-2007 2:33 PM
Hi all,
I have an edit text which is associated with a Choose From List(CFL). The CFL displays 2 fields viz. Code & Name. I need my edit text to display the 'Name' field but should save the Code field in the database.
Combo box has this functionality of 'Display Description' that display the description but stores the corresponding Code. How do I achieve this functionality for CFL.
Praveen.
Hi Praveen,
...well it has nothing to do with CFL when you want to display value A, but want to save value B.
You should plug a UserDataSource behind your EditText field + via code fill the right code into the DBDataSource field.
When you are using UDO - that's all you need to do; when you are using a form that is not connected to a UDO you will to handle the saving in the usual manner...
HTH,
Frank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen,
Here's code (based/generated on/through B1DE... I am sure you can "translate" it for your purposes) that does the trick:
<B1Listener(BoEventTypes.et_ITEM_PRESSED, true)> _
Public Overridable Function OnBeforeItemPressed(ByVal pVal As ItemEvent) As Boolean
Dim form As Form = B1Connections.theAppl.Forms.Item(pVal.FormUID)
Dim item As Item = form.Items.Item("1")
Dim button As Button = CType(item.Specific, Button)
Dim oEdt As SAPbouiCOM.EditText
Try
oEdt = form.Items.Item("NMS_MyDescr").Specific
Dim oDTab As SAPbouiCOM.DataTable
If form.DataSources.DataTables.Count = 0 Then
oDTab = form.DataSources.DataTables.Add("DummyDT")
Else
oDTab = form.DataSources.DataTables.Item("DummyDT")
End If
oDTab.ExecuteQuery("select U_MyCode from [@NMS_UDO_SDN] where U_MyDescr = '" & oEdt.String & "'")
oEdt = form.Items.Item("NMS_MyCode").Specific
oEdt.String = oDTab.GetValue("U_MyCode", 0).ToString()
Catch ex As Exception
B1Connections.theAppl.StatusBar.SetText(ex.Message, BoMessageTime.bmt_Short)
End Try
Return True
End Function
Regards,
Frank
Message was edited by:
Frank Moebius
To make it easier for me to compile a SQL for the DataTable I have the description in the UDT as well, but that doesn't have any impact on the trick...
User | Count |
---|---|
94 | |
9 | |
8 | |
5 | |
4 | |
3 | |
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.