Skip to content
Advertisement

SAP UI OData Create does not initialize IT_KEY_TAB parameter

I’m testing oData functinality with SAPUI5.

So far I’ve implemented GET & DELETE which is working fine.

No when I want to add a new Entry I get some problems.

enter image description here

Im sending the Create-Request like this:

var oEntry = {};
oEntry.EmailAdresse = sap.ui.getCore().getElementById("txtemail").getValue();
oEntry.Nachname = sap.ui.getCore().getElementById("txtlastname").getValue();

oModel.create("/Z_ETT_ODATASet", oEntry, function(oData, response){
        alert("Success");
    },
    function(oError){
        alert(oError);
});

This is my Request:

Accept                  application/json
Accept-Encoding         gzip, deflate
Accept-Language         en
Content-Length          54
Content-Type            application/json
Cookie                  ZZZZZZZZ
Host                    XXXXXXXXXXXXXXXXXXXX
MaxDataServiceVersion   2.0
Referer                 http://XXXXXXXXXXXXXXXXXXXX:8007/sap/bc/ui5_ui5/sap/zhelloworld/index.html?sap-client=100&sap-ui-language=EN&sap-ui-xx-devmode=true
User-Agent              Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0
X-CSRF-Token            AAAAAAAAAAAAAAAA==
dataserviceversion      2.0
sap-cancel-on-close     true
sap-contextid-accept    header

Also the data I want to post is mentioned in the request:

{"EmailAdresse":"testemail@test.de","Nachname":"Test"}

When I add an external Breakpoint to my SAP GUI I can see that Z_ETT_ODATASET_CREATE_ENTITY is invoked, but sadly IT_KEY_TAB has no entries.

What is wrong here – where am I losing my data ?

Advertisement

Answer

IT_KEY_TAB is going to give you the keys that are entered in the REST service (for example the key for the entity that you were using for GET or DELETE).

For POST and PUT requests, you want the object that is being sent, which can be retrieved using the io_data_provider->read_entry_data( ) method.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement