Wednesday, 20 January 2016

Taking ABAP - ABAPer(s) to HANA Platform - V1.0



C:\Users\Partha\Desktop\HANA\SAPHANA.png


In our earlier post you have learned about the HANA concept (in-memory ram, multi core processor, columnar storage, data compression, massive parallel processing).
If you have not visited our earlier post, please go through once from the below link.


Now it's clear that HANA is not only database, it's a platform, combination of advanced hardware and innovative software.
So, as an ABAPer is there anything new?
Yes.
If we can take any of our developed programs, we can see there are database table select to fetch data based on our requirements and then we do loop, all the required calculations, filtering of data based on conditions, populating final internal tables etc.
That means after simple database tables hits from database server we are pulling data into application server to process and get our required output/results.
In this way we may pulling, keeping, processing with unwanted data which may overload the database hit, extra pulling cost from database to application server and overburden the application server with unnecessary data processing.
Now, as the HANA brings total database in in-memory (very near to application server or we can say inside the application server), so now why we will hit database tables as we did earlier only to fetch data and do all the complex processing in application server, rather we can do all the data processing/calculation/populations while doing the database query/operations.
Image Source: SAP HANA – HA100
If we want to follow in the above concept then I'm sure you will be agree with me that our database query should be robust enough to avoid the application server logics overhead.
If your answer is yes then only I will go ahead :)
I'm sure you understood it properly and your answer is YES.


So what is the big deal now for an ABAPer.
ABAPer need to more concentrate on the database query rather than the application server custom logics.


As of now we are writing database query in open SQL.
After HANA came into picture we have started writing native SQL.


Now one of my friends raises his hand and asked hey Partha, what is this native/open SQL?
I know you don't require this kind of education now but still I'll explain for my friends who are unaware of this like my previous friend.


Open SQL:
SAP is supporting this open SQL to make query to any kind of database (oracle, DB2) that means it is independent of database provider and open to all.
Basically SAP has its own dictionary objects that are also independent of any kind of database and Open SQL works on that dictionary objects. After that the query goes to the specific database through the database interface that SAP have in the format of Native SQL.
You can also easily identify the Native SQL if you try to see any database query/Open SQL in SQL trace from ST05.


Native SQL:
As the name itself says that the query language is native to specific database. So when we will be using HANA as a primary database then we need to write our database query in Native SQL, the same way the SAP database interfaces is converting our open SQL into native SQL while going from dictionary query to database specific query.


HANA Evaluation:
Image source: SAP HANA – HA400
Obviously your company, who are already running their business in SAP, will not go and migrate to HANA overnight. As they already having their existing database to do business and after knowing the HANA's robust features, they are trying to replace their existing database systems by bringing HANA as secondary database and looking for permanent replaced the information near future.
So now your company have HANA as secondary database.


Transaction DBACOCKPIT:
Image source: SAP HANA – HA400


Now as an ABAPer one question would definitely come in our mind.
We have already written tones of code, so will all our code be replaced now if we want to use HANA as secondary database?
Definitely not!
Still we can keep our old code, written in open SQL query with little modifications like below.
Here SAP has come up with one new keyword 'CONNECTION', which will basically bypass our database query from traditional database to HANA database.


Open SQL using secondary database connection:
Image source: SAP HANA – HA400
Sometimes we are using HANA as secondary database with 'CONNECTION' when we need secondary index in our traditional database tables and to avoid the additional overhead of secondary indexes we are approaching to HANA database which doesn't bother about indexes as it is column storage and all the fields behaves as primary key.


But we have some restrictions as well if we only using HANA as secondary database. Which are as below.
Image source: SAP HANA – HA400


So we need to gradually move towards the HANA as primary database.
Primary database means, as I have already discussed as an ABAPer we need to move into Native SQL.
Image source: SAP HANA – HA400




Open SQL Syntax and Native SQL Syntax:
Image source: SAP HANA – HA400


Join in OPEN and Native SQL:
Image source: SAP HANA – HA400


How we can connect to HANA when we are using as primary database?
The answer is ADBC.
So let's have some idea about ADBC as well in this platform.
Image source: SAP HANA – HA400


Sequence for Reading Data with ADBC:
Image source: SAP HANA – HA400


Coding Example: ABAP Database Connectivity (ADBC):
Image source: SAP HANA – HA400


ADBC: Important things to keep in mind:


Gradually we will learn about Schema,  SQL Script, Procedures
Different views - attribute view, analytical view, calculation view and lot...


After reading the post you would definitely gain some interest to begin with HANA code.
But you have not HANA server to play around!! ☹
Don’t worry buddy! ☺
You can access HANA cloud platform for free. My dear friend Raju explained it in absolutely easy way.
Please go through the below link and grab it.


Stay tuned and be with us!




Friday, 1 January 2016

SAP HANA for beginners

E:\Backup\mysapbook\HANA\powered-by-SAP-HANA.jpg

Friends, remember the days when we had only 128 MB of RAM in our computer in early 20’s. The gals/guys who started using computer recently or 5-6 years back, they can’t even believe the same as they started using computers having minimum 1-2 GB RAM.
Here all I meant is about SPEED.
We know time is money!

SAP comes up with a very effective and efficient database called HANA which makes revolution in database world.
Now a days, when every organization is having a huge volume of data causing slowdown of  all the database operations, SAP introduces the HANA database which makes any database operation very fast which is well desired for any kind of organization.

