美文网首页SAP CDS viewSAP 修行SAP
使用 SAP CDS view SQL Function 将视图

使用 SAP CDS view SQL Function 将视图

作者: _扫地僧_ | 来源:发表于2021-08-24 08:59 被阅读0次

    SAP 用于学习目的设计了很多 demo 开发包,里面包含了很多用于演示目的的 CDS view,类似经典的 Flight 模型,比如视图 /DMO/I_Travel_U.

    这个视图和客户相关的信息只有一个 customer ID,因此基于该视图生成的 Fiori Elements 应用里,只有一个 Customer ID 可供显示:

    我们首先使用 association,通过主视图 /DMO/I_TRAVEL_U 的 CustomerID 字段,连接到 /DMO/I_CUSTOMER 视图,再使用 SQL Function 中的 concat_with_space, 将客户 association 中的 Title 和 LastName 连接在一起,将结果使用别名 Addressee 进行存储:

    @AbapCatalog.sqlViewName: 'ZCTRAVELJERRY'
    @AbapCatalog.compiler.compareFilter: true
    @AbapCatalog.preserveKey: true
    @AccessControl.authorizationCheck: #CHECK
    @EndUserText.label: 'Consumption view from /DMO/I_TRAVEL_U'
    @Metadata.allowExtensions: true
    @Search.searchable: true
    define view Z_C_TRAVEL_DATA_JERRY as select from /DMO/I_Travel_U 
    association [1..1] to /DMO/I_Agency as _Agency on $projection.AgencyID = _Agency.AgencyID
    association [1..1] to /DMO/I_Customer as _Customer on $projection.CustomerID = _Customer.CustomerID
    {       
        key TravelID,
    
        @ObjectModel.text.association: '_Agency'
        AgencyID,
        CustomerID,
        concat_with_space(_Customer.Title, _Customer.LastName, 1) as Addressee,
        BeginDate,
        EndDate,
        BookingFee,
        TotalPrice,
        CurrencyCode,
        @Search.defaultSearchElement: true
        @Search.fuzzinessThreshold: 0.90
        Memo,
        Status,
        LastChangedAt,
        /* Associations */
        _Agency,
        _Booking,
        _Currency,
        _Customer
    }
    
    

    最后 Fiori Elements 里的显示效果:


    更多Jerry的原创文章,尽在:"汪子熙":


    相关文章

      网友评论

        本文标题:使用 SAP CDS view SQL Function 将视图

        本文链接:https://www.haomeiwen.com/subject/sfykpltx.html