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

基于ABAP CDS的Fiori Elements列表报告动态意图导航问题

解决方案

核心思路

别把意图导航注解直接绑在BillingDocument字段上(这会导致单据编号变成可点击状态),而是定义独立的操作按钮行项目,通过语义对象导航传递参数,同时用后端的权限字段控制按钮的显隐。

具体注解实现

在你的CDS元数据扩展(比如针对ZC_BD的扩展)里添加以下代码:

@UI.lineItem: [
    // 保留原有其他行项目字段的注解...
    {
        position: 30,
        type: #FOR_ACTION,
        label: '显示 Billing Document',
        semanticObject: 'BillingDocument',
        semanticObjectAction: 'display',
        hidden: #(not IsDisplayAllowed), // 仅当IsDisplayAllowed为true时显示按钮
        parameters: [
            { name: 'BillingDocument', value: BillingDocument } // 传递单据编号参数
        ]
    },
    {
        position: 31,
        type: #FOR_ACTION,
        label: '修改 Billing Document',
        semanticObject: 'BillingDocument',
        semanticObjectAction: 'change',
        hidden: #(not IsChangeAllowed), // 仅当IsChangeAllowed为true时显示按钮
        parameters: [
            { name: 'BillingDocument', value: BillingDocument } // 传递单据编号参数
        ]
    }
]
// 如果需要在列表显示单据编号,仅保留普通行项目注解,不要加导航配置
@UI.lineItem: [{ position: 10, label: 'Billing Document' }]
BillingDocument;

// 不需要在列表展示权限标志的话,直接隐藏
@UI.hidden: true
IsDisplayAllowed;

@UI.hidden: true
IsChangeAllowed;

关键细节说明

  • 用type: #FOR_ACTION定义独立操作按钮,按钮是单独的行项目,不会关联BillingDocument字段的可点击性。
  • 修正原代码的显隐逻辑:hidden: #(not IsDisplayAllowed) 表示权限为true时显示按钮,false时隐藏,原写法逻辑是反向的。
  • 通过parameters数组传递BillingDocument参数,确保跳转VF03/VF02时携带正确的单据编号。
  • 如果不需要在列表展示单据编号,直接移除它的@UI.lineItem注解即可,不影响参数传递。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.11 18:05:00