cancel
Showing results for 
Search instead for 
Did you mean: 

SAP HANA SP5 - OData for Calc. view with parameters

iwan_santoso4
Participant
0 Kudos

Hi All,

Does anyone know how to define xsodata service file to expose a calculation view with parameters and how to call them from the browser?

For example I would like to expose a calculation view called CalcView1 with parameter of KUNNR and MATNR as oData service. How do I go about defining .xsodata file? and how to call the web service from a browser.

Thanks in Advance,

Iwan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Iwan,

  Not sure about passing parameters to a calc view but if you haven't seen Werner's blog on exposing a calc view and calling it via oData have a look. That should at least get you started.

http://scn.sap.com/community/developer-center/hana/blog/2013/01/22/rest-your-models-on-sap-hana-xs

Oliver

iwan_santoso4
Participant
0 Kudos

Thanks for the reply Oliver. Unfortunately, my view contains more than 2 millions records. I know in SAP HANA Studio, I can put parameters so that I can limit for example by customer and material combination. This should limit the number of records to be displayed. I can expose my view but with large volume or records, it takes a while to process.

Thanks,

Iwan

Former Member
0 Kudos

Hi Iwan,

Check the developer guide on http://help.sap.com/hana/hana_dev_en.pdf

Basically, here is what you do:

In your service definition .xsodata file, add

parameter via entity

to the definition of your odata feed for the view. This will generate an extra parameter structure you can use in your URL. If your .xsodata file was myService.xsodata and the alias for your feed was "myView", then the URL for calling the view with parameter will look like http://myserver:80xx/path/to/myService.xsodata/myViewParameters(KUNNR='12345')/Results

Check it out

--Juergen

iwan_santoso4
Participant
0 Kudos

Juergen,

Thanks for the info. However, i'm unable to activate the service definition file (.xsodata).

I defined the Calculation View using SQL Script Based (the same with graphical too)

When I perform data preview, I got prompted for the input parameter:

The result matched the input entered:

This is how I defined the service file:

And I got error message stating that my view is not calculation view:

Can you spot what I did wrong?

Regards,

Iwan

Former Member
0 Kudos

Hi Iwan,

You are using the DB catalog name, which is in fact a generated db view and not a HANA model. Try the model name instead. So instead of

"_SYS_BIC"."com.isantoso.poc/K004_P"

use

"com.isantoso.poc::K004_P"

Let us know if that helps

--juergen

iwan_santoso4
Participant
0 Kudos

Sweet!!!!! That's fix it! Thanks a bunch, Juergen!

Former Member
0 Kudos

Hey Juergen,

i have a follow-up question about the URL for calling the view. When i perform the data preview, i got prompted for two input parameters: P_DATEFROM and P_DATETO

The definition of my odata service is this:

service {

      "<package::CalculationView>" as "CalcView"

      keys generate local "ID"

      parameters via entity;

}

How would look an example URL for calling this view with both parameters, because this doesn't work?

http://server:port/path/service.xsodata/CalcViewParameters(P_DATEFROM='2012-01-14',P_DATETO='2012-01...?

former_member189009
Active Participant
0 Kudos

Hi Iwan,

    I have the same question like Manu, I have multiple input parameters, how do I wirte my URL ?
because this would fail:

http://server:port/path/service.xsodata/CalcViewParameters(P_DATEFROM='2012-01-14',P_DATETO='2012-01...?

   Thanks!

Answers (3)

Answers (3)

0 Kudos

Hi All,

If we want to modify the value  for create operation in ODATA services, How to do that ?

Can we write our logic in pre exit procedure ?

I was using create using event, But there I have to write insert statement manually.

Will it be possible, i just modify the values and an it get inserted automatically without writing manual insert statement procedure ??

Regards,

Megha

Former Member
0 Kudos

In UI5 when using odata services on Calc views with parameters, we have the foll. Entity sets which are shown as part of the metadata

<EntitySet Name="TOP_N_PRODUCT" EntityType="hana-poc.Top_N_Products_Price.TOP_N_PRODUCTType"/>


<EntitySet Name="TOP_N_PRODUCTParameters" EntityType="hana-poc.Top_N_Products_Price.TOP_N_PRODUCTParametersType"/>

These when used in the browser returns the right results

http://xxxx:8000/hana-poc/Top_N_Products_Price.xsodata/TOP_N_PRODUCTParameters(P_COUNT=5,P_KUNNR='',...

When this odata service is used via SAP UI5, UI5 generates foll queries which are which are incorrect

http://xxxx:8000/hana-poc/Top_N_Products_Price.xsodata/TOP_N_PRODUCTParameters(P_KUNNR='0000100001',...


http://xxxx:8000/hana-poc/Top_N_Products_Price.xsodata/TOP_N_PRODUCTParameters(P_KUNNR='0000100001',...


http://xxxx:8000/hana-poc/Top_N_Products_Price.xsodata/TOP_N_PRODUCTParameters(P_KUNNR='0000100001',...

Please suggest what could be the issue ?

  1. SAP UI5 version
  2. Issues of declaration
Former Member
0 Kudos

i came across the same problem and the solution for me was to remove the following sub string "?$format=json" from the property added to the odata call

oTable.bindRows("/InputParams(STARTTIME=datetime\'2013-05-07 00:00:00.022\',ENDTIME=datetime\'2013-06-06 15:01:41.022\', LOCALE=\'en\')/Results");

instead of

oTable.bindRows("/InputParams(STARTTIME=datetime\'2013-05-07 00:00:00.022\',ENDTIME=datetime\'2013-06-06 15:01:41.022\', LOCALE=\'en\')/Results?$format=json");

Regards

Björn

RonaldKonijnenb
Contributor
0 Kudos

Gents,

Reading up on this stuff for my new blg post. Cant figure out what "service namespace" is. What is it and how do I define it?

Former Member
0 Kudos

Hi Ronald,

check out 's video blog http://www.youtube.com/watch?v=Jfj5StUHnTA

Bottom line: it's not important what you choose as service namespace. I would just recommend to keep it consistent. Maybe Tom can comment on future plans how to use the namespace for structuring XS OData serivces...

cheers

--juergen

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

The namespace isn't used for anything on the providing side in HANA.  Its treated as documentation only.  It might be used by the consumption side depending upon the platform you are consuming from.  Inside SAP we tend use the package hierarchy which the service resides in as the namespace.  This is a techincally enforced rule or anything - just a good best practice.  This makes since because the package hierarchy is the namespace within the HANA repository for the service.

0 Kudos

Hi All,

If we want to modify the value  for create operation in ODATA services, How to do that ?

Can we write our logic in pre exit procedure ?

I was using create using event, But there I have to write insert statement manually.

Will it be possible, i just modify the values and an it get inserted automatically without writing manual insert statement procedure ??

Regards,

Megha

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

It is against forum rules to attach new and unrelated questions to existing threads.  Please open your own new forum post for this question.