Wednesday, 8 December 2021

Understanding Attributes ,Text, Value help in S/4 HANA ABAP CDS views

Introduction: 

This Blog post provide information and understanding on very important features in S4HANA Embedded Analytics which is Text, Attributes, and value help in CDS views.

Overview:

We face multiple requirements in Reports based on CDS views related to text, Attributes and Value help.

This can be achieved through various methods, in this Blog Post we will discuss few methods, their advantages and advantages. Sometimes we already standard CDS views for Dimensions and Text and sometimes we have to create them manually.

Solution: Lets discuss below methods to understand the concept:

Method 1: Using CDS View as Master Data View

This method is like Master data concept in SAP BW, there we have Master Data Info objects containing attributes and Text tables. Then in info providers we can assign their property to the fields coming from source.

Similarly, here we create Dimension View which will have Attribute data and Text View which will have text data. Then we will use the text view in Dimension View to make it Master Data and further use this Dimension view in our Transaction Data (Basic/Composite View).

Case 1. When we don’t have standard Dimension and Text view available for required field:

SAP has already provided Standard Dimension and Text View for most the fields, Example: I_Material , I_CompanyCode etc. However, there are some fields where we do not have Standard Views available, depending upon the report requirement we might need to create them.

Let’s take field BWMOD/KKREF, these fields contain same data, BWMOD is coming from T030 table and KKREF from T025L to get the text. Here we don’t have Standard Dimension and Text View on this field. Therefore we will use above to create our Dimension and text Views.

Note: To get the attributes we must have dimension view and to have text field we must have text view.

Let’s see how:

Step 1. Create Text View. Here important annotations are :

@ObjectModel.dataCategory: #TEXT –

@ObjectModel.representativeKey: ‘ValuationGroup’

@Semantics.language: true

@Semantics.text: true

Text CDS view code with annotations:

@AbapCatalog:{

sqlViewName: ‘IAMTEXTVIEW’,

preserveKey: true,

compiler.compareFilter: true

}

@ObjectModel.dataCategory: #TEXT

@VDM.viewType: #BASIC

@ObjectModel.representativeKey: ‘ValuationGroup’

@Metadata.ignorePropagatedAnnotations: true

@EndUserText.label: ‘Text View on Valuation Group’

define view IAM_TEXT_VIEW

as select from t025l

{

key t025l.kkref as ValuationGroup,

@Semantics.language: true

key t025l.spras                                                   as Language,

@Semantics.text: true

t025l.krftx as ValuationGroupName

}

Step 2. Create Dimension View on T030 Table where one of the fields is BWMOD, Take the distinct value for BWMOD and use above created Text view in association and provide CDS level and field level annotations as given below:

Note: When we don’t have separate table for BWMOD/KKREF, we can use distinct in CDS view as we used for below table, but we have table for KKREF which is T025K and hence we can also use directly T025K table without using distinct in our view.

Important points in Dimension CDS view:

1. Annotations:

@Analytics: { dataCategory: #DIMENSION}

@ObjectModel.text.association: ‘_TEXT’

@Search.defaultSearchElement: true

@Search.fuzzinessThreshold: 0.8

2. Association with Text View

Dimension CDS view code with annotations:

@AbapCatalog: {

sqlViewName: ‘IAMDIMENSIONVIEW’,

compiler.compareFilter: true

}

@AbapCatalog.preserveKey: false

@Analytics: { dataCategory: #DIMENSION}

@VDM.viewType: #BASIC

@EndUserText.label: ‘Dimension View on Valuation Group’

@Search.searchable: true

@ObjectModel.representativeKey: ‘ValuationGroup’

define view IAM_DIMENSION_VIEW

as select distinct from t030

association [0..*] to IAM_TEXT_VIEW  as _Text on $projection.ValuationGroup = _Text.ValuationGroup

{

@ObjectModel.text.association: ‘_TEXT’

@Search.defaultSearchElement: true

@Search.fuzzinessThreshold: 0.8

@Search.ranking: #HIGH

key t030.bwmod as ValuationGroup,

_Text

}

Step 3: Use association in Basic View/Composite view with above Dimension view and provide the field level annotation and express the association as below till Composite View:

SAP HANA Exam Prep, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Preparation, SAP HANA Tutorial and Materials
Composite View Method 1

Step 4: Now we can check result of our View in Tcode: RSRTS_ODP_DIS

SAP HANA Exam Prep, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Preparation, SAP HANA Tutorial and Materials
RSRTS_ODP_DIS Method 1

Here we can see that Attribute and Text symbols are appearing beside Valuation group , and we can see structure as well.

Step 5: Use above field in Consumption View /BW query, Attributes and Text will come automatically and when we create variable on Valuation Group then Value help will also come automatically with key and text options available.
 

Case 2. When we have standard Dimension and Text view for available for required field:


For example: I_MATERIAL and I_MATERIALTEXT is available for Material field.

We can follow the Steps mentioned in Case 1 from Step 4 to Step 5.

Understanding:

We can understand from above that Dimension View is created for Attributes and Text view is created for Descriptions, and when we use Dimension View in association with Composite view, we assign these properties to our field from transaction data and can also assign the value help to it (only when we assign variable at query level/Consumption View).

Special Cases:

1. Compounding Object GL account:

From S4HANA 2020, it is necessary to provide association of Chart of account along with GL account association in path expression and at field level.

Reason: Functionally GL account is compounded with Chart of accounts, because in Standard CDS view on GL account we can see that we have two keys.

SAP HANA Exam Prep, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Preparation, SAP HANA Tutorial and Materials
Standard GL Account CDS View Keys

Hence it is now necessary to use all the keys in further associations and annotations. Systems moving from previous version to 2020 might face these upgrade issues if they have not used association and annotation for both the keys properly.

2. Value help will show all the data of dimension view but sometimes we need to restrict the data.

Example :User want to see only GL accounts specific to one Chart of account. Though we can not do anything in standard Dimension  CDS view , we can use condition in our association on chart of accounts like below:

association to I_GLAccount as _GLAccount on_GLAccount.ChartOfAccounts= ‘Filter’
and $projection.GLAccount = _GLAccount.GLAccount

Method 2: Using CDS view just as a text view

In this method we will use or create just text view. We can take any field as key and can make any field  as text from different tables or from same table. We will not need Spras Language key.

Important Annotation:

@ObjectModel.dataCategory: #TEXT

@ObjectModel.representativeKey: ‘ValuationGroup’

@Search.defaultSearchElement: true

@Search.fuzzinessThreshold: 0.8

@Search.ranking: #HIGH

@ObjectModel.text.element: [‘krftx’]

@Semantics.text: true

Step 1: Create Text View with annotations as below:

AbapCatalog: {

  sqlViewName: ‘IAMTEXTVIEW’,

  compiler.compareFilter: true

  }

@AbapCatalog.preserveKey: false

@ObjectModel.dataCategory: #TEXT

@VDM.viewType: #BASIC

@EndUserText.label: ‘Text View on Valuation Group’

@Search.searchable: true

@ObjectModel.representativeKey: ‘ValuationGroup’

@Metadata.ignorePropagatedAnnotations: true

define view ZCFI_DV_VG01

{

@Search.defaultSearchElement: true

@Search.fuzzinessThreshold: 0.8

@Search.ranking: #HIGH

key t025l.kkref as ValuationGroup,

@ObjectModel.text.element: [‘krftx’]

@Semantics.text: true

t025l.krftx as krftx

}

where spras = ‘E’

Step 2:

Now in Composite View/Basic View use the association as below with Text View we just created and annotation at field level:

SAP HANA Exam Prep, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Preparation, SAP HANA Tutorial and Materials
Composite View Method 2

Step 3:

Result of Text View  and Composite View in Tcode:

SAP HANA Exam Prep, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Preparation, SAP HANA Tutorial and Materials
RSRTS_ODP_DIS Method 2

We can observe that Text and Attribute symbol is not appearing beside. However there is Text Structure.

Result in RSRT:

SAP HANA Exam Prep, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Preparation, SAP HANA Tutorial and Materials

Some difference between two methods:

Using Master Data (Method 1) Using Text (Method 2) 
Everything related to Master Data, Text and even Heirarchy can be achived from one view  Only used for text
Association with Dimension View withText View is required  Only Text View is enough 
Annotation to be used at composite level:@ObjectModel.foreignKey.association: ”  Annotation to be used at composite level:@objectmodel.text.association: ” 
It will take care of language automatically  Language has to be filtered at text level if present in text, not suitable where we have muktple language Reports 

Method 3: Using Value Help annotation as a field level annotation.

We can directly use Value Help View in the field level annotation in Consumption View.  We can use annotation as:

Consumption.valuehelpDefinition.entity.name : ‘ View Name’

Consumption.valuehelpDefinition.entity.element:   ‘Field Name ’

However, it doesn’t provide Text in report level and only used for Value help Purpose.

No comments:

Post a Comment