ABAP CDS Views and F4 and annotation
ABAP CDS Views and F4 and annotation
& F4 Help
91233.067
Introduction:
In the SAP Embedded Analytics world, ABAP Core Data Service Views are also known as ABAP CDS Views.
ABAP CDS Views are defined on top of existing database tables. Which can be further used in UI5
application for reporting purpose. When we deal with reports, then we need some selection parameters to
restrict data in to get expected output. Which works as selection screen in UI5 application. Such
functionality can be achieved with the help of ABAP CDS view.
In the world of SAP Embedded Analytics, ABAP Core Data Service views are also called views.
ABAP CDS. ABAP CDS views are defined on top of existing database tables. Who
can then be used in the UI5 application for reporting purposes. When we process
reports, we need certain selection parameters to filter the data in order to obtain
the expected output. Which functions as a selection screen in the UI5 application. Such a feature
can be obtained with the help of the ABAP CDS view.
Method 1:
{
@AnalyticsDetails.query.axis: #ROWS
key aXYZ,
@EndUserText.label: Service Order Type
@AnalyticsDetails.query.axis: #ROWS
OrderType
Note: Parameter values can be passed to composite view as shown in above code.
In the above example, we are getting a pop-up to provide inputs, but we are not getting F4 help for inputs.
can be achieved as below.
We have added annotation @Consumption.valuehelpDefinition: at parameter level to get input help. Name
& element helped us to connect with input help fields from CDS view ZCDS_XXXX_Value_Help.
We have not added any other association related ZCDS_XXXX_Value_Help in Consumption / composite /
interface views.
Sample Code -
{
@AnalyticsDetails.query.axis: #ROWS
key aXYZ,
@EndUserText.label: Service Order Type
@AnalyticsDetails.query.axis: #ROWS
#KEY_TEXT
OrderType
Method 2:
In this method we are not creating CDS with parameters but we are going to use annotation
@consumption.filter.mandatory : True. This annotation will give us prompts the same as the parameter.
@AbapCatalog.sqlViewName: Z_XXXX_V1
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@VDM.viewType: #CONSUMPTION
@Analytics.query: true
@Analytics.dataExtraction.enabled: true
@EndUserText.label: Consumption view
define view ZCDS_C_XXXXas select from ZCDS_I_XXXX
{
@AnalyticsDetails.query.axis: #ROWS
key aXYZ,
@Consumption.Filter.mandatory: True // Annotationfor input
prompts
@Consumption.valueHelp: _ValueHelp.aXXXX // Annotation to link with
CDSview which will generate text
@EndUserText.label: Service Order Type
@AnalyticsDetails.query.axis: #ROWS
#KEY_TEXT
OrderType
}
Output:
Here we can see that F4 help is also enabled and it has happened because of annotation.
@Consumption.ValueHelp.
When we use this annotation then we must provide connection to our association in Consumption view.
@Consumption.ValueHelp: ‘_ValueHelp.aXXXX’
Here ‘_ValueHelp’ is the association name and ‘aXXXX’ is the field on which we are generating value help.
Here we have created an association with the CDS view from which we are generating Value help. In addition to
this, we have mentioned 3 annotations above order type. We must use those annotation if we are generating
value help in parameter.
@AbapCatalog.sqlViewName: ZVM_XXX_A1
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Analytics.dataCategory: #CUBE
@VDM.viewType: #COMPOSITE
@EndUserText.label: Parameter based CDS view
define view ZCDS_I_XXXX
as select from aXXX_Table
association [0..1] to ZCDS_XXXX_Value_Help_ValueHelp
on $projection.OrderType= _ValueHelp.OrderType
{
key aXYZ,
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
@ObjectModel.foreignKey.association: _ValueHelp
aXXXX as OrderType,
//Association
_ValueHelp
@ObjectModel.Foreignkey.association will work with primary key of CDS view used in association.
i) In composite view, use the @ObjectModel.Text.Association annotation and provide a direct mapping to Text.
View.
Advantage: With this method, there will be no need for a dimension view while generating input help.
If we want to allow users to select multiple inputs, then use the annotation below at the consumption level.
@Consumption.filter.multipleSelections: true
Sample Code –
This will give us option to have multiple selection. User can choose & pass multiple inputs to report.
If we face a scenario where we need an option to have a range selection screen, then we can use the annotation below.
in Consumption view.
@Consumption.filter.mandatory: True
@Consumption.filter.selectionType: #RANGE
Till now we have seen multiple options to generate parameters & F4 help for it. Now let’s have look at
CDS view in which we have generated value help. Highlighting annotations which are important in both
CDS views.
CDS view used for Value help association
@AbapCatalog.sqlViewName: ZXXXXTEXT1
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.viewType: #BASIC
@ObjectModel.dataCategory: #TEXT
@Search.searchable: true
@EndUserText.label: Value Help Text
define view ZCDS_XXXXX_TEXTas select from tXXX01 // CDSView to
generate text
{
key aXXXXas OrderType, //Key Field
@Semantics.text: true
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
txt as OrderTypeText //Text Field
} where spras= 'E'
Important note
If we define the txt field as Key in the CDS view, then the text will not appear in the F4 help.
define view ZCDS_XXXXX_TEXTas select from tXXX01 // CDSView to
generate text
{
key aXXXXas OrderType, //Key Field
@Semantics.text: true
@Search.defaultSearchElement: true
@Search.fuzzinessThreshold: 0.8
Key txtas OrderTypeText //Text Field
as Key
}
In the below screenshot, only keys are appearing. Text is missing in F4 help as we have defined txt field as
Key.
Conclusion: ABAP CDS views are helpful to build user-friendly reports. We can allow users to have single
selection, multiple selection or range when the user executes those reports via any UI5 application.
References:
FollowLikeRSS Feed
Alert Moderator
Assigned Tags
View more...
Similar Blog Posts
ABAP CDS Views: Optional parameters in CDS View
By Yogen Patil June 03, 2021
ABAP CDS Views: Default values in parameters
By Yogen Patil June 03, 2021
Predefined Virtual Data Model as an example for understanding the difference of CDS View type
By Masaaki Arai Oct 18, 2018
Related Questions
CDS View F4 help - AnalyticsDetails.query.display #KEY_TEXT not working for parameters
By Christian Müller Mar 10, 2022
Passing multiple values in an input parameter for CDS views
By Vidhatha Ramakrishna Appikonda Jun 24, 2020
Text Value not Appearing in F4 Help of Input Parameter in Consumption CDS View
By Shilpi MajumdarSep 05, 2021
9 Comments
You must be logged in to comment or reply to a post.
KJ 911
June 16, 2021 at 4:28 pm
Excellent! Thank you very much for the information, it has worked perfectly for me.
However, I have a doubt, is it possible that when showing the aid values, it only ...
shows me the values that are written or are within the execution of the query.
Currently help values show all values from the master table.
Thank you!
Like 0
Share
Abhishek Chanders
August 6, 2021 at 8:46 am
Great Post.
I am having an issue with the last part. I tried to display only the key in the f4 help and hide the text.
by making it as a Key. But it is not working for me. In RSRT it is working as expected, but in
FIORI Query Browser, the Text is still displaying. The values in the Key field are copied to the
Text Field and it is showing the same values in both Key and Text Columns in F4. Let me know if
Is there any other solution for this?
Thank You
Like 0
Share
Yogen Patil
Blog Post Author
August 26, 2021 at 8:32 am
Remove association of text view from CDS view which is linked to generate input help.
Like 0
Share
Mamatha Krishna
February 23, 2022 at 5:49 pm
Helpful blog. Thank you !!
Like 1
Share
Yogen Patil
Blog Post Author
March 4, 2022 at 11:42 am
Thank You
Like 0
Share
Joseph BERTHE
March 3, 2022 at 3:51 pm
I have an issue regarding my F4 Value Help. When I try to search on the key field, it is OK, but when
I want to search on Text field, nothing happened. Is it a restriction or is there any annotations to
make it possible?
GET Idtf?$skip=0&$top=10&$filter=startswith(IdtfText,%27L%27)
Regards,
Joseph
Like 1
Share
Yogen Patil
Blog Post Author
March 4, 2022 at 11:41 am
Hi Joseph,
F4 help will work with Text as well. Please check if you are using all annotations mentioned.
above.
Regards,
Yogendra
Like 0
Share
Maxine Chin
March 23, 2022 at 10:05 PM
Hi Yogendra,
Cheers,
Max
Like 0
Share
Yogen Patil
Blog Post Author
April 29, 2022 at 2:21 pm
Thank You