<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SAP CDS with optional parameters in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505835#M2003584</link>
    <description>&lt;P&gt;Hallo,&lt;/P&gt;&lt;P&gt;thanks for the links! &lt;/P&gt;&lt;P&gt;I tried both option and it didn't work. &lt;/P&gt;&lt;P&gt;I added following annotation:&lt;/P&gt;&lt;P&gt;@Consumption.filter.mandatory:false &lt;/P&gt;&lt;P&gt;@Consumption.filter.selectionType: #SINGLE&lt;/P&gt;&lt;P&gt;Without a positive result.&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;And in the second link you can coos the default values for the fields &lt;/P&gt;&lt;P&gt;#CLIENT, #SYSTEM_DATE, #SYSTEM_LANGUAGE, #SYSTEM_TIME and #USER.&lt;/P&gt;&lt;P&gt;I don't have those fields.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Hassin&lt;/P&gt;</description>
    <pubDate>Mon, 07 Mar 2022 15:24:06 GMT</pubDate>
    <dc:creator>hassin</dc:creator>
    <dc:date>2022-03-07T15:24:06Z</dc:date>
    <item>
      <title>SAP CDS with optional parameters</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505833#M2003582</link>
      <description>&lt;P&gt;Hallo,&lt;/P&gt;
  &lt;P&gt;I'm using a CDS View (mara) with parameters. &lt;/P&gt;
  &lt;P&gt;I want to make the parameters optional and not mandatory.&lt;/P&gt;
  &lt;P&gt;I have read, that I have to give the parameters a default value to solve this problem. &lt;/P&gt;
  &lt;P&gt;How can I input the the needed syntax in the code below?&lt;/P&gt;
  &lt;P&gt;regards&lt;/P&gt;
  &lt;P&gt;Hassin&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;@AbapCatalog.sqlViewName: 'ZCS_MARA_PARA'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'VDS View with Parameter'


define view ZCS_MARA_Test1_PARA
    with parameters 
        p_matnr : matnr, 
        p_ernam : ernam  
as select from ZCP_MARAView_Test1 


{
    //ZCP_MARAView_Test1
    
    matnr               as Materialnummer,
    ersda               as Angelegt_Am,
    ernam               as Angelegt_Von,
    laeda               as Geaedert_Am,
    
    case 
    when aenam = 'STZI' then 'S. Zinn'
    else aenam               
    end as Geaendert_Von
    
}
where matnr = :p_matnr
or    ernam = :p_ernam&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Mar 2022 13:12:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505833#M2003582</guid>
      <dc:creator>hassin</dc:creator>
      <dc:date>2022-03-07T13:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: SAP CDS with optional parameters</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505834#M2003583</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;You can use annotation  &lt;U&gt;@Consumption.filter.mandatory: True&lt;/U&gt;  for this.&lt;/P&gt;&lt;P&gt;More in this blog &lt;A href="https://blogs.sap.com/2021/06/03/abap-cds-views-working-with-optional-parameters/"&gt;https://blogs.sap.com/2021/06/03/abap-cds-views-working-with-optional-parameters/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You also refer to the below blog for another way&lt;/P&gt;&lt;P&gt;&lt;A href="https://blogs.sap.com/2018/01/06/optional-parameters-in-cds-views/"&gt;https://blogs.sap.com/2018/01/06/optional-parameters-in-cds-views/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 14:16:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505834#M2003583</guid>
      <dc:creator>subhajit</dc:creator>
      <dc:date>2022-03-07T14:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAP CDS with optional parameters</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505835#M2003584</link>
      <description>&lt;P&gt;Hallo,&lt;/P&gt;&lt;P&gt;thanks for the links! &lt;/P&gt;&lt;P&gt;I tried both option and it didn't work. &lt;/P&gt;&lt;P&gt;I added following annotation:&lt;/P&gt;&lt;P&gt;@Consumption.filter.mandatory:false &lt;/P&gt;&lt;P&gt;@Consumption.filter.selectionType: #SINGLE&lt;/P&gt;&lt;P&gt;Without a positive result.&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;And in the second link you can coos the default values for the fields &lt;/P&gt;&lt;P&gt;#CLIENT, #SYSTEM_DATE, #SYSTEM_LANGUAGE, #SYSTEM_TIME and #USER.&lt;/P&gt;&lt;P&gt;I don't have those fields.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Hassin&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 15:24:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505835#M2003584</guid>
      <dc:creator>hassin</dc:creator>
      <dc:date>2022-03-07T15:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAP CDS with optional parameters</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505836#M2003585</link>
      <description>&lt;P&gt;This quick &amp;amp; dirty solution may work for you.&lt;/P&gt;&lt;P&gt;First, create a CDS without parameters.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;define view ZCS_MARA_Test1_Vanilla
