With SAP Netweaver Gateway SP04 HANA Database data can be accessible from Gateway system. And I started to search for a document for this. I accessed a SAP Help url but it is very short. (Document Link). But there are some limitations for SAP HANA. You can read them from this link.
First install HANA client on your Gateway Server:
Unix(Logon with root):
hdbinst -a client -p /usr/sap/<SID>/hdbclient -s <SID>
Windows(Logon with SIDadm):
hdbinst -a client -p <lw>:\usr\sap\<SID>\hdbclient
Create a new db entry in DBCON table. To achieve this enter transaction code DBCO.
Now we can create Model Class. Go to transaction SE24. Create a new class. And define Superclass. Superclass is: "/IWHDB/CL_HAI_RT_ABS_MODEL"
Now redefine GET_HDB_ARTIFACTS method and write code. Dont forget to change code with your catalog name and view name.
data: lr_view_assgmnt type ref to /iwhdb/s_hai_rt_view_assgmnt. rt_views = super->get_hdb_artifacts( ). append initial line to rt_views reference into lr_view_assgmnt. lr_view_assgmnt->catalog_name = 'demo'. lr_view_assgmnt->view_name = 'AT_SALES'.
Save and activate your class.
Go to transaction SPRO. Click SAP Reference IMG button. Go to SAP Netweaver -> Gateway Service Enablement -> Backend OData Channel -> Service Development for Backend OData Channel. And click "Execute" button near Maintain Models.
Enter your Technical Model Name and Model Version your models and click create. In the next screen enter your class name above created.
Save your work. And enter IMG Activity Maintain Services. In this screen enter your Technical Service Name and Service Version and click Create button. In Data Provider Class input field enter "/IWHDB/CL_HAI_RT_DATA". Save your service and click Assign Model. Choose you created below Technical Model and save again.
Now we need to create a BAdl Class. We need to do this because system does not know which dbcon entry to use. I dont write how to create a BAdl because I think you know it. In implementing class we implement "/IWBEP/IF_DESTIN_FINDER_BADI~GET_DB_CONNECTION" method. In this method we tell system which DBCON table entry to use. You can check name above. And if you have one more HANA systems you can write own logic to select system.
rv_db_connection = 'AWSHANA' .
Now we will register a service and use it. Go to transaction /IWFND/MAINT_SERVICE (I dont like Gateway transaction codes!). Add a new service.
Choose your service before you created. Enter your Technical Model Name and Technical Service Name. Enter package name $TMP. If you want you change package name.
And if everything is ok we can test your service.
And yes! We got data from SAP HANA!