Sunday, 15 January 2017

HANA Analytic View



Analytic View Introduction

Analytic View is in the form of Star schema, wherein we join one Fact table to multiple Dimension tables. Analytic views use real power of SAP HANA to perform complex calculations and aggregate functions by joining tables in form of star schema and by executing Star schema queries.

Characteristics of Analytic View

Analytic Views are used to perform complex calculations and Aggregate functions like Sum, Count, Min, Max, Etc.
Analytic Views are designed to run Start schema queries.
Each Analytic View has one Fact table surrounded by multiple dimension tables. Fact table contains primary key for each Dim table and measures.
Analytic Views are similar to Info Objects and Info sets of SAP BW.

Creating Analytic View
  1. Go to your Package Right click--> New--> Analytic View
  2. Give the Name and Description of Analytic View
  3. Next screen will show Data foundation and star join. In data foundation you will give the Fact table and in star join you will put dimension means Attribute view
  4. Now in data foundation add the fact table and select the column which is required. after selection the fields you can see them in right side column folder
     
  5. Now add attribute view in Star join field like for the below case we are adding 3 attribute view AT_CUSTOMER, AT_PRODUCTS, AT_TIME
  6.  Now make the join between fact table and Attribute view
  7.  Now run the view and check the output



    For more information please mail me at Sandeepcg1989@gmail.com

Saturday, 14 January 2017

Trigger in SAP HANA

Introduction

Triggers are stored programs, which are automatically executed or fired when some events occur. Triggers are, in fact, written to be executed in response to any of the following events −
1- A database manipulation (DML) statement (DELETE, INSERT, or UPDATE).2- A database definition (DDL) statement (CREATE, ALTER, or DROP).3- A database operation (SERVERERROR, LOGON, LOGOFF, STARTUP, or SHUTDOWN).

Triggers could be defined on the table, view, schema, or database with which the event is associated.


Creating Trigger-

Before creating Trigger i am taking one example suppose we have one table "DIMCUSTOMER" and we want that when anyone is inserting any value into this table at that time user name date and system date is stored means who have inserted and when.






Create a table which will store the user name and time who have inserted data in "DIMCUSTOMER" table.
Right click-->New Tabletable name "STSAUDIT" with 2 fields







Now open sql Editor and paste the below code





Code Explanation
create trigger STS.STSTRIGGER --> will create a trigger
after insert on "STS".DIMCUSTOMER" for each row --> means each insert of row in the table "STS".DIMCUSTOMER"

begin --> start of trigger
INSERT INTO "STS"."STSAUDIT" VALUES(
CURRENT_TIMESTSMP, CURRENT_USER
) ;above line means insert current time and user name into the table "STS"."STSAUDIT"

end --> end of trigger
After executing above code you can see one Trigger is created into trigger folder



Now open the table "STS"."STSAUDIT" and check timestamp and user name is inserted or not








Friday, 13 January 2017

HANA Procedure :SAP HANA Procedure in 10 minutes



Introduction


Suppose we have a table with 5 column and we want to change NETWR (Net Sales) from Dollar to Euro For this scenario we will write procedure.



Creating Procedure in SAP HANA

  1. Click on your Package Right Click--> New-->Procedure
  2. Give the name of Procedure and Description of Procedure
  3. After this one more folder Procedure will create inside your package and a sample BEGIN and END code will be Generated. You have to write your Logic here.
  4. Write the code in between BEGIN and END and in the select statement
    VBELN – Column name
    ERDAT  - Column name
    KUNNAR- column name
    NETWR- column name(Net revenue)
    round(NETWR/1.240) as Euro – round value of column NETWR and column will show as Euro
  5. Check and Activate after that one procedure will be created in your package
     
  6. After Activation one procedure will be created inside SYS_BIC Schema.
  7. For calling the schema write SCHEMA schema Name
  8. last Step is Run and check the output.






    For more information send me mail on sandeepcts1989@gmail.com



Thursday, 12 January 2017

HANA Attribute View


Introduction

Attribute Views are typically created for maintaining Master Data (Data which is not changing frequently Ex- employee Address or employee phone number etc ) in HANA system or we can also call it as a dimension in star schema modelling. It doesn’t store the data physically, however fetches the data from source in runtime whenever we execute this object in our system.



Creating Attribute View