cancel
Showing results for 
Search instead for 
Did you mean: 

CDS Annotations and Reference Data Source Problem

ceedee666
Active Contributor
0 Kudos

Hi all,

I have the following problem. I create a CDS view and on this basis an OData service using the Reference Data Source approach. This is an excerpt of the CDS view:

/* Definition of the VDM view type */
@VDM.viewType: #CONSUMPTION

/* BOPF object model */
@ObjectModel: {
    modelCategory: #BUSINESS_OBJECT,
    compositionRoot: true,
    
    /* forwarding of the transactional proessing */
    transactionalProcessingDelegated: true,
    
    semanticKey: ['PurchaseOrderID'],
    
    createEnabled: true,
    updateEnabled: true,
    deleteEnabled: true
}

define view ZC_PurchaseOrderHeaderTP 
    as select from ZI_PurchaseOrderHeaderTP
    /* associations to other BOPF nodes */
    association [0..*] to ZC_PurchaseOrderItemTP as _Items
    on $projection.PurchaseOrderHeaderKey = _Items.PurchaseOrderHeaderKey 
{
        @UI.hidden: true
    key PurchaseOrderHeaderKey,
        
        @UI.lineItem.position: 10
        @UI.identification.position: 10
        PurchaseOrderID,
        
        @UI.hidden: true
        SupplyerKey,
        
        @UI.hidden: true
        NoteKey,
        CurrencyCode,

After creating the OData service using the Gateway Service Builder I also implement an extension in the Model Provider Extension Class. This extension is shown below. It basically just renames the entities in the OData service.

CLASS zcl_z_erp_impl_ws19_mpc_ext IMPLEMENTATION.
  METHOD define.

    super->define( ).

    DATA: lo_entity_type TYPE REF TO /iwbep/if_mgw_odata_entity_typ,
          lo_entity_set  TYPE REF TO /iwbep/if_mgw_odata_entity_set,
          lo_property    TYPE REF TO /iwbep/if_mgw_odata_property.


    lo_entity_type = model->get_entity_type( 'ZC_PurchaseOrderHeaderTPType').
    lo_entity_type->set_name( iv_name = 'PurchaseOrderHeader' ).

    lo_entity_set = model->get_entity_set( 'ZC_PurchaseOrderHeaderTP').
    lo_entity_set->set_name( iv_name = 'PurchaseOrderHeaders' ).

        lo_entity_type = model->get_entity_type( 'ZC_PurchaseOrderItemTPType').
    lo_entity_type->set_name( iv_name = 'PurchaseOrderItem' ).

    lo_entity_set = model->get_entity_set( 'ZC_PurchaseOrderItemTP').
    lo_entity_set->set_name( iv_name = 'PurchaseOrderItems' ).

  ENDMETHOD.

ENDCLASS.

Finally, I created an Fiori Elements based application using the list report template on the basis of this service. The problem I'm now facing is the following. As long as there is an implementation of the define method in the model provider extension class the UI-annotations from the CDS view are not transferred to the Fiori Elements application. So e.g. no fields are visible in the table of the list view. As soon as I remove the implementation of the define method everything works as expected.

Does anyone know how to solve this problem? Am I missing something in the implementation of the model provide extension class?

Christian

View Entire Topic
Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

I have seen those the first time in SAP S/4HANA 1809