Technical Articles
How to redefine a CDS based Odata Service with Annotations ?
This blog will give you details on how to link the annotations of the Odata Service created based on CDS with the redefined service.
Problem:
Whenever you redefine a Odata service which was created based on CDS reference, the annotations of the redefined service will not be linked with the new Odata service .
We will now see how to eliminate this problem with one configuration technique.
Solution:
- First of all lets have a look at how the SEGW project which was created based on CDS .
This Odata service has annotation model linked to this service.
The highlighted one is the Annotation model created and associated with the service in transaction /IWBEP/REG_VOCAN.
The above mapping in /IWBEP/REG_VOCAN is an automated process.
2. What will happen if there is an service assignment in transaction /IWBEP.REG_VOCAN ?
When you register the Odata service, it will check for the entry in transaction /IWBEP/REG_VOCAN if the service is mapped with any Vocabulary model.
If entry exists, an entry will be created in DB table Vocabulary Annotation File -/IWFND/I_MED_VAA
3. The annotation will be retrieved in WebIDE only if the entry exists in /IWFND/I_MED_VAA.
Now Let’s have a look , how the new SEGW project in which the above service is redefined.
4.Create a SEGW project -> Redefine->Odata Service(GW).
5. Select the required entities and generate the project.
Do not register the service.
Configuration – Important step – In Back end system where the SEGW project exists.
6. Before registering the service,
- Go to transaction /IWBEP/REG_VOCAN .
- Select the annotation model of the Original Service (which you have redefined in point 1)
7. Click Add assignment – Give the service name generated (in point 1) and click “Enter”.
8. An entry will be created as below.
9. Now register the service
10. Now in WebIDE – Lets select redefined service
11. You will get the annotations of the original service – This is because of Configuration in point 6 and point 7.
Now what could be done if you are already facing the problem for a registered Odata service ?
1. De-register the service in transaction /IWFND/MAINT_SERVICE.
2. Perform the configuration in /IWBEP/REG_VOCAN (Point 6 & 9).
In Back end system where the SEGW project exists.
3. Register the service again in transaction /IWFND/MAINT_SERVICE.
Road Map:
We are planning to automate this configuration steps for CDS based Odata service when redefined.
Stay tuned for updates.
Hi Manikandan,
Thanks for sharing this blog!!!
It was really helpful.
I have one query on same scenario where we are redefining ODATA service having CDS as data source reference. When I add CDS to new service I don't see that CDS entity in metadata. Don't know why it's like this. Do you have any idea about it.
Thanks,
Dhiraj M
Hi,
I have the same problem, when I add CDS to new service I don't see that CDS entity in metadata.
Is there any solution for that issue?
Best regards
Jan
I think it's only possible with a workaround as adding a CDS data source reference to a redefinition will not lead to a " combined model exposure" . The result of method "GET_MODEL_EXPOSURE" from the MPC class of your extension project is not combined/merged with the result of the method "GET_MODEL_EXPOSURE" from the base MPC class.
Furtherore in an extension project the get_entity and get_entityset nethods are not generated automically.
The trick is to add a new entity to your model based on the DDIC structure which is assigned to your CDS view.
In your DPC_EXT class you have to implement:
The implementation of this method could be copied from a temporary SEGW project where you include the same CDS view as a data source reference. Just change the value of the UUID.
For example:
In the get entityset method you have to put:
In the get_entity method:
Hi,
if for any reason some of you take the miserable path like me and keep refreshing only the anno call, which fails with HTTP 400, then make sure to reload the whole app instead. Due to caching only that way will there be a reload of model metadata and the changes of reg_vocan be visible. Even if you keep editing your model and cleaning up the model cache!
I have already tried addin the redefinition service to reg_vocan but due to caching thought that it does not help. After hours spent debugging I have realized that the above listed way which I have taken too is the right way - just the stupid caching-and-generating-table-entry-based-on-another-entry situation tricked me.
Hi Manikandan Rajasekaran
I just followed the same steps as described in your blog, when creating the WebIDE project the annotitaion model of the original service was found, but wen opening the annotation file in my app the external annotations are not shown.
Do you have any idea?
Thanks!
Valuable post! Thanks, Manikandan! Looks like using this approach(+-) we can implement lightweght CRUD WEBAPI on Netweaver 7.50 utilizing power of CDS-views and SADL and skipping BOPF Gas Factory implemetation :)))
Hi!
I had to enhance the Manage Customer Line Items App (F0711), wich has a Annotation model.
So, after redefine a new Odata, referene to FAR_CUSTOMER_LINE_ITEMS, I develop what we needed, and crieate a new extended APP.
All Z development and features of APP is work, but the Value Help doesn't.
So I suppesed to we needed to assign the Standard annotation, but in the tcode /IWFND/REG_VOCAN we don't have authorization to input any service in the Standard Annotation.
Did anyon have a suggestion?