Showing results for 
Search instead for 
Did you mean: 

Adjust Entity Name with CDS Referenced Data Sources in Gateway


Hi experts,

We're developing Odata services and are using CDS for read model. We weighed in following options:

1) SEGW Project and import the CDS model and use mapping for the read function

2) CDS View published directly to Odata service, SEGW Project that imports the OData Service as a model

We chose option 2 so that we do not have to regenerate when we do changes to our CDS view, and everything is handled via CDS and the model.

But, i find it annoying that the entity model is taken over from the CDS view meaning Z naming convention. For some non-CDS scenario's we define our own entity that we implement for which we don't have to follow the Z naming, which gives us following result:

- BusinessPartner

Is there a way to redefine the CDS based entity name? In SEGW node 'Model References' we can change the name, but it doesn't seem to do anything.




I'm using the annotation:


This annotation has table/view scope, and when applied, whatever name is used there will be used when generating the service.

So in your CDS code, before the define view keywords you would include a line like: 'SalesOrder'

And the next time you generate the runtime objects with SEGW this name will be used to name the entity within the service, making it independent from the name of the underlying view..

Accepted Solutions (1)

Accepted Solutions (1)

Product and Topic Expert
Product and Topic Expert

Hi Wouter,

you have to redefine the DEFINE method of the MPC_EXT class of your Service Builder Project.

In the following example I created a SEGW project ZRDS resulting in a Service ZRDS_SRV using the CDS view


As a result the Name of the entity set would be named SEPM_I_SalesOrder_E while the entity type would be named SEPM_I_SalesOrder_EType.

Now the entity type is called SalesOrder and the entity set is called SalesOrders.

The result can be checked in the excerpt of the $metadata document (see below).

Best Regards,


 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( 'SEPM_I_SalesOrder_EType').

 LO_ENTITY_TYPE->SET_NAME( IV_NAME = 'Salesorder' ).

 lo_entity_set = model->get_entity_set( 'SEPM_I_SalesOrder_E').
 lo_entity_set->SET_NAME( IV_NAME = 'Salesorders' ).

<EntitySet sap:content-version="1" sap:deletable="false" sap:updatable="false" sap:creatable="false" Name="Salesorders" EntityType="ZRDS_SRV.Salesorder"/>
0 Kudos

Hi Andre,

i know thats an older Thread but i am facing the same issue and i didn't find so much documentation on the subject.

Your solution works to some good extend but there are a huge variety of issues. For example the Anotations dont work anymore they still refrence the CDS view name. The same happens with all the associations.

Now the issue with the Anotations i could in my project circumvent by offering another Entity that gives the mapping between Anotations and Odata Entities, since i am generating the UIs alone.

The real issue is a bug that gives wrong links when the expand option is given in the OData Request. If the response is requested in xml then the result is always correct. But if the response is requested in json format then we have the following problem: if the cache of the OData Services (IWBEP & IWFND CACHE_CLEANUP) then the response is correct. Every subsequent call with expand though gives the expanded entities with their CDS View name.

So is there a way to correct those issues? Maybe in define we have to change Assocations and so on?

Best regards,


Answers (0)