You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

自定义用户表单添加双Choose From List(CFL)的可行性及报错解决咨询

Multiple Choose From Lists (CFLs) on a Single Custom SAP B1 Form

Absolutely you can add a second CFL for the Item Master (OITM) table to your custom form—you just need to stop relying on the form's global ObjectType property to auto-configure your CFLs. Let me break down the problem and how to fix it:

Why the ObjectType Restriction Seems Like a Block

Your first CFL works when the form's ObjectType is set to 2 (Business Partners) because SAP B1 auto-links the CFL to that business object by default. But when you remove that property, the auto-configured CFL breaks, which is why you get an error. The good news is you don't need to rely on this auto-linking at all.

Step-by-Step Solution

1. Reset the Form's ObjectType

Set your form's ObjectType to -1 (this marks it as a fully custom form, no tied business object). This removes the global binding that was forcing the CFL to only work with Business Partners.

2. Manually Configure Both CFLs

Whether you're using the SAP B1 Form Builder (visual design) or writing SDK code, you can create independent CFLs for each table:

Option A: Using Form Builder (No Code)

  • Open your custom form in Form Builder.
  • For your Business Partner text box:
    1. Select the text box, go to the Choose From List property.
    2. Click the ellipsis to open the CFL configuration window.
    3. Create a new CFL, set its Object Type to 2 (Business Partners), give it a unique ID like CFL_BP.
    4. Select the fields you want to display (e.g., CardCode, CardName) and set the default return field to CardName.
  • For your Item Master text box:
    1. Repeat the same steps, but set the Object Type to 4 (Items), use a unique ID like CFL_Item.
    2. Choose fields like ItemCode, ItemName and set the return field to your preferred value (e.g., ItemCode or ItemName).

Option B: Using SDK Code (Programmatic Setup)

If you're building the form via code, you can create and bind CFLs directly:

' Initialize the form first (your existing form setup code here)

' Create Business Partner CFL
Dim cflBPParams As SAPbouiCOM.ChooseFromListCreationParams = _
    SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams)
cflBPParams.UniqueID = "CFL_BP"
cflBPParams.ObjectType = "2" ' Business Partner object type
cflBPParams.MultiSelection = False
Dim cflBP As SAPbouiCOM.ChooseFromList = oForm.ChooseFromLists.Add(cflBPParams)

' Bind to Business Partner text box
Dim txtBP As SAPbouiCOM.EditText = oForm.Items.Item("txtCardName").Specific
txtBP.ChooseFromListUID = "CFL_BP"

' Create Item Master CFL
Dim cflItemParams As SAPbouiCOM.ChooseFromListCreationParams = _
    SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_ChooseFromListCreationParams)
cflItemParams.UniqueID = "CFL_Item"
cflItemParams.ObjectType = "4" ' Item object type
cflItemParams.MultiSelection = False
Dim cflItem As SAPbouiCOM.ChooseFromList = oForm.ChooseFromLists.Add(cflItemParams)

' Bind to Item text box
Dim txtItem As SAPbouiCOM.EditText = oForm.Items.Item("txtItemName").Specific
txtItem.ChooseFromListUID = "CFL_Item"

3. Handle CFL Selection Events

You'll need to capture the ChooseFromListEvent to populate the correct text box when a user selects an item. Here's how to distinguish between the two CFLs:

Private Sub SBO_Application_ChooseFromListEvent(ByRef pVal As SAPbouiCOM.ChooseFromListEvent, ByRef BubbleEvent As Boolean) _
    Handles SBO_Application.ChooseFromListEvent

    If pVal.FormUID <> "YourCustomFormUID" Then Return

    Dim oForm As SAPbouiCOM.Form = SBO_Application.Forms.Item(pVal.FormUID)
    Dim selectedData As SAPbouiCOM.DataTable = pVal.SelectedObjects

    If selectedData.Rows.Count = 0 Then Return

    Select Case pVal.ChooseFromListUID
        Case "CFL_BP"
            ' Populate Business Partner text box
            oForm.Items.Item("txtCardName").Specific.Value = selectedData.GetValue("CardName", 0)
            ' Optional: Populate CardCode in a hidden field if needed
            ' oForm.Items.Item("txtCardCode").Specific.Value = selectedData.GetValue("CardCode", 0)
        
        Case "CFL_Item"
            ' Populate Item text box
            oForm.Items.Item("txtItemName").Specific.Value = selectedData.GetValue("ItemName", 0)
            ' Optional: Populate ItemCode
            ' oForm.Items.Item("txtItemCode").Specific.Value = selectedData.GetValue("ItemCode", 0)
    End Select
End Sub

Key Notes

  • Always use unique IDs for each CFL to avoid conflicts.
  • When using Form Builder, make sure the form's ObjectType is set to -1 (Custom) to prevent auto-binding issues.
  • You can extend this approach to add as many CFLs as needed for different tables (e.g., G/L Accounts, Vendors) on the same form.

内容的提问来源于stack exchange,提问作者Praxiom

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 09:07:41