Now let’s dig into the so called HANA (High-performance ANalytic Appliance).
SAP HANA manages massive data volume at high speeds.
HANA is combination of both advanced hardware and innovative software.
Hardware In-Memory RAM
Software   Column-Oriented RDBMS.

SAP HANA is written in C, C++.

E:\Backup\mysapbook\HANA\HANA_basic_architechture.png

Data resides in separate database server (Database on Dick) need additional load (120MB/s) while pulling (select) data to application server or manipulate (update/insert) data to DB server.

In the right hand side of the above image we can easily understood that pulling data to SAP application or manipulate data into DB is super-fast (100 GB/s).

The super-fast database access is possible because the total database stored in RAM (memory).

We know RAM is volatile memory, so your next question would be…
You: will all the data be lost if there is any disruption in system like power cut off!!!
SAP: NO!

SAP came up with two more things to manage the data.
  1. Log area (Disk).
  2. Data area (Disk).

All the current data stored in In-Memory database (RAM) and for each database-commit it will go into Log area. And if there will be power failure after the database commit, all the committed data will be synced into database from the Log area. That means Log area will hold only the current data. Please check the below image.
SAP HANA Recovery
All the current data (In-Memory DB) will be synced into Data area (Disk) after a certain interval (SAVEPOINT), by default it configured for 300 Sec (5 mins) in system but we can alter the savepoint as per our requirement.

So your most valuable data will not be lost in anyway and it's totally safe to upgrade your database into HANA and gear up your business. Cheers!

Q: Is it only all about the database that goes into RAM?
Ans: No.

As I have already mentioned that HANA is based on advanced hardware and innovative software.

HANA advanced Hardware that I have already tried to make you understood about In-memory (RAM) cache database.

Another side of the HANA’s advanced Hardware innovation is multi-core architecture
CPU (8 X 15 cores per blade) which enables massive parallel processing resulting high speed in database operation.

E:\Backup\mysapbook\HANA\HW_SW_1.png

Now let me try to explain HANA’s innovative software part.

Let’s take an example of a table that contains sales data like below.


ROW based stored table



Column based stored table










SO No
Country
Product
Total sales


SO No
Country
Product
Total sales
1
INDIA
Coca-Cola
100


1
INDIA
Coca-Cola
100
2
USA
Sprite
130


2
INDIA
Sprite
120
3
CHINA
Mazza
110


3
USA
Sprite
130
4
INDIA
Sprite
120


4
CHINA
Mazza
110
5
GERMAN
Beer
90


5
GERMAN
Beer
90


Primary index
=
Sorted

So, here we can see when table stored in columnar based then  all the table fields behaves as primary key and as a result all the fields value comes in sorted basis.
(No need to create secondary index while querying data with non-key field).

Advantages in columnar stored table (HANA) over row stored table:

SELECT *
FROM TAB_SALES
INTO IT_SALES
WHERE COUNTRY = ‘INDIA’.

C:\Users\Partha\Desktop\HANA\img_1.jpg

As you can see from the above mysapbook image,
The country field value (INDIA) is being searched all over the table as it is not a primary key for the row based stored table.
But when the same search happens in HANA table (columnar based stored), as all the fields treated here as primary key and all are sorted, the search algorithm will begin only on country field and came out of search while there will be mismatch of the field value.

Please note: SAP HANA supports row oriented storage as well. So SAP HANA has given the flexibility to switch between column and row oriented storage.

The basic concept is when we need any analytical view (select data from DB) then we will go for columnar based and when we need DB update/insert then we can go for row based stored table. We will dig into it in more details.

Data Compression in HANA:

C:\Users\Partha\Desktop\HANA\img_2.jpg

The columnar stored table is always stored in compressed format for the identical column (field) values.
But multiple rows cannot be identical to grasp the same functionality.
So, the total database storage would be less for HANA compared to other database.

HANA based DB is for Faster Aggregation / Any other arithmetic operations:
C:\Users\Partha\Desktop\HANA\img_3.jpg

HANA’s columnar based storage characteristics makes all the database level arithmetic operation very fast compared to row stored table.

Parallel processing in HANA:

C:\Users\Partha\Desktop\HANA\img_4.jpg

In a column store, data is already vertically partitioned. This means that operations on different columns can easily be processed in parallel. If multiple columns need to be searched or aggregated, each of these operations can be assigned to a different processor core

In-Memory operations for HANA:

C:\Users\Partha\Desktop\HANA\img_5.jpg

Other database:
  1. Huge data volume in all over the process.
  2. Unnecessary Data load in application layer.

In-Memory database:
  1. No data load as we are doing all the operation (filtrations and all arithmetic operations) in DB level and carrying only the required data into application layer.
  2. DB is also synced in memory cache so it will not overload the data.

FYI…
  • HANA started with 1 TB RAM and now it’s successfully tested with 200 TB RAM.
So how big your business/database, it’s doesn’t matter to HANA at all. HANA can accommodate all your data in in-memory database.

  • Latest SAP HANA version is SPS 11 (Support Package Stack 11 (Last Update: November 25, 2015, Revision 110))

Please let me know if you liked the page. Feel free to put your valuable comments for any kind of suggestions or if you want more discussion on SAP HANA basics.

Thank you!
Happy New Year!