• No results found

Creating Attribute Views

In document hana_dev_en (Page 121-126)

7 Setting Up the Analytic Model

7.2 Creating Views

7.2.3 Creating Attribute Views

Attribute views are used to define joins between tables, and to select a subset (or all) of the table's columns and rows. The rows selected can also be restricted by filters. One application of attribute views is to join multiple tables together when using star schemas, to create a single dimension table. The resultant dimension attribute view can then be joined to a fact table via an analytic view to provide meaning to its data. In this use case, the attribute view adds more columns and also hierarchies as further analysis criteria to the analytic view. In the star schema of the analytic view, the attribute view is shown as a single dimension table (although it might join multiple tables), that can be joined to a fact table. For example, attribute views can be used to join employees to

organizational units which could then be joined to a sales transaction via an analytic view You have imported T009 and T009B tables for creating attribute view of type Time.

Use this procedure to create a view that is used to model descriptive attribute data (that does not contain measures) using attributes.

Tip

You need this view for creating a multidimensional view. 1. Set Parameter

2. Expand the package to which you want to save your information object. 3. In the context menu of Attribute Views node, choose New .

4. Enter a name and description for the view.

5. To create data foundation for the view, perform substeps of the required scenario given in the table below:

Scenario Substeps

Create a view with table attributes.

In the Sub Type dropdown list, choose Standard. Create a view with time

characteristics. 1. In the 2. Select the required calendar type as follows:Sub Type dropdown list, choose Time.

a. If the calendar type is Fiscal, select a variant schema, and a fiscal variant.

b. If the calendar type is Gregorian, select the granularity for the data.

3. To use the system-generated time attribute view, select Auto Create.

Note

The system creates a time attribute view based on the default time tables, and defines the appropriate columns/attributes based on the granularity. It also creates the required filters.

Note

The tables used for time attribute creation with calendar type Gregorian are, M_TIME_DIMENSION, M_TIME_DIMENSION_ YEAR,

M_TIME_DIMENSION_ MONTH, M_TIME_DIMENSION_WEEK and for calendar type Fiscal is M_FISCAL_CALENDAR. If you want to do a data preview for the created attribute view, you need to generate time data into the mentioned tables from the Quick Launch tab page.

Copy a view from an existing view – in this case, you can modify the copied view.

1. Choose Copy From.

2. Select the required attribute view. Derive a view from an

existing view – in this case, you cannot modify the derived view that acts as a reference to the base attribute view.

1. In the Sub Type dropdown, choose Derived. 2. Select the required attribute view.

6. Choose Finish.

The attribute view editor opens. The Scenario panel of the editor consist of two nodes - Data Foundation and

The Semantics node represents the output structure of the view, that is, the dimension. In the Details panel you define the relationship between data sources and output elements.

2. Define Output Structure

a) Add the tables that you want to use in any of the following ways:

○ Drag the required tables present in the Catalog to the Data Foundation node.

○ Select the Data Foundation node in the Scenario panel, and in the context menu of the Details panel, choose Add.

Note

You can choose to add the same table again in Data Foundation using table aliases in the editor. For example, in cases where you want to have different cardinalities from the same table.

Restriction

It is not allowed to add column views to the Data Foundation.

b) If you want to query data from more than one table, in the Details panel context menu, choose Create Join, and enter the required details.

Note

○ After creating the join, you can edit its properties like join type, cardinality, etc in the Properties

view. You can choose to create Text Join between table fields in order to get language-specific data. For example, consider that you have a product table that contains product IDs and no description about products, and you have a text table for products that has a language-specific description for each product. You can create a text join between the two tables to get language- specific details. In a text join, the right table should be the text table and it is mandatory to specify the Language Column.

○ You can set the cardinality of the join as required. By default the cardinality of the join is "empty". The empty cardinality can be specified in cases when you are not sure about the right cardinality. If you specify the empty cardinatily, system during the join evaluation phase diagnose the best suited cardinality and execute the join. Wrong selection of cardinality can lead to erroneous data and out of memory issues.

c) Add the table columns to the output structure that is, the Semantics node that you want to use to define attribute data. You can define the attribute data by doing one of the following:

○ Select the toggle button on the left of the table field. ○ Right-click the table field, and choose Add to Output.

d) If you want to specify a filter condition based on which system must display data for a table field in the output do the following:

1. Right-click the table field, and choose Apply Filter. 2. Select the required operator, and enter filter values.

