Skip to Content

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

Return Code , Name using ChooseList

Hi

  Below is the code . I want when user select Code it should return Name also

Private Sub DrawAddForm(ByVal oForm As SAPbouiCOM.Form)

        Dim oItem As SAPbouiCOM.Item

        Dim oLabel As SAPbouiCOM.StaticText

        Dim oEdit As SAPbouiCOM.EditText

        Dim oButton As SAPbouiCOM.Button

        Dim oStatic As SAPbouiCOM.StaticText

        oForm0.Top = 150

        oForm0.Left = 330

        oForm0.ClientWidth = 200

        oForm0.ClientHeight = 170

        oForm0.Title = "Maintain Transaction"

        oForm0.DataSources.UserDataSources.Add("EditDS", SAPbouiCOM.BoDataType.dt_SHORT_TEXT)

AddChooseFromList()

        oItem = oForm0.Items.Add("EditTxt", SAPbouiCOM.BoFormItemTypes.it_EDIT)

        oItem.Left = 100

        oItem.Top = 10

        oItem.LinkTo = "StaticTxt"

        oEdit = oItem.Specific

        oItem = oForm0.Items.Add("StaticTxt", SAPbouiCOM.BoFormItemTypes.it_STATIC)

        oItem.Left = 10

        oItem.Top = 10

        oItem.LinkTo = "EditTxt"

        oStatic = oItem.Specific

        oStatic.Caption = "Emp Code"

        ' Name

        oItem = oForm0.Items.Add("lblName", SAPbouiCOM.BoFormItemTypes.it_STATIC)

        oItem.Left = 10

        oItem.Top = 40

        oItem.AffectsFormMode = False

        oLabel = oItem.Specific

        oLabel.Caption = "Emp Name"

        oItem = oForm0.Items.Add("txtName", SAPbouiCOM.BoFormItemTypes.it_EDIT)

        oItem.Left = 100

        oItem.Top = 40

        oItem.AffectsFormMode = False

        oItem.Visible = True

        oItem.Enabled = True

        oItem = oForm0.Items.Add("btnAdd", SAPbouiCOM.BoFormItemTypes.it_BUTTON)

        oItem.Left = 10

        oItem.Top = 130

        oItem.AffectsFormMode = False

        oButton = oItem.Specific

        oButton.Caption = "Add"

        oEdit.DataBind.SetBound(True, "", "EditDS")

        oEdit.ChooseFromListUID = "CFL1"

    End Sub

Private Sub AddChooseFromList()

        Try

            Dim oCFLs As SAPbouiCOM.ChooseFromListCollection

            Dim oCons As SAPbouiCOM.Conditions

            Dim oCon As SAPbouiCOM.Condition

            oCFLs = oForm0.ChooseFromLists

            Dim oCFL As SAPbouiCOM.ChooseFromList

            Dim oCFLCreationParams As SAPbouiCOM.ChooseFromListCreationParams

            oCFLCreationParams = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams)

            oCFLCreationParams.MultiSelection = False

            oCFLCreationParams.ObjectType = "171"

            oCFLCreationParams.UniqueID = "CFL1"

            oCFL = oCFLs.Add(oCFLCreationParams)

        Catch

            MsgBox(Err.Description)

        End Try

    End Sub


    Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent


If pVal.EventType = SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST Then

                    Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent

                    oCFLEvento = pVal

                    Dim sCFL_ID As String

                    sCFL_ID = oCFLEvento.ChooseFromListUID

                    Dim oForm As SAPbouiCOM.Form

                    oForm = SBO_Application.Forms.Item(FormUID)

                    Dim oCFL As SAPbouiCOM.ChooseFromList

                    oCFL = oForm.ChooseFromLists.Item(sCFL_ID)

                    If oCFLEvento.BeforeAction = False Then

                        Dim oDataTable As SAPbouiCOM.DataTable

                        oDataTable = oCFLEvento.SelectedObjects

                        Dim val As String

                        Try

                            val = oDataTable.GetValue(1, 0)

                        Catch ex As Exception

                        End Try

                        If (pVal.ItemUID = "EditTxt") Then

                            oForm.DataSources.UserDataSources.Item("EditDS").ValueEx = val

                        End If

                    End If

                End If

end sub

Thanks

Former Member
Not what you were looking for? View more on this topic or Ask a question