Skip to Content

SAPUI5 - SAP Gateway - PUT method (AJAX)

Hi experts,

I'm having a problem when put method is triggered.

What I'm doing is to create records in an Infotype from SAPUI5 so I use an AJAX call as follows:

$.ajaxSetup({

cache: false });

jQuery.ajax({

url: putURL,

async: true,

dataType: 'json',

cache: false,

data: JSON.stringify(data),

contentType: "application/json",

type: "PUT",

beforeSend: function(xhr) {

xhr.setRequestHeader("X-CSRF-Token", token); },

success: function(odata, textStatus, XMLHttpRequest) {

alert("OK");

},

error: function() {

alert("Error Put")

} });

In my case I have to create two records so I send two ajax calls. I am able to create both records in the infotype but the problem come with the response. With the first call the success function is fired without problems but with the second one the status in the console is pending and retrieve a 504 error.

sin-titulo.png

I don't know how to fixed that.

thanks in advance,

Regards.

sin-titulo.png (4.2 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Mar 08, 2017 at 03:30 PM

    Hi,

    in the Network I get this message:

    "<html><head><title>Error report</title></head><body><h1>HTTP Status 504 - An internal application error occurred."

    Answering to Nabi Zamani, I get more than two calls in the backend, in fact, the new entries are recorded correctly in the infotypes, but then I don't get Response.

    I've noticed that this happens when the method is different. So I could send 5 PUT methods without any problem but if then I send a POST/GET method then the gateway error ocurred.

    Thanks.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 06, 2017 at 10:59 AM

    What error are you getting in the Network ?

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 07, 2017 at 08:41 AM

    So you get a timeout... This can have several reasons:

    • your firewall blocks you
    • backend operation take way too long
    • backend operation is buggy, i.e. the is an infinite loop somewhere
    • ...

    Did you implement the backend service on your own in SAP GW? Did you debug the backend? Can you veryify your call gets to the backend?

    Other than that I wonder why you are not using ODataMOdel.update(...) instsead of jQuery.ajax(...). Using the v2.ODataModel would make your code much more maintainable and you would not have to worry things like csrf token, contetnType, etc. But that's a different story...

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 08, 2017 at 03:51 PM

    Hi,

    I have a question.

    I am using oDataModel.update(...) and I am able to send various records in one call. In the backend the function

    ....-CHANGESET_BEGIN is called and I recived a variable IT_CHANGESET_INPUT with all the records. That's the correct perfomance?

    Thanks in advanced.

    Regards.

    Add comment
    10|10000 characters needed characters exceeded