All the table fields that you have added to the output are automatically mapped as attributes. 3. Define Key Attributes

a) Select the Semantics node.

b) In the Attributes tab page of the Column panel, select the required attribute and select the Type as Key Attribute.

Remember

If there is more than one key attribute, all key attributes of the attribute view must point to the same table in the data foundation. The central table of the attribute view is the one to which all the key attributes point.

Note

In case of auto-generated time attribute views, the attributes and key attributes are automatically assigned.

4. Optional Step: Create Calculated Columns

a) In the Output of Data Foundation panel, right-click Calculated Columns. b) In the context menu, choose New.

c) Enter a name and description (label) for the calculated column. d) Select a data type for the calculated column.

e) Enter length and scale for the calculated coulmn.

f) In the Expression Editor enter the expression. For example, you can write a formula such as,

if("PRODUCT" = 'ABC', "DISCOUNT" * 0.10, "DISCOUNT"). This means if attribute PRODUCT equals the string ‘ABC’ then DISCOUNT equals to DISCOUNT multiplied by 0.10 should be returned. Otherwise the original value of attribute DISCOUNT should be used.

Note

The expression can also be assembled by dragging and dropping the expression elements from the menus below the editor window.

g) Choose OK.

5. Optional Step: To filter and view the table data in the modeled view, which is relevant to a specific client as specified in the table fields, such as, MANDT or CLIENT, at runtime perform the following:

1. Select the Semantics node, in the Properties panel edit the Default Client property.

Note

The default value for the property is the one that is specified as a preference. At runtime, if the property is set to Dynamic then, the value set for the Session Client property is used to filter table data. The Session Client property is set while creating a user.

Note

You can choose to create hierarchies in order to define relationships between attributes.

Note

You can choose to associate an attribute with another attribute, which describes it in detail. For example, when reporting via Label Mapping (also known as Description Mapping), you can associate Region_ID with Region_Text.

Before SP05, you could associate an attribute with another attribute in a model. In the runtime object an <attribute>.description column is generated and is shown during data preview. Now, from SP05 onwards the behavior is as follows:

○ For an attribute (CUSTOMER) you can now maintain label mapping by selecting another attribute (TEXT) from the same model as "Label Column" in the Semantics node. The result is "TEXT" displaying as the label column in data preview. Note that the CUSTOMER.description column is not generated and is not shown in data preview anymore. You can choose to rename a label column as <attribute>.description. For example, if A1 has a label column B1, then you can rename B1 to A1.description but not as B1.description. Once you rename a label column with .description as suffix, the related columns appear side by side during data preview.

○ If you have created an object using the old editor (which supported the old style of description mapping) and try to open it using the new editor you will see a new column CUSTOMER.description (as an attribute) which is hidden and disabled because this column cannot be used in other places such as parameter/variable, calculated column, restricted column and so on. You cannot maintain properties for this attribute for example, description. CUSTOMER.description displays in the data preview as long as you do not change it in the editor. You can change its name. After changing the name you can maintain its properties and use it like other attributes.

You can rename the label column as <attribute>.description. For example, if A1 has a label column A1.description, then you can rename A1.description to B1 and again as A1.description but not as B1.description. Once you rename a label column with .description as suffix, the related columns appear side by side during data preview.

6. Activate the view using one of the following options in the toolbar:

Save and Activate - to activate the current view and redeploy the affected objects if an active version of the affected object exists. Otherwise only current view gets activated.

Save and Activate All - to activate the current view along with the required and affected objects.

Note

You can also activate the current view by selecting the view in the Navigator view and choosing Activate in the context menu.

You can find the activated model in the related package. If you want to modify this model, from the context menu, choose Open and make the necessary changes.

Restriction

The behavior of attribute views with the new editor is as follows:

● When an object (a table of an attribute view) is removed and added again in an attribute view in order to reflect the recently modified columns with its data type, it reflects the previous state of the columns alone. For more information, see SAP Note 1783668.

● When you open an attribute view and there is a missing column in the required object, an error is shown and the editor does not open. For information regarding the solution of this issue, see SAP Note 1788552. Related Links

Creating Hierarchies [page 148]

Activating Objects [page 153]

Generating Time Data [page 118]

For modeling a business scenario that requires time dimension, you can populate time data in the default time- related tables present in _SYS_BI schema, for example while creating time attribute views. You can choose to generate the time data for a given time span based on your requirements such as, calendar type and granularity.

In document hana_dev_en (Page 121-126)