cancel
Showing results for 
Search instead for 
Did you mean: 

Display description & save code for a control with CFL

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member185703
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Frank,

Thanx for ur reply.

When the form is in the 'Find' mode how do I fetch the value A once I hit the 'Find' button. Value 'B' will be taken care by the UDO.

Regards,

Praveen

former_member185703
Active Contributor
0 Kudos

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

Answers (0)