Skip to Content
avatar image
Former Member

Post a table/multiple lines to SAP via SAP Gateway from external server

Hi,

I know there are many posts on the same topic but the problem we're facing is that we're using the exact same format for processing batch operations but still the data is not posted. Is there anything amiss?

Issue: We're not able to POST multiple lines from our web application server to SAP in one go via SAP gateway service.

Methods tried so far:

1. Currently, we're posting by calling the POST RFC gateway URL in a loop and posting the multiple lines one by one in each call. This method is working and posting the data in SAP but it is definitely not the efficient method to achieve the same.

Problem: Not efficient.

2. We tried to post the data in JSON format, which is acceptable format by SAP gateway service. But the data is not posted through and results in error.

Problem: Data not posted.

3. In the final method, we're posting the data in JSON format only, but we're trying to post in batch format. In this method, for posting each line, we're preparing the request body and request header but the problem we're facing is that it is not posting all the lines in SAP. Default, only one CHANGESET operation can be processed and even after redefining methods as described in this blog to allow multiple CHANGESET processing, we're getting errors.

Problem: Only one operation allowed to post.

Sample Request body:

In the attached file.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Feb 23 at 07:55 AM

    Try specifying the changeset keys to let the framework know that a single changeset is getting processed. Make a payload as below

    --batch_206a-6c8e-c4e9
    Content-Type: multipart/mixed; boundary=changeset_b938-88a2-fec5
     
    --changeset_b938-88a2-fec5
    Content-Type: application/http
    Content-Transfer-Encoding: binary
     
    POST ZVENDOR_RECONCILESet HTTP/1.1
    sap-contextid-accept: header
    Accept: application/json
    x-csrf-token: V1lGA6EihdJ8ji37XVM21A==
    Accept-Language: en-US
    DataServiceVersion: 2.0
    MaxDataServiceVersion: 2.0
    sap-cancel-on-close: true
    Content-Type: application/json
    
       {"Xblnr":"5100000004",
        "Ebeln":"4500000003"
       } 
    
    --changeset_b938-88a2-fec5
    Content-Type: application/http
    Content-Transfer-Encoding: binary
     
    POST ZVENDOR_RECONCILESet HTTP/1.1
    sap-contextid-accept: header
    Accept: application/json
    x-csrf-token: V1lGA6EihdJ8ji37XVM21A==
    Accept-Language: en-US
    DataServiceVersion: 2.0
    MaxDataServiceVersion: 2.0
    sap-cancel-on-close: true
    Content-Type: application/json
    
       {"Xblnr":"5100000005",
        "Ebeln":"4500000003"
       } 
    
    --changeset_b938-88a2-fec5
    Content-Type: application/http
    Content-Transfer-Encoding: binary
     
    POST ZVENDOR_RECONCILESet HTTP/1.1
    sap-contextid-accept: header
    Accept: application/json
    x-csrf-token: V1lGA6EihdJ8ji37XVM21A==
    Accept-Language: en-US
    DataServiceVersion: 2.0
    MaxDataServiceVersion: 2.0
    sap-cancel-on-close: true
    Content-Type: application/json
    
       {"Xblnr":"5100000006",
        "Ebeln":"4500000003"
       } 
     
    --changeset_b938-88a2-fec5-- 
    --batch_206a-6c8e-c4e9--
    

    After that, put breakpoints in Changeset_Begin, Create Entity and Changeset End and trace the program flow.

    Add comment
    10|10000 characters needed characters exceeded