OData and SAP Netweaver Gateway. Part V. CRUD Operations in OData Services

What is CRUD Operation?

As of now in our tutorial series, we have explored the GET Operation involving READ_ENTITY and READ_ENTITYSET methods. GET is used for pulling information and displaying. GET or READ Method is the “R” of the popular “CRUD” Operations. Others being Create, Update and Delete. In this article, we would concentrate on writing to the database using POST and PUT operations and remove entries using DELETE operation. We would be creating, updating and deleting entries in the database. And the Guinea pig remains the same, i.e. ZEKKOEKPO table.

A. POST Operation

As the name suggests, it is mainly used for creating new entries. For our stand-alone test, we cannot directly choose POST Operation and execute the URI. POST Operation is a two steps process in t-code /n/IWFND/GW_CLIENT. We need to first prepare the request string using GET Operation and then use the string to POST data.

i. Execute GET Operation with “Use as Request” option
URI: /sap/opu/odata/sap/ZGW_PO_SRV/zekkoekpoSet(Ebeln=’4580000990′,Ebelp=’00001′)

Use as Request

ii. Execute the POST operation

CRUD in OData Services

Oops, you get an error.

SAP Netweaver Gateway and oData Tutorial

What did you think? Can you execute the POST operation without writing any code? It is not magic even though ABAPers are magicians. 🙂

We still have two activities to perform.
i. Redefine CREATE_ENTITY method
ii. Call the POST Operation with correct URI

Let us redefine the method and write simple ABAP code to insert entries in the custom table. If you do not know how to re-define the Data Provider Class method, please refer to our earlier post: Create your first OData Service.


Before we execute the POST Operation, let us confirm there is no entry in the custom table.

SAP Odata

Put an external breakpoint on the CREATE_ENTITY Method to prove that it is triggered while executing POST operation.

the POST Operation

Let us execute the POST-Operation again.

URI: /sap/opu/odata/sap/ZGW_PO_SRV/zekkoekpoSet(Ebeln=’4580000990′,Ebelp=’00001′)

You get the same error “Method Not Allowed”.


Did you mark; our action did not stop at the breakpoint. What does it mean? It means the method was not triggered at all and the URI is not the correct one.

Scroll up and check, we specifically said: “Call the POST Operation with correct URI”. So the correct URI to POST is: /sap/opu/odata/sap/ZGW_PO_SRV/zekkoekpoSet


Finally, the Method is triggered and the debugger stops at the break point.

Check the status is “Created”.


Let us validate if the entry is really populated in the custom table.

Yes!! It is.

Congrats, you just did a POST Operation in OData Service. Remember the above steps and URI options. We would need them when we consume these URIs in our SAPUI5 Applications (SAPUI5 Tutorial series to be commenced soon).

Did you take notice, there is only CREATE_ENTITY Method? No CREATE_ENTITYSET Method. Does it mean we can create just one row at a time? Absolutely not. You can always pull multiple entries and post into the database.

Also Read: ABAP Development for SAP HANA Tutorial Series.

B. PUT Operation

While POST is to create entries, PUT Operation is to update/modify existing entries. Like POST Operation, PUT also has two steps. Execute GET Operation with the option “Use as Request” and then execute the real PUT Operation.

URI: /sap/opu/odata/sap/ZGW_PO_SRV/zekkoekpoSet(Ebeln=’4580000990′,Ebelp=’00001′)

Once we have the Request, let us execute the PUT Operation.

Were you expecting to update the table without writing any code? My friend, who will implement the Update_Entity Method? 🙂

PUT Operation

URI: /sap/opu/odata/sap/ZGW_PO_SRV/zekkoekpoSet(Ebeln=’4580000990′,Ebelp=’00001′)

Let us pass the URI to update the MENGE value of the entry which we created above.

Check we have changed the MENGE value to 14 from 7 in the Request String which would be passed to PUT Operation.

Request String in PUT

Let us execute.

The status looks green. But the text says, “No Content”. I am sure, you are as confused as me. What really happened?

No Content

When I go the table, it shows the entry was successfully updated. All is well that ends well. The status code for correct Update is ‘204’. So we are good.

Hopefully, this was enough demonstration of PUT/UPDATE Operation. If you still have doubt, just put a breakpoint at the UPDATE_ENTITY method and understand the flow. If your method is not triggered, it means your URI is incorrect. Keep this as your homework. Debug PUT Operation.

