Skip to Content
Technical Articles

SAP Fiori List Report Utilizing CDS View with Parameters

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

 

6 Comments
You must be Logged on to comment or reply to a post.
  • 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

    • Yeah, I agree ramjee korada 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

  • 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.).