cancel
Showing results for 
Search instead for 
Did you mean: 

XS OData on Calc view with wild card Input Params

avishek_gorai2
Participant
0 Kudos

Hi Experts,

I am trying out a scenario with XS OData where I want to pass optional / wild card Input parameters.

Sample scenario: Calculation view Outputs an Aggregate of Sales Amount per 'Business Partner ID' and 'Billing Status'. Created a Calculation view with two input parameters (BILL_STATUS and PARTNER_ID) both Optional. These parameters are used in an expression at the Projection level with a match condition.

Data preview of Calculation view works fine, when either of the Parameters are entered as '*'. Infact both input parameters have default value as '*' in the Parameter Definition.

Next, this Calculation view was exposed as an OData service. The service metadata is as shown below:

My intension was to pass wildcard (to begin with *) for either or both of these parameters (as it works in the data preview). However the OData is not allowing passing '*' for any of the input parameters.

The following call returns results:

...serviceName.xsodata/InputParams(BILL_STATUS='I',PARTNER_ID='0100000000')/Results

However a call with wildcard for input parameters does not return any records; URL like:

...serviceName.xsodata/InputParams(BILL_STATUS='*',PARTNER_ID='0100000000')/Results

I even tried escape character for wildcard like '\\*' or '\*'. none of these worked.

My question is:

  1. Is wild card characters not allowed in XS OData as Input parameters?
  2. Since the parameters are optional with default value. Is there a way to skip passing them /one of them. I could not get the service working without passing both the parameters.

Thanks,

Avishek.

Accepted Solutions (1)

Accepted Solutions (1)

SergioG_TX
Active Contributor
0 Kudos

Avishek,

you are correct.. the wild card param will not work as you already know.. what you can do is to assign a default value on your input param in case the request does not contain one value.

alternatively, you if you were to pass a value and instead of matching via equality, you could use the contains operator ... for string values...  i think you are more concerned about my first answer above.

hope this helps...

avishek_gorai2
Participant
0 Kudos

Hi Sergio,

Thanks for your response.

The Input parameters already have default value defined as '*' (star). Which kicks in during data preview.

However I am not clear how to construct the OData Query URL for not passing a parameter.

I tried

  1. /InputParams(BILL_STATUS='',PARTNER_ID='0100000000')/Results          returned no results
  2. /InputParams(BILL_STATUS=null,PARTNER_ID='0100000000')/Results     returned no results again
  3. /InputParams(BILL_STATUS,PARTNER_ID='0100000000')/Results              threw syntax error
  4. /InputParams(PARTNER_ID='0100000000')/Results     syntax error number of keys do not match

For now, I just need to have the flexibility to choose if a parameter value is passed or not passed. If not passed the default value is applied.

The second option, I think will have some limitation when trying to select all values for a particular column.

Regards,

Avishek.

SergioG_TX
Active Contributor
0 Kudos

most likely you have the input param set as mandatory... please uncheck the checkbox so that you can omit it from the request.

avishek_gorai2
Participant
0 Kudos

Sergio,

Both Input Parameters are optional from the beginning. My idea was to keep them optional.

Got stuck in the OData. Optional parameters worked fine till data preview of Calculation View.

Regards,

Avishek.

SergioG_TX
Active Contributor
0 Kudos

so make them optional.. and also provide a default value in the view itself.. that should help

avishek_gorai2
Participant
0 Kudos

Sergio,

I think I confused you with my last reply. The input parameters are already optional and their default value is *.

Answers (1)

Answers (1)

avishek_gorai2
Participant
0 Kudos

As a workaround, I used two Calculated columns to convert blank values of Input Parameters to *.

In the filter expression used the calculated columns instead of Input Parameters.

Now I am able to get results from OData passing '' (blank) as values for Input Parameters.

However I will still be interested in knowing if there is a way to pass no values to Input parameters directly (so the default kicks in).

chandan_praharaj
Contributor
0 Kudos

I have tried to replicate your scenario, to confirm there in no way to pass no value, as Sergio mentioned, you have to hardcode the default value in the IP part of Calc View. OData is not SAP Standard. So we can do like that only .

avishek_gorai2
Participant
0 Kudos

Chandan,

Were you able to construct an OData URL to pass no Input Parameter value such that the default value was used. I was not able to do that, inspite of both my input parameters being optional.

Best I could do was pass a blank for the input parameters and that ended up in the Calc view being called with blank as the IP and not the default value. Finally I had to write the expression to handle this (check my response above).

If you found out a way to trigger the use of the default parameter please share.

Regards,

Avishek.

chandan_praharaj
Contributor
0 Kudos

I have implemented one of such scenario. I think I got your problem.

You are trying not to pass Optional IP in URL.: Which is not possible as in ODATA service , if you declare an entity for IP(Input Parms), you have to pass them for sure.

So there is no Optional concept here, if we are passing the value in ODATA, irrespective of we declare it as Optional/Mandatory.

This can only be leveraged in your UI code, for Example if user keeps that filed as Blank, you need to explicitely  pass some data so that it should bring all the data.

Like this you can/have to achieve.

In My case, I have one IP which will take Days (for Example 14 days), and calculate the date range based on that. So if user keeps the UI filed as blank, from UI side while generating the URI for OData, I have passed 0(ZERO), so that my calculation view calculate the date range To as 31.12.9999. I think my scenario will help you understand how Odata with IP works.

UI need to handle this while generating the ODATA service URL.There is no Optional concept, rather I can call this as UI will have to handle this so that for User, it is Optional, who can enter anything.