cancel
Showing results for 
Search instead for 
Did you mean: 

Choose from list button

Former Member
0 Kudos

L.S.,

Does someone have some sample code how to implement the 'Choose from list button'. So to select for example a business partner, when you hit the tab-key in the cardcode field of my own form.

I'm using SBO 6.5. Your help would be really appreciated.

Regards,

Michiel Reuser

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I hope that this example will help you.

=========================================

Private oBPCode As SAPbouiCOM.EditText

Private oBPName As SAPbouiCOM.EditText

Private Sub SBOApplication_ItemEvent(ByVal FormUID As String, pVal As SAPbouiCOM.IItemEvent, BubbleEvent As Boolean)

If pVal.FormUID = "MasterForm" Then

If pVal.Before_Action = False Then

if pVal.EventType = et_ITEM_PRESSED and pVal.ItemUID = "ListItem" then

Call Charger_Liste_Article

End if

End If

End If

If pVal.FormUID = "ListForm" Then

If pVal.EventType = et_ITEM_PRESSED and pVal.ItemUID = "OkBtn" then

Dim ii As Long

ii = oMatrix.GetNextSelectedRow

If ii <> -1 Then

Set oBPCode = oMatrix.Columns("ItemCode").Cells(ii).Specific

Set oBPName = oMatrix.Columns("ItemName").Cells(ii).Specific

ItemUDS.Value = oBPCode.String

NameUDS.Value = oBPName.String

End If

oBPListForm.Close

Set oBPListForm = Nothing

Set oUserDataSource = Nothing

Set oDBDataSource = Nothing

End If

End If

End Sub

Sub Charger_Liste_Article()

CreateArticleForm

AddDataSourceToArticleForm

BindDataToArticleForm

SetMatrixArticle

oBPListForm.Visible = True

End Sub

Private Sub CreateArticleForm()

Dim oItem As SAPbouiCOM.Item

Dim oButton As SAPbouiCOM.Button

Set oBPListForm = SBOApplication.Forms.Add("ListForm", ft_Fixed)

oBPListForm.Title = "Choice item ..."

oBPListForm.Left = 350

oBPListForm.Width = 300

oBPListForm.Top = 50

oBPListForm.Height = 320

Set oItem = oBPListForm.Items.Add("OkBtn", it_BUTTON)

oItem.Left = 5

oItem.Width = 65

oItem.Height = 19

oItem.Top = 260

Set oButton = oItem.Specific

oButton.Caption = "Ok"

Set oItem = oBPListForm.Items.Add("2", it_BUTTON)

oItem.Left = 75

oItem.Width = 65

oItem.Height = 19

oItem.Top = 260

Set oButton = oItem.Specific

oButton.Caption = "Cancel"

'// Adding a Matrix item

Set oItem = oBPListForm.Items.Add("Matrix", it_MATRIX)

oItem.Left = 5

oItem.Width = 283

oItem.Top = 5

oItem.Height = 245

Set oMatrix = oItem.Specific

Set oColumns = oMatrix.Columns

'//***********************************

'// Adding Culomn items to the matrix

'//***********************************

Set oColumn = oColumns.Add("#", it_EDIT)

oColumn.TitleObject.Caption = "#"

oColumn.Editable = False

Set oColumn = oColumns.Add("ItemCode", it_EDIT)

oColumn.TitleObject.Caption = "Item code"

oColumn.Editable = False

Set oColumn = oColumns.Add("ItemName", it_EDIT)

oColumn.TitleObject.Caption = "Item name"

oColumn.Editable = False

oMatrix.AutoResizeColumns

End Sub

Public Sub AddDataSourceToArticleForm()

Set oUserDataSource = oBPListForm.DataSources.UserDataSources.Add("index", dt_SHORT_NUMBER)

Set oDBDataSource = oBPListForm.DataSources.DBDataSources.Add("OITM")

End Sub

Public Sub BindDataToArticleForm()

Set oColumn = oMatrix.Columns.Item("#")

oColumn.DataBind.SetBound True, "", "index"

Set oColumn = oMatrix.Columns.Item("ItemCode")

oColumn.DataBind.SetBound True, "OITM", "ItemCode"

Set oColumn = oMatrix.Columns.Item("ItemName")

oColumn.DataBind.SetBound True, "OITM", "ItemName"

End Sub

Public Sub SetMatrixArticle()

Dim i As Long '// to be used as counter

oMatrix.Clear

oDBDataSource.query

For i = 0 To oDBDataSource.Size - 1

oDBDataSource.Offset = i

oUserDataSource.Value = i + 1

oMatrix.AddRow

Next i

oMatrix.AutoResizeColumns

oMatrix.SelectionMode = ms_Single

End Sub

Former Member
0 Kudos

The code supplied wasnt exacly what i was looking for but it was helpfull anyway so thanks for that.

Question: How do i show the "choose from list button" next to the edittext on the mainform, there doesnt seem to be a BoFormItemTypes value for it.

Thanks in advance

Michiel Reuser

Former Member
0 Kudos

Use item type it_BUTTON, specific Type=bt_Image, Image=CHOOSE_ICON. SAP then uses its internal resource CHOOSE_ICON.

The xml will look like this:

<Application>

<forms>

<action type="add">

<form ...>

<items>

<action type="add">

<item ... type="4" height="15" width="15" ...>

<specific image="CHOOSE_ICON"/>

</item>

</action>

</items>

</form>

</action>

</forms>

</Application>

You cannot do this in ScreenPainter.

It is always useful to do GetAsXML on a system form to find out how they do it ...

Regards,

Jan

FOA
Advisor
Advisor
0 Kudos

Just as an additional information, in the 2005 SDK version this object is exposed and can be linked to several field types.

Regards,

Felipe