Odata services

17
When it comes to OData Service development with SAP NetWeaver Gateway a very typical use case is to build a service that is based on an RFC module (or a set of RFC modules) – e! for a "ist # Detail application For such a scenario there are do$ens of RFC modules (%&'s) available in the S&' standard that can be used &nd of course you can also build and consume your own (*)RFC modules if the e+istin! modules don,t satisfy your needs  For additional information re!ardin! the Service %uilder please also see -homas .ei!ens %lo!/ -he new S&' 0etWeaver 1ateway Service %uilder/ %uild new OData Services in 2 3uic4 Steps   n thi s Step-by-s tep Guide we will build an OData Service that consumes two RFC modules from the 5'. (5nterprise 'rocurement .odel) demo content From this 5'. demo content we  pic4 two %&'s that retrieve the list and detail of Sales Orders # "ine tems -he data model is  pretty simple We have one entity for the Sales Order header data6 and one entity for the Sales Order "ine tem -h e two %&' s tha t we wi ll us e in our serv ice ar e/ BAPI_EPM_SO_GET_LIST  and BAPI_EPM_SO_GET_DETAIL -his !uide is based on SAP NetWeaver Gateway 2! SP" We will be mainly usin! the SAP NetWeaver Gateway Servi#e Bui$der  for the service creation -he Service %uilder allows us to  build our service without writin! a sin!le line of code (althou!h you still can d o codin! – if you want7)  n this first part (8) we will build a .eta .odel of the service n the second part (9) we will  perform the service implementation  So let,s !et started 8 Create a new pro:ect %GW&!!_''_SO (SO stands for Sales Order) ;; is :ust a placeholder for a !roup number and 1W8<< indicates the course number – as the screen shots were ta4en from the 1W8<< trainin! course material that have created

Transcript of Odata services

Page 1: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 1/17

When it comes to OData Service development with SAP NetWeaver Gateway a very typical use

case is to build a service that is based on an RFC module (or a set of RFC modules) – e! for a

"ist # Detail application For such a scenario there are do$ens of RFC modules (%&'s) availablein the S&' standard that can be used &nd of course you can also build and consume your own

(*)RFC modules if the e+istin! modules don,t satisfy your needs

 

For additional information re!ardin! the Service %uilder please also see -homas .ei!ens %lo!/

-he new S&' 0etWeaver 1ateway Service %uilder/ %uild new OData Services in 2 3uic4 Steps 

n this Step-by-step Guide we will build an OData Service that consumes two RFC modules

from the 5'. (5nterprise 'rocurement .odel) demo content From this 5'. demo content we

 pic4 two %&'s that retrieve the list and detail of Sales Orders # "ine tems -he data model is

 pretty simple We have one entity for the Sales Order header data6 and one entity for the SalesOrder "ine tem

-he two %&'s that we will use in our service are/ BAPI_EPM_SO_GET_LIST  and

BAPI_EPM_SO_GET_DETAIL

-his !uide is based on SAP NetWeaver Gateway 2! SP" We will be mainly usin! the SAP

NetWeaver Gateway Servi#e Bui$der for the service creation -he Service %uilder allows us to build our service without writin! a sin!le line of code (althou!h you still can do codin! – if you

want7)

 

n this first part (8) we will build a .eta .odel of the service n the second part (9) we will

 perform the service implementation

 

So let,s !et started

8 Create a new pro:ect %GW&!!_''_SO (SO stands for Sales Order) ;; is :ust a placeholder 

for a !roup number and 1W8<< indicates the course number – as the screen shots were ta4enfrom the 1W8<< trainin! course material that have created

Page 2: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 2/17

 

9 Create the first entity by importin! an RFC interface For this ri!ht*clic4 on  Data Model  andchoose Import -> RFC/BOR Interface

Page 3: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 3/17

 

2 5nter the followin! values in the wi$ard and then choose Next /

 

5ntity -ype 0ame Sa$esOrder

