cancel
Showing results for 
Search instead for 
Did you mean: 

ChooseFromList

Former Member
0 Kudos
64

Hi

It is creating ChooseList option , but i want to display data from CUVV table , what changes should be done & i want filter condition also.

Secondly when seleccted value from list , it is not displaying  any value.

Friend Class ClsSal

    Public sErrMsg As String

    Public lErrCode As Integer

    Public lRetCode As Integer

    Private WithEvents SBO_Application As SAPbouiCOM.Application

    Private oCompany As SAPbobsCOM.Company

    Dim SboGuiApi = New SAPbouiCOM.SboGuiApi

    Dim oForm As SAPbouiCOM.Form

    Dim oItem As SAPbouiCOM.Item

    Dim oStaticText As SAPbouiCOM.StaticText

    Dim oEditText As SAPbouiCOM.EditText

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

        If pVal.FormType = 133 And pVal.BeforeAction = False Then

            oForm = Me.SBO_Application.Forms.GetForm(pVal.FormType, pVal.FormTypeCount)

            Try

                If pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_LOAD Then

                    'oForm = Me.SBO_Application.Forms.GetForm(pVal.FormType, pVal.FormTypeCount)

                    Dim oItems As SAPbouiCOM.Items = SBO_Application.Forms.Item(FormUID).Items

                    oItem = oForm.Items.Add("lbltr", SAPbouiCOM.BoFormItemTypes.it_STATIC)

                    oItem.Height = oForm.Items.Item("70").Height

                    oItem.Top = oForm.Items.Item("70").Top + 20

                    oItem.Left = oForm.Items.Item("70").Left

                    oItem.Width = oForm.Items.Item("70").Width

                    oItem.Visible = True

                    oItem.LinkTo = "txttr"

                    oStaticText = ((oItem.Specific))

                    oStaticText.Caption = "ABC "

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

                    AddChooseFromList()

                    oItem = oForm.Items.Add("txttr", SAPbouiCOM.BoFormItemTypes.it_EDIT)

                    oItem.Height = oForm.Items.Item("14").Height

                    oItem.Top = oForm.Items.Item("14").Top + 35

                    oItem.Left = oForm.Items.Item("14").Left

                    oItem.Width = oForm.Items.Item("14").Width

                    oItem.Visible = True

                    oItem.Enabled = True

                    oItem.LinkTo = "lbltr"

                    oEditText = ((oItem.Specific))

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

                    oEditText.ChooseFromListUID = "CFL1"

                   

                   

                   

                End If

                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(0, 0)

                        Catch ex As Exception

                        End Try

                        If (pVal.ItemUID = "EditTxt") Or (pVal.ItemUID = "Button") Then

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

                        End If

                    End If

                End If

               

            Catch oEx As Exception

                MessageBox.Show(oEx.Message)

            Finally

                GC.Collect()

            End Try

        End If

    End Sub

    Private Sub AddChooseFromList()

        Try

            Dim oCFLs As SAPbouiCOM.ChooseFromListCollection

            'Dim oCons As SAPbouiCOM.Conditions

            'Dim oCon As SAPbouiCOM.Condition

            oCFLs = oForm.ChooseFromLists

            Dim oCFL As SAPbouiCOM.ChooseFromList

            Dim oCFLCreationParams As SAPbouiCOM.ChooseFromListCreationParams

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

            ' Adding 2 CFL, one for the button and one for the edit text.

            oCFLCreationParams.MultiSelection = False

            oCFLCreationParams.ObjectType = "2"

            oCFLCreationParams.UniqueID = "CFL1"

            oCFL = oCFLs.Add(oCFLCreationParams)

            ' Adding Conditions to CFL1

            'oCons = oCFL.GetConditions()

            'oCon = oCons.Add()

            'oCon.Alias = "CardType"

            'oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL

            'oCon.CondVal = "C"

            'oCFL.SetConditions(oCons)

            'oCFLCreationParams.UniqueID = "CFL2"

            'oCFL = oCFLs.Add(oCFLCreationParams)

        Catch

            MsgBox(Err.Description)

        End Try

    End Sub

End Class

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

christophe_averous
Active Participant
0 Kudos

Hi,

To use the choose from list you have to deal with an objecttype:

The list of the object type can be found in the sdk help: BoObjectTypes Enumeration

For example in your example 2 is the Business partner Object.

CUVV is not an object.

FormattedSearches object is 219 which is related to CSHS table (CUVV is a child table from this object). For me want you want to do is not possible.

Secondly to display the value add the following:

 

    Private Sub SBO_ItemEvent_CHOOSE_FROM_LIST(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean, ByRef pSBO As SAPbouiCOM.Application)
        Dim oForm As SAPbouiCOM.Form
        Dim oItem As SAPbouiCOM.Item
        Dim oItem2 As SAPbouiCOM.Item
        Dim oFolder As SAPbouiCOM.Folder
        Dim oMatrix As SAPbouiCOM.Matrix
        Try
            Select Case pVal.ItemUID
                Case Is = "Whs"
                    If pVal.ActionSuccess = True Then
                        oForm = pSBO.Forms.Item(FormUID)
                        Dim oCFL As SAPbouiCOM.ChooseFromList
                        Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent
                        oCFLEvento = pVal
                        Dim sCFL_ID As String
                        sCFL_ID = oCFLEvento.ChooseFromListUID
                        oCFL = oForm.ChooseFromLists.Item(sCFL_ID)
                        Dim oDataTable As SAPbouiCOM.DataTable
                        oDataTable = oCFLEvento.SelectedObjects
                        Dim val As String
                        Try
                            val = oDataTable.GetValue(0, 0)

                        Catch ex As Exception

                        End Try
                        oForm.DataSources.UserDataSources.Item("Whs").ValueEx = val
                    Else
                        Dim oCFL As SAPbouiCOM.ChooseFromList
                        Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent
                        oCFLEvento = pVal
                    End If
            End Select
        Catch ex As Exception
            pSBO.SetStatusBarMessage(ex.Message, BoMessageTime.bmt_Short, True)
        End Try

    End Sub

Regards

Christophe