Inspired by http://ftse.richardallen.co.uk/ I thought it by interesting to use Google Spreadsheet & Google Finance Functions to publish a JSON feed of the latest share prices (or at least withing 20 minutes) which can be loaded into HANA using SAPUI5 & ODATA CRUD.
The Refresh button reads the latest information from Google spreadsheet.
The Save button writes it to HANA.
Here is a link to the complete Project/Package I created (FTSE_SIMPLE.rar):
https://drive.google.com/file/d/0Bxydpie8Km_fb3NBSUh5Z1Q2OVU/edit?usp=sharing
Please feel free to try and load and run in your own HANA environment.
To Create the JSON Feed:
---------------------------------
1) Create a spreadhseet in Google Drive
https://docs.google.com/spreadsheet/ccc?key=0Ahydpie8Km_fdFRwajhOWTRsNGUtMWZROXF5a1pLN3c&usp=sharing
2) Use Google Finance Functions to get the latest share prices (within 20 minutes)
Example Cell(F2) Formula for Current Price:
=GoogleFinance(E2,"price")
Example Cell(F2) Formula for Day Change:
=GoogleFinance(E2,"change")
3) Publish The Google Spreadsheet to the Web
The following JSON link can then be used.
All the code is provided in the earlier link and there is now plenty of training videos on HANA XS development so I won't bore you with the details of creating a table, role, SAPUI5 view etc
However the key integration points within the HANA XS Javascript code are:
--------------------------------------------------------------------------------------------
1) Create a FTSE_functions.js which reads the JSON link, and re-formats it a bit to enable it to be linked to SAPUI5 Table
see getFTSE(dataStocks) function.
2) Created and ODATA service with custom create procedure for saving
Note: I didn't strictly need the create procedure to use ODATA to create records into table 'FTSE_LATEST', but wanted to have flexibility to add custom validations and additional logic.
3) Used the Model.create statement to write individual entries back to HANA table using ODATA Create, rather than an Insert statement.
The benefit of using ODATA Create is that all the save operations can be encapsulated, and controlled, rather than using direct SQL inserts statements.
It can't be used for insert large volumes of record (e.g. as you may find with real-time stock market feeds from Rueters or Bloomberg) however in this example it's fine.
While this example has been interesting, in practice I wouldn't want to click 'Refresh' and 'Save' all the time if I wanted to start tracking Stock market changes over time.
What I need to do now is schedule some of the operations to run.
I could of course use:
-BODS
-BW on HANA Batch scheduling
-Server scheduled tasks
But my next plan though is to use HADOOP Oozie to schedule the loads into HANA.
Why not crack an egg with a sledge hammer, it's definitely more fun.