Standard service - a fixed amount of work that is performed at a fixed price.  Post Service

  

Sunday, 21 April 2019 13:23

OData Service from CDS Annotation Not Working in Browser Mode

Written by  https://sapyard.com/odata-service-from-cds-annotation-not-working-in-browser-mode/
Rate this item
(0 votes)

By now we assume you know that we can create OData Service from CDS view without a single line of code in SEGW. Yes we can expose CDS

view as OData Service without going to t-code SEGW. Annotation @OData.publish : true does the trick. CDS is one of the most significant and powerful innovation of SAP which would be used in all future developments in S/4HANA. Author Paul Hardy rightly said “CDS View is a big/powerful SELECT statement on steroids”.

Once the OData is created, it needs to be registered like any other OData Service using t-code /IWFND/MAINT_SERVICE. This is one time activity for the CDS generated OData Service.

Check this: Create your first OData Service

Note: The ODataService created from CDS View can only perform ‘R’ i.e. GET operation of CRUD. It cannot do Create, Update or Delete operationsof the CRUD.

The other day, we ran into a strange hiccup in our Embedded S/4HANA System. We created a CDS View and exposed it as OData Service using the @OData.publish: true annotation. The OData Service got created successfully and it worked perfectly in /IWFND/GW_CLIENT test but not in Browser mode.

Below is the CDS with @OData.publish: true.

We created the CDS and the corresponding OData Service in client 110 (development); while our test data resides in client 130 (testing client in development system). When we tested the OData Service in SAP Gateway Client 130, it worked perfectly as shown below:

But, when we tried to test the same OData Service in client 130 in Browser mode, it started pointing to the client 110. Remember, we are in 130 client but still the OData was forcing to be opened in client 110.

Our SAP Gateway is set up in S/4HANA-130 client. Since theGateway is embedded rather than aHUB, there is no alias other than Local for OData in our S/4 environment. Therefore, the processing mode should be setto CO-DEPLOYEDONLY rather than ROUTING-BASEDwhich should allow testing of the OData in S/4HANA-130 rather than trying torun the backend call on S/4HANA-110.

Check below, for our system, we have forced the Processing Mode to Co-deployed only in t-code /IWFND/MAINT_SERVICE.

Also check there is no System Aliases in S/4HANA test client130. It automatically picks130 as Gateway is configured as embedded and thereis no alias other than local for OData.

Also Read : ADT Eclipse/HANA Studio for ABAPers

If you are wondering, what is Routing-based and Co-deployed only Processing Mode? Below definitions from SAP Help might give a better clarity.

Definition of OData Service Processing Mode

  • Routing-based: This is the default processing mode. That means the SAP Gateway system uses the routing configuration for this service and passes the OData request via RFC to one or more remote backend systems (different backend systems are available in case  of Multiple Origin Composition) or via a direct call to the local system (RFC bypassing). Till now, the RFC bypassing implementation just saves the RFC and network overhead but it is not optimized for data transfer and also for database accesses within the local system.
  • Co-deployed only: The optimization for service processing in a co-deployed system is realized for a fast data transfer between the SAP Gateway system and the IW_BEP component on the local system. Using this processing mode, the routing configuration is not used and the OData request is directly passed to the IW_BEP component.
  • As the routing information is not used for the processing mode “Co-deployed only”, no additional system aliases can be assigned to this service via transaction /IWFND/MAINT_SERVICE.
  • When some more system aliases are added to a service via transport, they are ignored during the service processing at runtime. The transaction /IWFND/MAINT_SERVICE will show in this case a popup to inform and to require the administrators either to change the processing mode back to “Routing-based” or to remove the needless system aliases.

Use

Choose the processing mode ‘Co-Deployed only’ to improve the service processing performance if this service is registered and published in a co-deployed system only.

Our Issue: OData Service created using CDS annotation re-directs the browser to the development client. OData Service works perfectly in SAP Gateway Client test in /IWFND/MAINT_SERVICE but fails in Call Browser mode. The browser tries to call the other client 110 when being tested in 130.

Solution: The resolution was rather simple. When we created the OData Service using annotations in CDS View, the OData Service got created with the development client (110) as default. Reason being, you can create OData from CDS only in your development client.

You can check it in SICF t-code.

We removed the Clientdefinition in SICF which magically corrected the issue.

Let us retest in our 130 client. The browser correctly asksfor 130 credentials.

Also Explore : How to Consume Custom OData in SAPUI5 Application

This is just a simple use case we encountered in our S/4HANA system. This might look too small, but when you face it, it would take few hours of your ABAP developer, SAP Basis Admin and SAP Security guy :). Everyone is learning the new tricks of S/4HANA. Although CDS is not a proprietary of HANA (CDS is database independent), but going forward, almost all SAP design architecture would involve CDS. It is high time we started embracing CDS and exploit it to our advantage.

If you have faced any similar issues in your projects, please do share. Your experience might save quite a few quality hours of our development fraternity. After all, learning from others mistake is one of the ways to avoid doing it ourselves.

If you think our page is helpful, do not forget to share our links with your friends, colleagues and team members. Do like our facebook page and follow us at twitter and instagram. Please subscribe to our youtube channel for free end to end video courses.

Your feedback is most welcome. Please, please leave your comments below.

We have a very active Telegram (App) SAP Technical Group with more than 4625+ SAP Technical Practitioners from 6 Continents of the SAP World. Please join it using below link.
Telegram SAP Technical Discuss Group. You need to install the Telegram App first on your mobile device. Once you have it on your mobile, you can join the group and also access it from the Web on your computer and laptop.

Free Step by Step Core Data Services Exercises

Read 248 times

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.