Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
AnkurBajpai
Active Participant
Hi Folks,

In this blog we’re going to develop an SAP Fiori Elements (List Report) Application utilizing CDS view with parameter.

I checked in lots of blogs statement that Standard List Report doesn’t not support CDS view with parameter.

I found a solution and we just need to use single property in our manifest.json file to achieve it.

Below are the steps we need to do:

  1. CDS View source code

  2. Metadata of CDS view

  3. Web IDE code


 

  1. CDS View source code


@AbapCatalog.sqlViewName: 'ZCQMBTHFLGUXPOC'

@AbapCatalog.compiler.compareFilter: true

@AccessControl.authorizationCheck: #NOT_REQUIRED

@VDM.viewType: #CONSUMPTION

@OData.publish: true

@EndUserText.label: 'Batch Flagging Activities Report'

@UI.headerInfo: {
typeName : 'Batch Flagging Activities Report' ,
typeNamePlural: 'Batch Flagging Activities Report' }

define view ZC_QM_BTHFLG_POC_UX
with parameters
@EndUserText.label: 'History/Current'
@Consumption.defaultValue: 'Current'
@Consumption.valueHelpDefinition:[{entity:{name : 'ZI_Current_History',
element : 'Status'}}]
hist_curr : char7,

@EndUserText.label: 'Start Date'
@Environment.systemField: #SYSTEM_DATE
S_Date : dats,

@EndUserText.label: 'End Date'
@Environment.systemField: #SYSTEM_DATE
E_Date : dats,

@EndUserText.label: 'Plant'
@Consumption.valueHelpDefinition:[{entity:{name : 'I_Plant',
element : 'Plant'}}]
ip_Plant : werks_d

as select from ZI_QM_HIST_CURR_001 (S_Date:$parameters.S_Date,E_Date:$parameters.E_Date,
ip_Plant:$parameters.ip_Plant,
hist_curr:$parameters.hist_curr)
{
@EndUserText.label: 'Material'
@UI.selectionField.element: 'Material'
@UI.lineItem.position: 10
key Material,
_matnr_txt,

@EndUserText.label: 'Batch'
@Consumption.semanticObject: 'Batch'
@UI.lineItem.position: 20
key Batch,

@EndUserText.label: 'Change Control'
@UI.lineItem.position: 30
@UI.selectionField.element:'Change Control'
CC_ID,

@EndUserText.label: 'Flag/ Unflag'
@UI.lineItem.position: 40
@UI.selectionField.element:'Flag'
Flag,

@EndUserText.label: 'Flagging Type'
@UI.lineItem.position: 50
@UI.selectionField.element:'Flagging Type'
FlaggingSource,

}

2. Metadata of CDS view:

As I made 4 fields as parameterized, we can see in the below screenshot of Metadata of CDS view.


 

3. SAP Web IDE code:

  • Select a List Report template Application-> Click on Next



 

  • Enter the project details -> Click on Next



 

  • Select the system -> Select the OData service -> Click on Next





  • Select the Annotations files-> Click on Next



 

  • Select the OData Collection -> Click on Finish



 

  • Open the json file from the project structure.

  • Add "considerAnalyticalParameters": true as highlighted in below screenshot.



 

  • Run the application

  • Fill all the mandatory parameter-> click on Go



 

As you can see in the above screenshot the data is coming.

So, folks cheers we can use CDS view with Parameters in List Report Application. We don’t need any extension or any extra code for Parameterized CDS.

I hope this simple trick can help you guys to consume CDS view with Parameters in List Report Application template.

 

 

Regards,

Ankur Bajpai

 
18 Comments
Ramjee_korada
Active Contributor
Thanks for blog and I was looking for it.

I have question. As per my knowledge, CDS view parameters can take single value at a time. Since we are fiori List report application, End user can search for multiple values.

In your example, I want to search for plants 1234 , 5678. Does this work with CDS view parameters + Fiori App.

Best wishes,

