on 07-05-2016 6:37 PM
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:
Thanks,
Avishek.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.