as select from ZCP_MARAView_Test1 
{
    matnr               as Materialnummer,
    ersda               as Angelegt_Am,
    ernam               as Angelegt_Von,
    laeda               as Geaedert_Am,
    
    case 
    when aenam = 'STZI' then 'S. Zinn'
    else aenam               
    end as Geaendert_Von
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then, make your CDS with parameters read data from that one.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;define view ZCS_MARA_Test1_PARA
    with parameters 
        p_matnr : matnr, 
        p_ernam : ernam  
as select from ZCS_MARA_Test1_Vanilla
{
    Materialnummer,&lt;BR /&gt;    Angelegt_Am,&lt;BR /&gt;    Angelent_Von,&lt;BR /&gt;    Geaedert_Am,&lt;BR /&gt;    Geaedert_Von&lt;BR /&gt;}&lt;BR /&gt;where Materialnummer = :p_matnr or Angelent_Von = :p_ernam&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When you need to read without parameters, access ZCS_MARA_TEST1_VANILLA. When you need to read with parameters, access ZCS_MARA_TEST1_PARA.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 05:47:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505836#M2003585</guid>
      <dc:creator>keremkoseoglu</dc:creator>
      <dc:date>2022-03-08T05:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: SAP CDS with optional parameters</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505837#M2003586</link>
      <description>&lt;P&gt;Hallo,&lt;/P&gt;&lt;P&gt;thanks for the solution! &lt;/P&gt;&lt;P&gt;My CDS View are build in a similar structure.&lt;/P&gt;&lt;P&gt;I have a basic view, a composite view and a consumption view. &lt;/P&gt;&lt;P&gt;In the last view (consumption) I use the parameters as you told.&lt;/P&gt;&lt;P&gt;The problem hear is, that you have to enter something for both parameters to revive a result / move forward. &lt;/P&gt;&lt;P&gt;I want to have the possibility to enter one parameter and receive an result.&lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.sap.com/storage/temp/2027829-image.png" data-attachment="2027829"&gt;image.png&lt;/A&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Hassin&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 11:33:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505837#M2003586</guid>
      <dc:creator>hassin</dc:creator>
      <dc:date>2022-03-08T11:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAP CDS with optional parameters</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505838#M2003587</link>
      <description>&lt;P&gt; &lt;SPAN class="mention-scrubbed"&gt;hassin&lt;/SPAN&gt; in that case, I suppose you should steer towards AMDP methods. You can import (optional) parameters or even ranges to an AMDP method, and execute a query accordingly.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 12:00:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505838#M2003587</guid>
      <dc:creator>keremkoseoglu</dc:creator>
      <dc:date>2022-03-08T12:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAP CDS with optional parameters</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505839#M2003588</link>
      <description>&lt;P&gt;As per current design, you are not able to make any of the CDS input parameter as optional &lt;/P&gt;&lt;P&gt;expect few like date, user and client.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 08:46:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sap-cds-with-optional-parameters/m-p/12505839#M2003588</guid>
      <dc:creator>hassin</dc:creator>
      <dc:date>2022-10-12T08:46:05Z</dc:date>
    </item>
  </channel>
</rss>