Ramjee
AnkurBajpai
Active Participant
0 Kudos

Yeah, I agree koradaramjee789 As we can pass single value in CDS view with Parameters, same thing we can do here from Fiori Elements(List Report) application.

For multiple selection of the field I think we need to go with CDS view without parameter.

 

Thanks,

Ankur Bajpai

termanico
Participant
0 Kudos
Coooool! 🙂

Thanks Ankur!
AnkurBajpai
Active Participant
0 Kudos
🙂 termanico
former_member570896
Participant
Thanks Aknur!

Very useful, I am currently trying to use analytical parameters but with Java and Apache Olingo in BTP. It would be interesting if SAP spent more time developing annotations for Apache Olingo + HANA Database + OpenUI5. I think that I can provide some scripts that we had to develop in our project to extend the EDM adding specific annotations for SAP (like ValueList, LineItems, etc.).
franois_henrotte
Active Contributor
Nice trick, very useful
AnkurBajpai
Active Participant
0 Kudos
That would be really amazing!
AnkurBajpai
Active Participant
0 Kudos
Thanks franois.henrotte
shweta_sahay
Explorer
0 Kudos
Hi Ankur,

Very nice blog! When I am trying to achieve same I am getting $batch exception . Exception is raised with message

"The caller violated a precondition for a method call"  in Fiori .

When I separately run Odata by passing parameters I am getting result .

Thanks

Shweta





bravetom
Discoverer
0 Kudos

Thanks!

axel_mohnen_ctie
Explorer
0 Kudos
Hi Ankur,

Thanks a lot for the excellent blog.

I tried to follow your example, but in the smart filter bar I only see the "Parameters" fields like S_Date. The key field "Material" is not visible at all either in the smart filter bar nor in the "adapt filter" popup.

Do I miss something?

Thanks a lot.

Kind regards

Axel
axel_mohnen_ctie
Explorer
0 Kudos
Hi Ankur,

it works now. I selected just the wrong Entityset.

@Shweta: I had the same issue:

"The caller violated a precondition for a method call"  in Fiori .

When I separately run Odata by passing parameters I am getting result .

 

I forgot the parameter “considerAnalyticalParameters”: true in the manifest.

Kind regards

Axel
former_member756463
Discoverer
0 Kudos
Hi Ankur,

Thanks for this, very helpful !! I have a question. Can we also put parameterized CDS views as value helps using the annotation @Consumption.valueHelpDefinition.

For ex: in the above, you have used a parameter s_date. So suppose i want to pass this parameter further to a value help for one of the projection list fields, is that possible?

I tried with the "additional bindings" annotation but it didnt work.

Please let me know your thoughts on this.

 

Thanks,

Govind
AnkurBajpai
Active Participant
0 Kudos
Hi govindvn92 ,

Sorry for late reply, I guess it should work as you can see in my CDS view code I used for multiple parameters.

Please let me know if more inputs needed.

 

Thanks,

Ankur Bajpai

 
AnkurBajpai
Active Participant
0 Kudos
Hi axel.mohnen.ctie

Sorry I was not much active. Thanks for posting resolution!

 

Thanks,

Ankur Bajpai
AnkurBajpai
Active Participant
0 Kudos
Hi shweta.sahay ,

I hope your query also resolved by axel.mohnen.ctie .

 

Thanks,

Ankur Bajpai
former_member756463
Discoverer
0 Kudos
Hi Ankur,

 

Thanks for the response. What i meant is suppose in your example, we need a value help definition for the field 'Material'.

Now, i want to restrict the number of materials shown on the value help based on the start date parameter, that is, I want the value help of material shown on UI to be dynamic based on whatever value is inputted on the Start Date parameter.

Is that something possible through the @Consumption.valueHelpDefinition annotation or any other way?

 

Thanks,

Govind
VenkateshThota
Explorer
0 Kudos
Hi Ankur Bajpai

I would like to navigate from overview page to list report with some filters

 

Does above solution works for my criteria

 

 
Labels in this area