on 06-08-2018 8:16 PM
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:
- ZV_CDS_SALES_ORDER
- 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.
Thanks!
Wouter
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
SEPM_I_SalesOrder_E.
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,
Andre
method DEFINE.
super->DEFINE( ).
* catch /IWBEP/CX_MGW_MED_EXCEPTION. "
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' ).
* catch /IWBEP/CX_MGW_MED_EXCEPTION. "
lo_entity_set = model->get_entity_set( 'SEPM_I_SalesOrder_E').
lo_entity_set->SET_NAME( IV_NAME = 'Salesorders' ).
endmethod.
<EntitySet sap:content-version="1" sap:deletable="false" sap:updatable="false" sap:creatable="false" Name="Salesorders" EntityType="ZRDS_SRV.Salesorder"/>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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,
Georgios
User | Count |
---|---|
65 | |
8 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.