Skip to Content
Author's profile photo Parthibha Tulasiram

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: 

Assigned Tags

      16 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Tarun Jain
      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

      Author's profile photo Parthibha Tulasiram
      Parthibha Tulasiram
      Blog 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

      Author's profile photo Monika Juyal
      Monika Juyal

      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

      Author's profile photo Cagalp Kocyigit
      Cagalp Kocyigit

      Hi Parthibha,

      thank you for sharing. Great example.

      Author's profile photo Madhu latha
      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

      Author's profile photo Kumud Singh
      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

       

      Author's profile photo Parthibha Tulasiram
      Parthibha Tulasiram
      Blog Post Author

      Hi Kumud,

       

      I have used Fiori element- list report application template.

       

      Regards,

      Parthibha

      Author's profile photo Ronak Jain
      Ronak Jain

      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.

       

      Author's profile photo Fernando Kuhn
      Fernando Kuhn

      Did you manage to correct this? I have the exact same problem.

      Author's profile photo sudhakara reddy
      sudhakara reddy

      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?

      Author's profile photo Tanveer Shaikh
      Tanveer Shaikh

      Great Example !

      Any comment on how to pass parameter to the object page of the list report ? I have a working parameterized  odata service with dependent entity navigation but a lineitem table on object page won’t trigger based on the list report parameter ?

      Question asked here -

      https://answers.sap.com/questions/12650436/list-report-to-object-page-navigating-to-entities.html

      Author's profile photo Smriti Gupta
      Smriti Gupta

      Hi ,

       

      Thanks for this blog. I want to pass input parameter in Smart Business KPI. I am also getting in in evaluation, however its not appearing in the App.

      -<EntityType sap:content-version="1" sap:semantics="parameters" Name="ZC_FK_LAGEAUSLASTParameters">

      -<Key>

      <PropertyRef Name="P_mtart"/>

      </Key>

      <Property Name="P_mtart" Nullable="false" Type="Edm.String" sap:label="Materialart" MaxLength="4" sap:text="P_mtartText" sap:filterable="false" sap:parameter="mandatory"/>

      <Property Name="P_mtartText" Type="Edm.String" MaxLength="60" sap:filterable="false"/>

      <NavigationProperty Name="Results" ToRole="ToRole_ZCFKLAGEAUSLASTParametersToResult" FromRole="FromRole_ZCFKLAGEAUSLASTParametersToResult" Relationship="ZC_FK_LAGEAUSLAST_CDS.ZCFKLAGEAUSLASTParametersToResult"/>

      </EntityType>

      Any suggestions pls

       

      Thanks

      Smriti

      Author's profile photo Sagar .
      Sagar .

      Nice Blog

      Author's profile photo Tanveer Shaikh
      Tanveer Shaikh

      Hi Parthibha Tulasiram,

      Any pointers as to how to build Analytical List Page for parameter based Odata Service ?

      Here is sample application where “Display Currency” ( Mandatory) is defined as a input parameter.  Looked everywhere but seems there no documentation around it.

      Looking for a sample annotation / required Odata service metadata / extension code sample to achieve input parameter based ALP .

      Help !

      Thanks,

      Tanveer

      Author's profile photo Tikeer Guo
      Tikeer Guo

      Dear Tanveer,

       

      I also face the issue, when the CDS view has an input parameter and used the input parameter as where condition in the CDS view, then build the ALP based on this CDS view, the ALP page is crashed when run it, the ALP page cannot load. Have you found the solution?

      Thank you.

       

      Author's profile photo Con Pirzas
      Con Pirzas

      Hi Parthibha,

      Old post, but thought i would give it a go, as someone may respond. Followed your instructions for the CDS View with parameters, and fails with: Target was not found, Cannot read properties of undefined (reading 'get Metadata'). I run it within the SAP Cloud Web IDE with the test Fiori tile.

      F12 Errors:

      2023-06-21 19:45:33.346100 A syntax error occurred while evaluating 'cp/com/zcptest/ext/controller/ListReportExt.controller.js', restarting the app with sap-ui-debug=x might reveal the error location - sap.ui.ModuleSystem
      u @ Log-dbg.js:493
      Log-dbg.js:493 2023-06-21  Attempt to load Extension Controller cp.com.zcptest.ext.controller.ListReportExt was not successful - is the Controller correctly defined in its file? -
      u @ Log-dbg.js:493
      2Controller-dbg.js:247 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'getMetadata')

       

      Code added to ListReportExt.controller.js as per your instructions:

      sap.ui.controller("cp.com.zcptest.ext.controller.ListReportExt", {
      onClickActionzvbak1: function (oEvent) {
      onBeforeRebindTableExtension: function(oEvent) {
      var oSmartTable = oEvent.getSource();
      var oSmartFilterBar = this.byId(oSmartTable.getSmartFilterId());
      var path = oSmartFilterBar.getParameterBindingPath();
      oSmartTable.setTableBindingPath(path);
      }
      }
      });

      Would appreciate any assistance,

      thanks,

      Con.