One more thing, and we’re ready to roll…go to your AWS Management Console, EC2 and then choose Security Groups. Our R server is going to be assign to “Quicklaunch-1”. Just select it and go to Inbound. And add the port “6311”.

That’s all folks…we’re officially ready to go! On SAP HANA, create a table and call it TICKETS_BY_YEAR with the following structure:

Open a SQL Editor and copy the following code…

insert into "SYSTEM"."TICKETS_BY_YEAR" values('20110101',4195);insert into "SYSTEM"."TICKETS_BY_YEAR" values('20110201',4245);insert into "SYSTEM"."TICKETS_BY_YEAR" values('20110301',4971);insert into "SYSTEM"."TICKETS_BY_YEAR" values('20110401',4469);insert into "SYSTEM"."TICKETS_BY_YEAR" values('20110501',4257);insert into "SYSTEM"."TICKETS_BY_YEAR" values('20110601',4973);insert into "SYSTEM"."TICKETS_BY_YEAR" values('20110701',4470);insert into "SYSTEM"."TICKETS_BY_YEAR" values('20110801',4981);insert into "SYSTEM"."TICKETS_BY_YEAR" values('20110901',4530);insert into "SYSTEM"."TICKETS_BY_YEAR" values('20111001',4167);insert into "SYSTEM"."TICKETS_BY_YEAR" values('20111101',4059);insert into "SYSTEM"."TICKETS_BY_YEAR" values('20111201',1483);

This table is supposed to hold the tickets sales for a given company, during each month of the year 2011. What we want to do here is to determine or predict how are going to our sales on 2012. We’re going to use #R for that matter. Create the following script and call it “Predict_Tickets”. This script will have two Stored Procedures, called Prediction_Model and Get_Tickets.

As you can see, our first Stored Procedure called Prediction_Model, we’re using RLANG as the script language…meaning that we’re going to embed R code that will go from our SAP HANA to our R Serve and back with the modified information. Prediction_Model is calling the Stored Procedure Get_Tickets, which is doing a select from the table TICKETS_BY_YEAR and then calling Prediction_Model to finally insert the data back into SAP HANA. At the end of our script, we call Get_Tickets and do a select to TICKETS_BY_YEAR to verify that our script worked.

Success! Our SAP HANA and R integration work like a charm! We never left SAP HANA Studio, but our code went to the R Server and back to bring us the modified information…all in just 829 milliseconds…really fast considering that both servers are in the cloud… That’s all for now…I will come back with more information on SAP HANA and R as soon as I can…there’s still a lot to discover and test.