Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
laxmi_jibhe
Explorer
Hello,

 

While creating Odata services, I had gone through multiple blogs post and found that there are few steps which are not self explanatory and hence at the end of creating an odata service we get bad HTTP response . This is mainly due to missing explanation for how to load meta data and how to test the entity set data .

In this blog post, I am going to tell you step by step process to create Odata services for SAP /SAP HANA system and how to test it.

I tried to explain the whole process in 4 steps.

Step 1. Go to transaction code - SEGW .


Click on Icon Create. A pop window will appear , Fill the details as per below mention in screen shot and click on check icon or enter.


 

Below screen will appear where you can see below folder in project. In Folder data model, we can see three sub folders. Entity Type - it acts as work area , Entity Sets -It act as internal table and associations.



 

Now we are going to define structure of work area and internal table , Right click on Data model select import and select DDIC structure .


 

Here give the details of structure and structure name as per below screen below.

Select radio button Entity type and and click on check box entity set. fill ABAP structure as VBAK and click on next


Now you will get the pop up screen with VBAK table fields name. Select fields for your structure and click on next.


project5


Other window will appear where we have to select the key field. tick on Vbeln as key field and click on finish. You may get warning message , it can be totally ignored.


Now expand folder entity type and fill the below parameters in properties , Please don't tick Null check box for VBELN as it is key field.



Similarly Create Structure for SD Item following same steps





click on Save button at the top of menu bar

Now click on generate Icon, A pop up window will appear with class details , click on tick icon and proceed further. It will ask for package , give details and proceed further . These are also knowns as runtime artifacts.


 

Step 2. Go to transaction code /IWFND/MAINT_SERVICE .

Click on push button Add services .


 

Next screen will appear, give the alias name and execute , Search you for your project .


Now double click on your project name . A pop up window will appear , enter the package details and click on tick icon. An Information message will be shown where it will confirm about the service is created and metadata loaded successfully



 

Now click back and go to main screen of transaction /IWFND/MAINT_SERVICE and find your service.

Click on SAP Gateway Client

 


 

A new screen will come, Execute the transaction and check the response .


 

Now we will write code to get data.

Step 3. Go to transaction code SEGW and expand folder service Implementation  .

Under service implementation - Expand SDheaderSet. you will find different options. Right click on GetEntitySet and select GO to ABAP work Bench . It will redirect to the class


 

Now expand the method drop down and select method for GetEntitySet for Header data and right click and select redefine.


 

Write below code in method. Save and activate all related objects for classes.


Similarly , Write code for GetEntitySet for Item and activate .


 

Step -4

Go to transaction /IWFND/MAINT_SERVICE and find out you service , select your service and click on load metadata.


Information message will pop up - Metadata has been loaded successfully.

 

Now Click on SAP Gateway Client .


 

Now Click on Entity set.


 

Select entity for header and enter


Click and execute and you will get the header data in response


 

Similarly, Select entity set for item and execute . You will get data for item


 

Here , We had completed our Odata service creation with a Service Builder Project with two entities and two entity-sets. We have generated the runtime artifacts and registered and activated our OData service. We had redefined methods of header and item entity set , load metadata and test the entity set with for test data.

Thanks
24 Comments
gowripujithakapu
Discoverer
0 Kudos
Hi Laxmi,

While adding a service in /IWFND/MAINT_SERVICE,Iam getting an error "System alias 'LOCAL' does not exist".Please help me out if any necessary configuration is missed out.
laxmi_jibhe
Explorer
0 Kudos
Hi Gowri,

System Alias need to be maintained, Please check if System Alias is created in your system if not then maintain as per below

SPRO -> SAP Gateway -> Odata channel -> Connection Settings -> SAP Gateway to SAP System -> Manage SAP System Aliases

Once the system alias is created, Maintain that for your odata service in  /IWFND/MAINT_SERVICE. In Transaction   /IWFND/MAINT_SERVICE , Select your Odata service and click on below Pushbutton on screen which you can see in right bottom window.


Thanks
0 Kudos
Hi Laxmi,

I don't know whether the article is related to my problem or not, but after i did all steps above i want to connect SAP Analytics Cloud (SAC) to my odata service. When i create new connection using odata service connection, i have an error "the user does not have permission to access the requested resource".

Is it any step that i missing or need more config? Can you help me please?

 