-ar!et System L(#a$

Data Source -ype )e*(te +u,#ti(, a$$s

Data Source 0ame BAPI_EPM_SO_GET_LIST

Page 4: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 4/17

 

= 5+pand the SOHEADERDATA node and select the followin! fields/

SOID! NOTE! B"#ERID! B"#ERNAME! C"RRENC#CODE! $ROSSAMO"NT!

 NETAMO"NT! TA%AMO"NT 0ote that SOHEADERDATA is not selected Choose Next 

Page 5: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 5/17

 

> n the first line6 SOID6 select the field I& 'e( and choose F)n)&*/

Page 6: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 6/17

 

? Create the second entity a!ain by importin! an RFC interface Ri!ht*clic4  Data Model and

choose Import -> RFC/BOR Interface

Page 7: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 7/17

 

@ 5nter the followin! values in the wi$ard and choose Next /

 

5ntity -ype 0ame Sa$esOrderIte*

-ar!et System L(#a$

Data Source -ype )e*(te +u,#ti(, a$$s

Data Source 0ame BAPI_EPM_SO_GET_LIST

 

A 5+pand the SOITEMDATA node and select the followin! fields/

SOID! SOITEM+OS! +ROD"CTID! NOTE! C"RRENC#CODE! $ROSSAMO"NT! NETAMO"NT! TA%AMO"NT! ,"ANTIT#! ,"ANTIT#"NIT  0ote that SOITEMDATA is not selected Choose Next 

Page 8: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 8/17

 

B n the first and second line6 SOID! SOITEM+OS 6 select the field I& 'e( and choose F)n)&*/

Page 9: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 9/17

 

 0ow our pro:ect has 9 entities – one for the Sales Order and one for the Sales Order "ine tem

&s a ne+t step we create entity*sets out of these entities

8 5+pand the node Data Model and double*clic4 Ent)t( Set&/

Page 10: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 10/17

 

9 Clic4 the Create button twice to add two new lines to the table/

 

2 5nter the followin! values/

 

Page 11: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 11/17

Na*e E,tity Type Na*e

SalesOrderCollection SalesOrder  

SalesOrdertemCollection SalesOrdertem

 

= Choose Sae/

 0ow the basic definition of the .odel is done &s a ne+t step we can !enerate the necessary

runtime artifacts

8 Choose the $enerate pushbutton/

Page 12: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 12/17

 

9 "eave the default values and choose Enter /

Page 13: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 13/17

'lease note the -echnical Service 0ame .$011%%SOSR2 is eual to the 5+ternal Service

 0ame reuired to consume this service later on

 

2 Choose 3ocal O45ect /

 

= erify that the runtime ob:ects have been !enerated successfully/

 

Page 14: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 14/17

 

 0ow we can Re!ister and &ctivate the Service

 

8 Double*clic4 Ser)ce Ma)ntenance/

 

9 Select system .5 and choose the Re6)&ter button 'lease note that the entries listed here

depend on the System &lias confi!uration you have done in the S&' 0etWeaver 1atewaymplementation 1uide (.1) n a local deployed environment (%ac4end and Eub components

deployed on the same bo+) you mi!ht also find "OC&"G with the RFC destination 0O05G

here

 

2 Confirm the warnin! messa!e displayed in the popup/

Page 15: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 15/17

 

= 'ress F= to select the system alias Select ER+EMEA from the input help 'lease note that

you won,t !et any popup if there is only 8 System &lias maintained &s mentioned above6dependin! on the deployment method and .1 confi!uration you possibly see an alias

"OC&"G instead of the ones shown in the screen shot/

 

> Confirm the Select S(&tem Al)a& popup/

Page 16: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 16/17

 

? "eave the default values and enter 7tmp as the pac4a!e and choose Enter /

 

-he External Ser)ce Name is defaulted with the Tec*n)cal Ser)ce Name from the 1eneration

Step

 

@ erify that the service has been re!istered and activated successfully/

Page 17: Odata services

7/23/2019 Odata services

http://slidepdf.com/reader/full/odata-services 17/17

 

 0ow we can run our service the first time 'lease note that we,ve only maintained the basic

model data so far &s a conseuence we can access the metadata of the service6 but not yet any business data (that will come in part 9)

 

8 Open a new window6 start transaction .IW+ND.GW_LIENT

9 5nter HR/ .sap.(pu.(data.sap.%GW&!!_''_SO_S)/.0*etadata  and choose 5+ecute/