Skip to Content
Author's profile photo shivam shukla

R integration with SAP HANA

Hi –  Just thought to share about my new passion about “R” , I would like to share my newly experience with R (using R Studio) and its integration with SAP HANA , for the beginners it would be really helpful to follow the below steps and a smooth integration with R studio , enjoy accessing HANA artifacts easily like accessing the tables/view information & Consuming procedures , intention is let the people know the integration & want to share more later on this topic once I am friendly in “R” development fashion –  “still in learning mode” J.

Here are the prerequisites you must have before trying your hands on “R”



R-ODBC Package

R Studio

Setup the Data source (in this case SAP HANA DB Server)

Go to Service Marketplace -> Software Downloads -> Support Packages and Patches -> A-Z –> H–> SAP HANA PLATFORM EDITION” –> SAP HANA PLATFORM EDIT. 1.0” –> Entry by Component” –> HANA client

Another step by step procedure to Download the SAP HANA Client –

Once you have installed HANADBClient in your system then you need to setup data source.

Go to -> Control Panel -> Search for data Source (ODBC) -> Set up data sources (ODBC)

You will get the below popup


On Current tab click on Add one popup will appear for Server/Port information

Enter any data source name/any description for server ad then enter server:port –  if you don’t know the server and port name goto your hana studio (SAP HANA Development perspective) and right click on system then click on properties tab -> Additional properties tab -> Host details. After entering these details click on connect to check if the details are correct or not by entering the username/password if all ok then you get a prompt on connect that connection is successful.


Once you are done with above now download the R Studio ( ) and R package ( )

Now install both the Components once you are done with R Studio installation download the RODBC package ( )  goto your R Studio now & all install r Studio package.

Once we have added the RODBC package now we can check on R studio using library function

Now we can go ahead for accessing our HANA database artifacts, establish the database connection using R commands & then execute sqlQuery function for executing sql commands on R.



I created one table in HANA server for billing docs that I am accessing using “R” below is the sample code.

library (‘RODBC’)

ch<-odbcConnect(“data source name”,uid=”test_hana”,pwd=”test12″);

sqlQuery(ch, ‘SELECT * FROM “_SYS_BIC”.”BILLING_DATA” ‘)

result ->

Here is the output from “R”

Another sample for consuming procedure in “R”

I created on procedure which returns Company Code , Accounting doc & fiscal year from BSEG .

sqlQuery(ch, ‘CALL “ABAPDEMO”.”GETDATA”(10 , ? )’);


Output in “R”


Your suggestions/questions/improvements are most welcome, I will try to share more sample codes as I will move on.


Thank you!

















Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Very exciting post! I've only just started dabbling with R but already very impressed with its power and flexibility, can't wait to combine it with HAN. Thanks for sharing

      - Jesse

      Author's profile photo Shady Shen
      Shady Shen

      Nice ~

      Do you know how to save data to HANA column store using sqlSave / or whatever R function?

      Besides, my test with sqlSave is having issue with unicode characters, do you know how to deal with code page setting with R and HANA?


      Thanks in advance,


      Author's profile photo Lars Breddemann
      Lars Breddemann

      Have a look at

      sqlSave doesn't seem to be very clever when storing data, so creating the target table upfront is a good idea.