on 11-25-2013 1:02 PM
hello!
I just started using sap netweaver gateway and I am a complete beginner, so please take it slow on me (I am very thankful for useful links).
in transaction SEGW I have a question how I can build a smart solution for creating an entity type which is used to handle my business logic in the backend (erp) and also passing something like a bapiret2 to the frontend (SAP UI5) whether it has passed or failed.
here is a simple example:
I have a small Z table with personnel number (PERSNR), first name, last name and I'm passing via my odata channel the ID (PA0032-WAUSW) and create an entry in this Z table.
So actually I want to tell my frontend something like "Entry created" or "no ID found". How do I model this? My first and I guess wrong thought was to create an entity which has the fields of my Z table + the ID + the BAPIRET2 structure.
I am somehow a bit confused...maybe you can help me clear up my mind?
Thank you very much,
BR,
Dominik
Hi Domonik,
You cannot return BAPIRET2 kind of messages here. But you can return a HTTP status code and message. Following links can be helpfull.
http://scn.sap.com/thread/3343754
Thanks
Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am new to Odata service. I have created one Odata service for Create operation and it is returning success code 201 that means Create operation performed successfully. But in the BAPI for create operation we are getting some return messages like "Created successfully''. But in the Odata service I am not able to get those success return messages.
The messages are stored in some internal output table IT_RETURN that is of type BAPIRET2 in SAP system.
Can anybody help me that how to fetch the return messages in Odata service.
With Regards
Neha Pandey
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Neha,
in this blog is described how you can return Info and Warning messages:
http://scn.sap.com/thread/3470565
Best regards,
Steffen
Hi Dominik,
You have to start thinking a bit differently when using Gateway - but not that much.
Firstly, keep it simple. Why do you need a "message" to tell you that something worked? You expect it to work! In that case, the service will return the proper http response status code (because there is no exception). If you want to give your user a message, do it on the client (UI) side when the response code is received. Don't waste network bandwidth with a redundant message.
On the other hand, if something goes wrong, you probably should send a message. Even if you don't send a message you must raise an exception to enable the Gateway OData processor to detect and return an error response code.
And be assured, if you send something that can't be understood, Gateway will give you back no end of messages
Regards
Ron.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is a a sample code on how to raise exceptions in the Gateway Context.
http://help.sap.com/saphelp_nw74/helpdata/en/f2/a126519eff236ee10000000a445394/content.htm
Hello Krishna!
Thanks for the example which actually works really fine
Unfortunately it doesn't fit exactly my business case because I actually don't really send a "Bad Request" (http 400).
I actually want a http 200 status request AND an error message on the frontend which actually comes from the backend (ABAP method). Something like "The entered values are not correct!"
---edit---
I have found the API for /IWEBP/IF_MESSAGE_CONTAINER with method ADD_MESSAGE_FROM_BAPI which seems to work. The only problem is that in the output XML from the Gateway Test I can't find anything. Do I have to do something apart from adding the message?
Hi Dominik,
You cannot send a Success HTTP Status code as well as an error message. That does not sound logical for me.
You can ignore the HTTP status code right? . Moreover, in the link I mentioned, I see a HTTP status code through which I believe you can influence the Status Code.
In rest protocol,
Successful POST need to return 201 and return the Entity Created. - No message allowed
Successful PUT - 200, and No Content to be returned.
Only failures can return messages.
Thanks
Krishna
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.