Skip to Content

Batch Processing in Gateway Client Not Working

Hi Team,

I have re-defined the methods Change Begin set and Change end set methods.

When I executed the Gateway, I am able to see the Status 202 after execution. But the data is not getting created.

When I am executing the service without batch, Its working perfectly. Please let me know after status 202, is there any process I have to do to execute the service.

I have a requirement, after successful execution of all Materials creation in a batch I have to call Commit or Roll back.

Let me know where can i call the BAPI COMMIT or BAPI Roll back.

If any of material fail, nothing has to be created. I have to allow only if every thing is success.

Please let me know what I am missing and let me know what else I have to do to achieve this requirement.

Batch Code:

--batch

Content-Type: multipart/mixed; boundary=changeset

--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary

POST Variant_createSet HTTP/1.1

Content-Type: application/atom+xml

Content-Length: 588

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<entry xml:base="http://sxxxh1pute01.hightest.awstest.net:8001/sap/opu/odata/sap/ZXXX_TESTKPIT_SRV/"

xmlns="http://www.w3.org/2005/Atom"

xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"

xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">

<id>http://sxxxh1pute01.hightest.awstest.net:8001/sap/opu/odata/sap/ZXXX_TESTKPIT_SRV/Variant_createSet</id>

<title type="text">Variant_createSet</title>

<category term="ZXXX_TESTKPIT_SRV.Variant_create" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>

<link href="Variant_createSet" rel="self" title="Variant_create"/>

<content type="application/xml">

<m:properties>

<d:Matnr>1758848</d:Matnr>

<d:Satnr>1758848</d:Satnr>

<d:Charprof>Z005</d:Charprof>

<d:Char_name>Z032</d:Char_name>

<d:Char_value>38</d:Char_value>

</m:properties>

</content>

</entry>

--changeset

Content-Type: application/http

Content-Transfer-Encoding: binary

POST Variant_createSet HTTP/1.1

Content-Type: application/atom+xml

Content-Length: 588

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<entry xml:base="http://sxxxh1pute01.hightest.awstest.net:8001/sap/opu/odata/sap/ZXXX_TESTKPIT_SRV/"

xmlns="http://www.w3.org/2005/Atom"

xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"

xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">

<id>http://sxxxh1pute01.hightest.awstest.net:8001/sap/opu/odata/sap/ZXXX_TESTKPIT_SRV/Variant_createSet</id>

<title type="text">Variant_createSet</title>

<category term="ZXXX_TESTKPIT_SRV.Variant_create" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>

<link href="Variant_createSet" rel="self" title="Variant_create"/>

<content type="application/xml">

<m:properties>

<d:Matnr>1758848</d:Matnr>

<d:Satnr>1758848</d:Satnr>

<d:Charprof>Z005</d:Charprof>

<d:Char_name>Z032</d:Char_name>

<d:Char_value>37</d:Char_value>

</m:properties>

</content>

</entry>

--batch--

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jan 11, 2016 at 06:18 AM

    Hi Shaik,

    From your above Batch request, I can understand that you are calling same post URL for each material in batch. For this all service are separate and will get committed and rollback individually.

    I can give one work around that, You do one thing that you create a single service with create deep insert and keep all material XML as details part and keep header part as for rollback and commit purpose.

    In this way you can use COMMIT WORK in CREATE DEEP INSERT method itself .

    something like this..

    Loop at Material Docs. "For every material document

    If success. "sales order was created but not yet written to database

    <CALL CREATE BAPI FOR MATERIAL>

    If success. "material was created but not yet written to database

    Commit Work. "or use FM BAPI_TRANSACTION_COMMIT

    else. "failed to create material

    Rollback Work.

    endif.

    Endif.

    Endloop.

    Regards

    Vivek

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      You can go ahead with create_deep_entity method as a workaround. This method is used for creating a resource which has navigation property e.g. Purchase Order. This method is triggered only if any navigation property is mentioned in the payload. In order to achieve this, you can create a dummy entity and then create an association of dummy to your entityset with navigation property in dummy. This way you will be able to receive a internal table of your desired entity inside deep structure of dummy set. Now you can pass this whole internal table to your backend FM and then decide to commit and rollback there on. This will certainly have a performance benefit as compared to the normal batch requests.

      There is another interesting feature in batch calls i.e. changeset at once. You can check this link and the sample code in SFLIGHT example service.

      http://scn.sap.com/docs/DOC-57113

      Regards,

      Ekansh

  • Posted on Jan 11, 2016 at 05:33 AM

    Hello Shaik,

    I see a ' --changeset-- ' is missed at the last.

    Try with the below payload.

    --batch

    Content-Type: multipart/mixed; boundary=changeset

    --changeset

    Content-Type: application/http

    Content-Transfer-Encoding: binary

    POST Variant_createSet HTTP/1.1

    Content-Type: application/atom+xml

    Content-Length: 588

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>

    <entry xml:base="http://sxxxh1pute01.hightest.awstest.net:8001/sap/opu/odata/sap/ZXXX_TESTKPIT_SRV/"

    xmlns="http://www.w3.org/2005/Atom"

    xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"

    xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">

    <id>http://sxxxh1pute01.hightest.awstest.net:8001/sap/opu/odata/sap/ZXXX_TESTKPIT_SRV/Variant_createSet</id>

    <title type="text">Variant_createSet</title>

    <category term="ZXXX_TESTKPIT_SRV.Variant_create" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>

    <link href="Variant_createSet" rel="self" title="Variant_create"/>

    <content type="application/xml">

    <m:properties>

    <d:Matnr>1758848</d:Matnr>

    <d:Satnr>1758848</d:Satnr>

    <d:Charprof>Z005</d:Charprof>

    <d:Char_name>Z032</d:Char_name>

    <d:Char_value>38</d:Char_value>

    </m:properties>

    </content>

    </entry>

    --changeset

    Content-Type: application/http

    Content-Transfer-Encoding: binary

    POST Variant_createSet HTTP/1.1

    Content-Type: application/atom+xml

    Content-Length: 588

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>

    <entry xml:base="http://sxxxh1pute01.hightest.awstest.net:8001/sap/opu/odata/sap/ZXXX_TESTKPIT_SRV/"

    xmlns="http://www.w3.org/2005/Atom"

    xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"

    xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">

    <id>http://sxxxh1pute01.hightest.awstest.net:8001/sap/opu/odata/sap/ZXXX_TESTKPIT_SRV/Variant_createSet</id>

    <title type="text">Variant_createSet</title>

    <category term="ZXXX_TESTKPIT_SRV.Variant_create" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>

    <link href="Variant_createSet" rel="self" title="Variant_create"/>

    <content type="application/xml">

    <m:properties>

    <d:Matnr>1758848</d:Matnr>

    <d:Satnr>1758848</d:Satnr>

    <d:Charprof>Z005</d:Charprof>

    <d:Char_name>Z032</d:Char_name>

    <d:Char_value>37</d:Char_value>

    </m:properties>

    </content>

    </entry>

    --changeset--

    --batch--

    More information for Explicit commit or roll back is here ->

    $batch Processing - SAP NetWeaver Gateway - SAP Library

    Regards,

    Ashwin

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Ashwin,

      Now its working, but I am facing an issue with the below commit.

      in form Commit work mv_changeset_optotal, I am getting my number of records.

      when I execute the above pay load the value will be 2. so its raising an dump.

      FORM commit_check .

      * Commit Work is allowed for anyone of the following cases:
      * - no ChangeSet
      * - only one operation in Changeset
      * - during CHANGESET_END
      IF mv_changeset_optotal = 1 OR
      mv_changeset_processing <> abap_true OR
      mv_changeset_end_processing = abap_true.
      EXIT.
      ENDIF.

      MESSAGE x051(/iwbep/cm_mgw_rt).

      ENDFORM.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.