Thank you.
PRAGSMATIC
Participant
0 Kudos
have you enabled ODATA service via transaction SICF ?
laxmi_jibhe
Explorer
0 Kudos
Hi Anurag,

Yes, we can enable OData service via SICF transaction .

Thanks
0 Kudos
Wonderful Explanation. Thanks Ma'am
0 Kudos
THANKS.......
0 Kudos
Hi Laxmi,

Very good document for beginners. Thanks.

 

Regards,

Soujanya
Miloš_Volek
Explorer
0 Kudos
Thanks for sharing! Its very well written, detailed information.
aqibpathan
Participant
0 Kudos
Hi!

Excellent blog to begin with! Keep it up

Regards,

AQIB
0 Kudos

Indeed, Great Job! Happy to see your blog. Keep it up !.

0 Kudos
Good one!
mkrsap_ten
Explorer
0 Kudos
Hi,

 

I'm getting below error while trying to execute headerSet. Any idea please ? I have followed all the mentioned steps in the blog.

 

glauco
Active Contributor
0 Kudos
Hi.

Probably you must redo this step: redefine method GetEntitySet.
P2004656809
Explorer
0 Kudos
Hello Mani,

 

I have also faced the same issue, but it got resolved -

Click on activate, after the method is re-defined

xiswanto
Active Participant
0 Kudos

Hello laxmi,

 

overall this tutorial is very easy to understand, although I'm curious about one part ( regarding the behavior of Odata method sequence 😞

  • upon executing the URI, from the SAP NetWeaver Gateway Client from your example below for Header, it seems to automatically run the method get_entityset ( or is it get_entity) and return the correspondence value

so question is: what if I wanted to test the create / update / delete method, how do I actually change the URI to test the other method? is it possible to do so in SAP environment or doable in external system environment (such as Postman, etc)

 

Regards,

 

Siswanto

 

*Update: I've understood that to call other method ( update / create / delete ) is based on the http Method ( POST, PUT, DELETE ),
only one question left: how do I test the Odata service from out of SAP, do I use Postman based on the URI given in the gateway client screen, or is there other usable software?

HemantVaswani
Explorer
0 Kudos
Hi All,

Can you help me understand , after loading the metadata, when i attempt to click on "SAP Gateway Client " button, the click is acknowledged but the new window as seen in this blog is not appearing at all, what could be the reason.


after click on the button none screen pops up i tried click on Call Browser but nothing happens I am using SAP GUI 770 Ver Windows

uday_gubbala2
Active Contributor
You can refer to Jan's blog https://blogs.sap.com/2020/11/24/introduction-to-odata-and-how-to-implement-them-in-abap/ where he has described as to how to execute ODATA operations via POSTMAN
syedijlalayub
Explorer
0 Kudos

Hi laxmi.jibhe

I hope you're alright.
I followed all your steps for a ztable but I recieved 404 Not Found in SAP Gateway Client. The service is activated in SICF. I should mention that I recieve 404 on default odata services too. The only http services that are working are from the node /sap/public/, including /sap/public/ping. But odata service and other default services are 404 including my own odata services 


I'm using ABAP Platform Trial 1909 SP07
Below is what I did for my ztable ZEmployee with ZST_EMPLOYEE struct

please help!!

syedijlalayub
Explorer
0 Kudos
Hi everyone,

I resolved my problem.

Incase anyone else faces it; I had set profile parameter is/HTTP/virt_host_0 (default_host) manually. This parameter should not be changed since it is used for default_host (odata service comes in default_host node). I removed the parameter (tcode rz10) and restarted abap system and now everything is good.

Thanks & regards,
Sycntegral
Active Participant
0 Kudos

 

Hi laxmi.jibhe

Please join our session where we will show how to expose standard SAP S4HANA tables to SAP Cloud Analytics

https://groups.community.sap.com/t5/sap-community/sap-community-series-introducing-our-sap-demojam-f...

You could also ask me directly https://www.linkedin.com/in/eddiemogilevsky/

gabriel_redware
Explorer
0 Kudos

Aprecciate your explanation. help me a lot!!!

Ganesan_K20
Discoverer
0 Kudos

Its a great explanation for the beginners. appreciate your efforts..

hsonnenahalli
Contributor
0 Kudos

What would be the rate-limiting and throttling settings for custom Odata API? We are facing issues with these parameters. Please suggest.

 

Regards

 

HS