Skip to Content

SAP Fiori List Report Utilizing Parametrized CDS

I have Identified a way where CDS with parameters can be easily carried out with the Fiori  List Report.

 

A typical List Report generation use the following steps:

  1. Consumption CDS Exposed as OData service
  2. Template Based List report generation using OData

This works fine when we have CDS with all relevant annotations. In cases where we have Parametrised CDS, Standard List Report generation will not support.  Many Times, we have parametrised CDS for narrowing down the search criteria.

“List Report is generated with Parametrised CDS with Mandatory Fields, but the data will not have fetched “

For the CDS view with parameters, a separate Parameter Entity Set on the OData Service gets created along with Columns Entity Set and the data is fetched based on the parameter entry, which will create a query as “zpart_param(p_rldnr=’0L’)/Set”.

CDS Source code:

@AbapCatalog.sqlViewName: ‘paramtest’
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: ‘test’
@OData.publish: true
define view zpart_param

with parameters
p_rldnr: rldnr
as select from acdoca as a{

key a.rldnr as Ledger,

a.rbukrs as CompanyCode,
a.kunnr as CustomerNo,
a.racct as GLAccount,
a.belnr as DocumentNo
}
where a.rldnr= $parameters.p_rldnr

 

 Metadata for above CDS :

Solution Overview

As mentioned above, Standard List Report generated code won’t support the Parametrised CDS.

List Report is generated with the Mandatory Fields (as part of the CDS Parameter) but hitting the go Button will not bring the data.

In this scenario, we need to extend the List Report code and can achieve the relevant functionality

  1. List Report Extension to support Parameterized CDS

Select Project -> Extend-> List Report Extension-> Action

2. We need to add the Following code inside the EXT-> controller.js file

On Go event of filter will get the Parameter binding path of the FilterBar and set the table binding path with parameter path.

 

 

onBeforeRebindTableExtension: function(oEvent) {

var oSmartTable = oEvent.getSource();
var oSmartFilterBar = this.byId(oSmartTable.getSmartFilterId());
var path = oSmartFilterBar.getParameterBindingPath();
oSmartTable.setTableBindingPath(path);

}

 

Output: 

9 Comments
You must be Logged on to comment or reply to a post.
  • Hi Partibha,

     

    I think you could archive the same functionality easily by adding the following annotation to the field rldnr in CDS View without using parameter and Custom code in UI.

     

      @UI.selectionField: [{position: 10 }] 
     @Consumption: {
                        filter: {
                            mandatory: true,
                            defaultValue: '',
                            defaultValueHigh: '',
                            hidden: false,
                            selectionType: #INTERVAL,
                            multipleSelections: true
                        }
                    } 

     

    Regards,

    Tarun

    • Hi Tarun,

      The use case is for CDS with parameter, for the simple CDS without parameter the annotation you have mentioned is fine.

      Regards,

      Parthibha

    • Hi Tarun,

       

      Yes, by using annotation in CDS this functionality can be achieved but only for the selectiontype: #INTERVAL. What if in case of RANGE?

      Thanks,

      Monika

  • Hi Parthibha,

    Thank you sharing amazing example.

    Currently i am working in same use-case  but I want to pass multiple values in  one parameter from FIORI List Report

    Can you please help me on same

     

    Regards

    Madhu

  • Hi,

    How did you expose the parameter to UI level? Currently, a smart template app does not expose parameter to the UI. Thanks!

     

     

    Regards,

    Kumud

     

  • Hi Parthibha Tulasiram,

     

    I have followed the steps as described by you in this blog. However, selection field is not displayed in the smart template. Could you please suggest me, at where i have made mistake. I have shared the screen shot of annotation file and my smart template application.

     

  • I am also facing the same issue. Is there any solution for this issue?

    How the association is coming from parameters entityType (zpart_test_cdsParameters) to main enitytype (zpart_test_cdsType) in CDS view?

    We are missing the relationship in CDS view? Can you please explain how we can establish relationship between both entitytypes?