Wednesday 20 September 2017

SAP HANA: Attribute Views

·         Attribute view acts like a dimension.It joins multiple tables and acts as Master.
·         Attribute views are built specifically for master data.
·         There is no measure and aggregation option.
·         Attribute view is reusable objects.
·         Their primary purpose was to maintain a reusable pool of master data which could then be combined with transaction data in Calculation views or Analytical views
·         It doesn’t store the data physically, however, fetches the data from a source in runtime whenever we execute this object in our system.

Creation of Attribute view:

Step 1: Create Package by right click the Content and select New and select Package
Step 2: Then we get a package creation Pop-up screen where we are required to enter its Technical name, Description, Delivery unit, Language, and Person responsible.

Click ‘OK’ after entering the details. We should then be able to see a package with the same name under our content folder. Here, I named it as “KABIL_HC”.


Step 3: Create Attribute View by right click the package “KABIL_HC” and select New and select Attribute View.
In the below screen we have to enter the details for our Attribute View, like Technical Name, Description(Label) and Type of object (Subtype). We can create three types of Attribute Views, they are
1.      Standard
2.      Time
3.      Derived
Standard: This is normal attribute view which is defined on one or multiple source tables that has already sourced in HANA.
Time: If we need to create time dimension based on time/date tables that we have in our HANA system under _SYS_BI schema, then we can choose this.
The tables are M_TIME_DIMENSION and M_FISCAL_CALENDAR.
Derived: If we want to derive a view from an existing attribute view then we need to choose this. The only editable in this type is the description of the new Attribute View.
If we want to define an attribute view by using one of our existing objects as a copy, then we can choose ‘Copy From’ option.
Note: The difference between Copy from and Derived is that in case of derived we can only edit the description of the new attribute view, all the remaining changes can only be performed on the base object. In case of Copy From we can modify our copied view entirely.


The below screen opens up. Notice that the semantics is not connected to an Aggregation node here. It is connected to a “Data Foundation”.


A “Data Foundation” is a node which you cannot remove. It is purely used to include tables into the view. You can use a singular table here or have more by specifying the join condition inside this “Data Foundation”.
You cannot insert views into the “Data Foundation”. It only accepts tables.
Step 4: Now Drag and Drop the required tables and select required fields.
Step 5: Now we are going to create a Calculated Column by right click the Calculated column and select New. A Pop-up screen will appear


Here I wrote an expression for Full name “FIRST_NAME”+’ ‘+”LAST_NAME”.
Step 6: Now Drag and Drop the “TH_EMP_MASTER” tables and select required fields.
Step 7: And the make a join link between the table with the relationship. In default, the join will be the referential join. In a property, opening up the JOIN type setting provides a list of available options. Switch it to LEFT OUTER JOIN (you can choose any type which is required for you).
Step 8: Finally, Save and activate this view. Now execute a data preview to check the data. As seen below, the JOIN is successful and data appears as required.
Result:

Thank you for visiting...
Share your comments...

4 comments:

  1. "Hi Venkat,
    This is one awesome blog. Much thanks again. Fantastic.

    I am trying to send an email from HANA XSJS,just like an notifications. I am using the gmail id's to send and receive the email. also set the HTTP dest file and added necessary configurations in the XS admin tool. still i am getting the same error like below:
    HttpClient.request: request failed: internal error occurred ""Failed to send request to socket...rc = -1""
    Please help me to solve this. Thanks much in advance
    Regards,
    Kevin Lee"

    ReplyDelete
  2. Hi There,

    Thank you SO MUCH! I was actually holding my breath as I followed these directions. It worked beautifully!

    I sort of understand why I get an error message, but I am unable to solve it.
    Here's what I have done. And I'd like to see resuts even if they are negative. We also have quantity on invoices which are negative.
    Any takers on heping me?
    SAP B1 HANA
    *Edit: full error message:
    1). [SAP AG][LIBODBCHDB32 DLL][HDBODBC32] General error;304 division by zero undefined: search table error: [6859] AttributeEngine: divide by zero;decfloat comma '' (SWEI) (fixed12_16.6 sqlsub(fixed12_16.6 "SEPTON.INV1.Price", fixed12_16.6 "SEPTON.INV1
    SELECT T0."CardCode", T0."CardName", T0."DocNum", T1."ItemCode", T1."Dscription", T1."Quantity", T1."LineTotal", T1."StockPrice", SUM(T1."Price"-T1."StockPrice")*T1."Quantity" AS "Bruttovinst", SUM((T1."Price"-T1."StockPrice")*T1."Quantity"/T1."LineTotal")*100 AS "Bruttovinst", T3."Price", T3."Currency"

    FROM OINV T0

    INNER JOIN INV1 T1 ON T0."DocEntry" = T1."DocEntry"

    INNER JOIN OITM T2 ON T1."ItemCode" = T2."ItemCode"

    INNER JOIN ITM1 T3 ON T2."ItemCode" = T3."ItemCode"

    INNER JOIN OPLN T4 ON T3."PriceList" = T4."ListNum"

    WHERE T0."DocDate" >=[%0] AND T0."DocDate" <=[%1] AND T3."PriceList" ='1' AND T1."LineStatus" = 'O'

    GROUP BY T0."CardCode", T0."CardName", T0."DocNum", T1."ItemCode", T1."Dscription", T1."Quantity", T1."LineTotal", T1."StockPrice", T3."Price", T3."Currency"

    By the way do you have any YouTube videos, would love to watch it. I would like to connect you on LinkedIn, great to have experts like you in my connection (In case, if you don’t have any issues).


    Please keep providing such valuable information.


    Many Thanks,
    Irene Hynes

    ReplyDelete
    Replies
    1. Hi Irene Hynes,

      your Code:
      WHERE T0."DocDate" >=[%0] AND T0."DocDate" <=[%1] AND T3."PriceList" ='1' AND T1."LineStatus" = 'O'

      I just want to know what your exactly expecting... from the above code "T0."DocDate" >=[%0]" it seems to be problem..

      To solve it, i want to know what is the data type of "DocDate" column and how data resides on it ( i.e format of data)
      for example: if the data is "01052018" i.e., ddmmyyyy.

      And if you want to get results sets between those dates which you mentioned in your code means u may give full date...

      but from your code what i understand means your using wildcard characters "%" . you cant use these with comparative operators.
      It should be like as T0."DocDate" like '%0...

      contact me through mail: kabilsapworld@gmail.com

      Delete
  3. Hi There,

    Thank you SO MUCH! I was actually holding my breath as I followed these directions. It worked beautifully!

    We use BW datasources to extract data from ECC system.
    But BW system will be stopped and using HANA system instead.
    Instead of extracting data from ECC with SLT and remodeling in HANA with complex business logic again
    SAP HANA Training , is there other way in HANA to extract data from ECC like BW datasources without BW system ?

    Excellent tutorials - very easy to understand with all the details. I hope you will continue to provide more such tutorials.
    Muchas Gracias,
    Preethi

    ReplyDelete