cancel
Showing results for 
Search instead for 
Did you mean: 

Batch Processing in Gateway Client Not Working

0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

vivek_gaurav
Participant
0 Kudos

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

0 Kudos

Hi Vivek,

Yes you are right, I am calling the same post URL.

I have to created this Materials in a way, if everything success I have use BAPI commit, if any of material got failed for creation. I have to do rollback.

I will try to use CREATE DEEP INSERT method and try to achieve this requirement.

I haven't used this method yet, I will try .. Please let me know if there is any sample code.

What do you mean by keeping "header part as for rollback and commit ".

Regards

Shaik

EkanshCapgemini
Active Contributor
0 Kudos

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

Answers (1)

Answers (1)

AshwinDutt
Active Contributor
0 Kudos

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

0 Kudos

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.