Skip to Content

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: 

To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

  1. Tarun Jain

    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

    (0) 
    1. Parthibha Tulasiram Post author

      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

      (0) 
  2. Madhu latha

    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

    (0) 
  3. Kumud Singh

    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

     

    (0) 

Leave a Reply