C. DELETE Operation

For DELETE we do not need to execute GET and Use as Request. We just need to pass the right URI with correct options.

Let us delete the same entry which we created and modified above.

URI: /sap/opu/odata/sap/ZGW_PO_SRV/zekkoekpoSet(Ebeln=’4580000990′,Ebelp=’00001′)

modify using OData service

We have missed it the third time today. Remember, if we want to execute any Operation, the corresponding Method has to be redefined and implemented. Hopefully, in your real project, you would not miss it.

Let us redefine and implement the DELETE_ENTITY Method.


Put an external break point and execute the DELETE Operation.


Check the status. It is Green with the message ‘No Content’.

DELETE OData Service

The message text is a little misnomer, but this time I am not worried. I know it worked as the message code is green and the method triggered. Let us validate it.

The only entry present in the table ZEKKOEKPO has been deleted. So our DELETE Operation has executed successfully.

PS: There are two other Operations viz PATCH and MERGE. You might want to check them separately.

Hope you have a fair idea about CRUD operations now. In real work, the logic to read, edit and parse would be more complex depending on the business needs. But the fundamentals would remain the same. The corresponding methods you need to re-define and implement would remain the same. So be confident!! You can handle CRUD features of the any OData Service, however crude it might be. 😀

This is all about SAP Netweaver Gateway basics and OData fundamentals. In the next post, we would summarize whatever we have learned and understood till now. We will talk about common terminologies and jargons used in SAP OData and Netweaver Gateway meetings. Thereafter, we would jump into consuming these OData Service in our SAPUI5 Applications.

If you GENUINELY like our articles then it would be a HUGE help if you subscribed and liked us on facebook. It might seem insignificant, but it helps more than you might think.

Do you have anything to add to this article? Have you faced any issue understanding OData or SAP Netweaver Gateway? Do you want to share any real project requirement or solutions? Please do not hold back. Please leave your thoughts in the comment section.

Thank you very much for your time!!

Call for Guest Authors and Contributors to write SAP Articles on our page and get noticed and also receive cool Gifts.

Do you have any tips or tricks to share? Do you want to write some articles at SAPYard? Please REGISTER and start posting and sharing your knowledge to the SAP world and get connected to your readers. Please check our simple guidelines for contributing your articles and receiving the gifts.

Step by Step Tutorials on SAP Netweaver Gateway and OData

Also, Check Step by Step Tutorials on SAPUI5

We have a very active Telegram SAP Technical Group. Please join it using below link.
Telegram SAP Technical Discuss Group.

WhatsApp had the limitation of 256 members per group and we were finding a hard time syncing and maintaining information in multiple WhatsApp group. Therefore we have moved to Telegram as it can accommodate more than 10,000 users. Please join.


    • Thank you Shigufta for visiting our page. SAPYard tries to post articles thinking freshers in mind. So our articles are very elaborate with generous screenshots.

      We are glad you liked it. Please keep visiting. Please share our links with your team members, friends and colleagues.

      Team SAPYard.

  1. Hi Team,

    Just wanted to know can we use FILTER(t use optional fields) in query for PUT operation?
    When I am trying getting error as “The specified HTTP method is not allowed for the resource identified by the Data Service Request URI”

    But, if we go with only key fields in URL it works fine.

    Tejas Shah

  2. OData services are meant for consumption by browser based applications,mobile devices,Enterprise Software,consumer devices etc.
    Odata is a lightweight Web protocol for querying and updating data, applying and building on Web technologies such as HTTP, Atom Publishing Protocol (AtomPub), and RSS (Really Simple Syndication) to provide access to information from a variety of backend applications including SAP(on-premise) and cloud(XSOData).
    The consumer connects directly(or indirectly) to the system for the service call from a frontend consumer application at realtime and hence it is not something that gets published anywhere.
    Also it is stateless(although there are ways to defy this attribute but not meant to as per the REST PROTOCOL) hence does not store anything and is a to and fro communication of information through service calls.
    Hope this helps Kuldip’s query.

    Arkajeet Dasgupta

  3. Hi Raju, can you please explain how can we published this webservice for public what are the things which require to make web service publish on internet.


Please enter your comment!
Please enter your name here