Skip to Content
Author's profile photo Former Member

Expose Attribute Views as XS OData Service in HANA

1. You need to change the Eclipse IDE perspective to SAP HANA Development. Navigate toWindow → Open Perspective → Other to change the perspective of your HANA Studio to SAP HANA Development   (OR)   Select the SAP HANA Development perspective in the perspective shortcut which is at the top right corner of your SAP HANA Studio.


/wp-content/uploads/2016/08/1_1008152.png

2. In the Open Perspective window, select SAP HANA Development Perspective and hit OK.

/wp-content/uploads/2016/08/2_1008153.png

3. In the left section, you will see three new tabs Project Explorer, Repositories and Systems.Select Repositories tab.

4. Right click to create a new repository workspace for the HANA System you have already logged in.

/wp-content/uploads/2016/08/3_1008154.png

5. In the Create New Repository Workspace window, select the HANA system for which you want to create workspace, enter Workspace name and hit Finish.

/wp-content/uploads/2016/08/4_1008164.png

6. Your new workspace will be created

/wp-content/uploads/2016/08/5_1008165.png

7. Expand the created workspace and identify your repository package , right click on it and chooseCheck Out.

Tip : Checked out package will have tick mark like thisCheck_Out

/wp-content/uploads/2016/08/6_1008166.png

8. After checking out, select your package and press Cntrl+N (or) Right click → New → Other.

9. In the New window search with XS OData and select XS OData FileXS_OData_Fileand hit Next.

/wp-content/uploads/2016/08/7_1008173.png

10. In the New XS OData Service window, enter File name, choose Template as “Basic” and hit Finish.


/wp-content/uploads/2016/08/8_1008175.png

11. A new HANA XS OData service will be created with predefined syntax like below.

/wp-content/uploads/2016/08/9_1008180.png

12. We are not going to use the predefined syntax as it, remove that and copy and paste the below code

12.PNG

13. Lets see what the HANA XS OData service file contains

  1. Service definition starts with syntax – service {  }.
  2. you have to provide the full path of attribute view where it is stored and its name.
  3. as  –  you have to provide the Entity Type name.
  4. with – columns of attribute view you want to expose.
  5. key – key of the attribute view.

14. Activate the service by clicking on Active Button Activateon the tool bar.  You can also right click on the package and choose Activate / Activate All.

/wp-content/uploads/2016/08/14_1008186.png

15. Before testing the service we need to first expose our package to do so we need to create two files in our package they are .xsaccess and .xsapp. Right click on your package → New → File

/wp-content/uploads/2016/08/15_1008188.png

16. Copy and paste below code into newly created .xsaccess file.

16.PNG

17. Again repeat the Step-17 to create .xsapp file. This file will be a blank file.

18. Activate all objects in the package. Now we are ready for testing.HANA XS OData services are accessed by URL.Open your chrome browser and enter URL of your XS OData service in the below format.

http://hostname:port/package/file.xsodata

18. You will see the XS OData service metadata output like below in the browser.

/wp-content/uploads/2016/08/18_1008197.png

19. Now append the entity name “EmployeeCollection” to the above URL and you will see the data of the attribute view like below.

URL –http://saplearners.com:8005/demopackage/services/EmployeeInfo.xsodata/EmployeeCollection

/wp-content/uploads/2016/08/19_1008198.png

20. We you have successfully exposed HANA attribute view as XS OData service.Now we can use this XS OData service in SAPUI5/SAP Fiori applications to display the data in UI.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo SAKRIYANAIK NK
      SAKRIYANAIK NK

      Excellent blog - the same odata services can also consumed in SAP Cloud API management and SAP Cloud CPI - via SAP Cloud connector  and will be used for integrating with External cloud applications.

      This saves lot of time and money for the customers!!