Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
kumarsanjeev
Explorer
PUBLISHING CDS View to the Outer World over internet with OData Service and consume via FIORI app.

It is very easy to publish a CDS view with OData Service.  To do it we just have to use one annotation ‘@OData.publish: true’ which will further create an OData Service and we must register it within SAP system via GUI interface.  Once registered, CDS view is ready to be consumed in any application within or outside SAP environment.  We will look at how we can consume it in a simple Master-Details CDS view app.

 

Let’s create a new view with tables ‘VBAK – Sales Header’ and VBAP – Sales Items’. We will use the concept of ‘Association’ again.



 

Create the CDS view as below and activate. You can choose any tables of your choice.



  • Now add the OData annotation and activate again




  • Hover over the mouse pointer on the yellow icon showed up in front of @OData annotation. It will show the service name which gets created and indicates that service is not yet active. Copy the service name to register and activate.  This is a mandatory one-time activity we need to perform so that our CDS view can be published with OData.  Notice that the service name generated by the system is almost like your CDS view name with _CDS




  • Login to SAP GUI interface to register the service. You can hot CTRL+6 to login within ADT or login separately via SAP Logon pad.

    • Goto tcode /n/IWFND/MAINT_SERVICE and clock ‘Add Service’ button.






 

  • Choose ‘LOCAL’ as System Alias and pass the service name we copied from CDS view to ‘External Service Name’. Hit Enter.  Select the Service and click ‘Add Selected Services’.




  • Now pass the ‘package’ to transport OR select ‘Local’ if no transport is required. Hit ‘Continue’;


 



  • Service is now created.




->To check if Service is registered, Go back screen and filter it.





->Select the Service and click on Call Browser;



->A browser window will open and you have to enter your SAP credentials( uname/pwd ).  You can see the service code.  Note the CDS View/Entity name and the Asslciation Table name ‘VBAP’ also appears.

-> To check if OData service returns the data, copy the CDS view name and add it to the link in the browser.

FROM:



 

 

TO:



 

 

Note that the data displayed is only from table VBAK – Sales Header.  NO Join is yet performed and NO data from table VBAP – Sales Item is displayed yet.  Check the highlighted link in blue, this is the link to the table VBAP to display data On-Demand as we have applied the concept of ‘ASSOCIATIONS’ within the CDS view.  Copy and paste this link in the browser window by replacing it with the CDS view name as below;

-Replace <IP address> with you IP in below URLs

From:http://ec2-<IP address>.compute-1.amazonaws.com:8080/sap/opu/odata/sap/ZCDS_ODATA_VIEW_CDS/ZCDS_ODATA_VIEW

 

To:

http://ec2-<IP address>.compute-1.amazonaws.com:8080/sap/opu/odata/sap/ZCDS_ODATA_VIEW_CDS/ZCDS_ODATA_VIEW('200000013')/to_sitem

Check that the data from Sales Item table VBAP is now displayed;



 

  • CDS view and OData Service is now ready and next we will plug this in to a FIORI app and we need to do a little configuration via SAP Web IDE. SAP Web IDE personal edition is free from SAP, you can download from here: https://tools.hana.ondemand.com/#sapui5 and unzip the file on your machine. It will create an eclipse folder.




  • Launch SAP Web IDE;

    • Go to eclipse folder and double click ‘Orion.exe’ file to start the Web IDE server.

    • Once started, go to web browser and launch : http://localhost:8080/webide/index.html

    • Right click on Workspace->New->Project from Template

    • Click on ‘SAP Fiori Master-Detail Application and hit ‘Next’






 

  • Enter necessary information and hit ‘Next’;




 

  • Choose your S/4 system and system might ask uname/pwd if you are logging in first time. Check that all the OData services are displayed.




 

NOTE:  If your S4 system is not available as you can see above, you have to configure the destination file if you have not done yet.  Follow these steps;

  1. Go to this path in your SAP Web IDE folder;


C:\SAP Web IDE\eclipse\config_master\service.destinations\destinations

  1. Maintain the system file with below config;


Name=S4D

Type=HTTP

Description=S4D - AWS1809

URL=http://<IP address>:8080

ProxyType=Internet

Authentication=NoAuthentication

WebIDEUsage=odata_abap,odata_gen,ui5_execute_abap,dev_abap      

WebIDESystem=S4D

WebIDEEnabled=true

TrustAll=true

sap-client=600



 

  • Next to URL: you can either use IP or the system name. Make sure the port is correct too, it could be different in your system.

  • Make sure this file has no extension. You can check like this:




 

If you see any extension, delete it and save.  So after selecting the S/4 system, you can select the CDS View OData service form the list and take it from here to create Fiori App.

The CDS view now is available to feed the data to the Fiori App.  We will see another end to end example in a separate blog  post to plug CDS into FIORI app.



 

In summary, FIORI is the new web way of working with SAP systems via 'apps'.  All the Operational or Analytical reports will be configured into FIORI screens as apps, to be triggered with a click.  In this blog post, we saw what all we need to integrate a CDS view into FIORI framework and how to resolve issues during integration.

Part# 10. CDS Views – @VDM Annotation: Check the SAP Best Practices for CDS view development

 

Follow for upcoming blog posts: kumarsanjeev

Keep learning..

SK

 

 
1 Comment
Labels in this area