Skip to Content
Author's profile photo Nagesh A

Detailed step by step procedure for Creating Gateway Service with all the CRUD Operations and testing them in Service Explorer Part2

In the first part Detailed step by step procedure for Creating Gateway Service with all the CRUD Operations and testing them in Service Explorer Part1

I discussed the the below topic.

1.Create service in Gateway system with all the CRUD operations.(Create Read Update Delete).


Before starting, I am expecting that you are able to create gateway service or you have gone through my previous blog.In this blog i will discuss about maintaining our service and testing it in ServiceExplorer.

Our Service Name: ZBPS_MATR_DEMO_SRV.

Now we need to Activate and Maintain our service, we will do that in transaction /IWFND/MAINT_SERVICE.

     a. First we need to locate and add our service. Click on add service button.

b. Now we need to add System alias to our service, i.e. systems with which we are going to interact.

Click on Execute to get Service Document .

Now we will get our service Meta data.

Service Metadata Document (Metadata Document): Describes the data model (i.e. structure and organization of all the resources) exposed as HTTP endpoints by an OData service.

Check the Service Meta data.

Now we will test all the CRUD operations.


READ:

Here in URI we can pass values for key fields only.

In our example we are trying to READ Material ‘000000000000000023’ and we will do that in Gateway client.

URI: http:// <hostname>:<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/matrset(‘000000000000000023’)

Paste this URI against Request URI field in Gateway client and select HTTP Method GET and click on execute.

Output:

      

We will get same XML in HTTP Request Body. Make require changes in that for Material creation. Here we need to select HTTP Method POST for CREATE operation and we need to change URI as below.

URI:

http:// <hostname>:<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/matrset

UPDATE: Now we will try to UPDATE the Material just we have created through CREATE operation.

Do the same steps as in create operation, first read the Material ‘000000000000000016’ through READ operation and by using that xml as a Request we will try to UPDATE Material Group of that Material.

URI: http:// <hostname>:<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/matrset(‘000000000000000016’)

Here MatlGroup is 00108, we will update that to 00107 and we will verify it through READ operation.

Click on Use as Request and make the necessary changes to the XML as below and select the HTTP Method PUT for Updating and click on execute.

Xml:

<?xml version=“1.0” encoding=“utf-8”?>
<entry xml:base=
http:// <hostname>:<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/” xmlns=http://www.w3.org/2005/Atomxmlns:m=http://schemas.microsoft.com/ado/2007/08/dataservices/metadataxmlns:d=http://schemas.microsoft.com/ado/2007/08/dataservices>
<content type=
“application/xml”>
<m:properties>
<d:BaseUom>EA</d:BaseUom>
<d:MatlGroup>00107</d:MatlGroup>
<d:BasicView>X</d:BasicView>
<d:MatlType>ROH</d:MatlType>
<d:IndSector>1</d:IndSector>
<d:Material>000000000000000016</d:Material>
<d:MatlDesc>Test material gateway</d:MatlDesc>
<d:LanguIso>EN</d:LanguIso>
<d:Langu>E</d:Langu>
</m:properties>
</content>
</entry>

DELETE:

Now we will try to DELETE the Material which we have created, for this we use HTTP method DELETE.

Here to delete the Material we will just set the Delete Flag to ‘X’. First we will read that material and using that xml as a request we will process Delete operation. Here we will select HTTP method DELETE and execute it after modifying xml.

XML:

<?xml version=“1.0” encoding=“utf-8”?>
<entry xml:base=
http:// <hostname>:<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/” xmlns=http://www.w3.org/2005/Atomxmlns:m=http://schemas.microsoft.com/ado/2007/08/dataservices/metadataxmlns:d=http://schemas.microsoft.com/ado/2007/08/dataservices>
<content type=
“application/xml”>
<m:properties>
<d:MatlGroup>00107</d:MatlGroup>
<d:Material>000000000000000019</d:Material>
<d:DelFlag>X</d:DelFlag>
</m:properties>
</content>
</entry>

With this we have completed all the CRUD operations.

Assigned Tags

      17 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jitendra Kansal
      Jitendra Kansal

      great.. i will try this.. thanks for sharing

      Author's profile photo Naga Satish Kumar Sudani
      Naga Satish Kumar Sudani

      Good Work..........

      Author's profile photo Former Member
      Former Member

      Very Useful Stuff. I proceeded same way to test Material Master & it almost worked well.

      But I have an issue when I execute the QUERY operation. I get the Status Code as 200, which is OK; but materials are not listed in the output.

      Any idea about why is it happening..??

      One point to be noted:

      Query in the thread goes like this:

      ?$filter=Material ge '000000000000000023' and Material le '000000000000000053'

      It is giving technical issue for me. So, I am using 'E' in place of sign '='.

      Author's profile photo Vishnu Pankajakshan
      Vishnu Pankajakshan

      Hi Nagesh,

      I tried all the above steps and its working fine.I tried another method by redefining DPC_EXT and MPC_EXT and i used a custom functional module with TABLE's as input and output.I passed my input through XML payload in gateway client.I am not sure whether the method i used is proper or not.And i also would like to know a method to do the same thing using GPA.

      regards,

      Vishnu

      Author's profile photo spandana N
      spandana N

      Hi Nagesh,

         Thank you very much for the  stuff.  i have  followed the same scenario it is working fine  in development system  but i was getting problem in Quality system with RFC .

      Failed to connect using the specified RFC destination .

      Example :

      i have created  project in SEGW tool in SAP Net weaver Gateway  in Development system with  rfc destination  (DEV_100) and moved to quality system , but the rfc destination DEV_100 is not there  in Quality system . and getting error  as

      'Failed to connect using RFC destination DEV_100'.  How can i resolve this issues ...

      Failed to connect using the specified RFC destination .

      do i  manually  create the mapping  again  with giving the new rfc in Quality system ? Please suggest .

      Author's profile photo Nagesh A
      Nagesh A
      Blog Post Author

      Hi,

      I think you need to add the new system in transaction /IWFND/MAINT_SERVICE as mentioned in the document.


      Thanks

      Nageswar

      Author's profile photo spandana N
      spandana N

      Hi Nageswar ,

        i have already added the  new system as alias  eventhough getting the same error

      "Failed to connect using RFC destination DEV_100".

      Author's profile photo Former Member
      Former Member

      Hi,

      It's Perfectly working in tables....please anyone say me how can i work with structure or fields...I got 'No Output Table is Mapped in the query operation' error....

      Thank you.

      Author's profile photo Vishnu Pankajakshan
      Vishnu Pankajakshan

      Hi Nagesh,

      In Create can we have an internal table(Multiple rows) as input if my FM have internal table as input.

      (I used to do create deep entity for multiple rows as input).

      Regards,

      Vishnu

      Author's profile photo spandana N
      spandana N

      HI Vishnu,

        yes we can have multiple inputs rows from SAP FM and need to take care of creating the Meta (payload) while sending it to the  SAP netweaver

      Author's profile photo Vishnu Pankajakshan
      Vishnu Pankajakshan

      i have tried multiple inputs with deep entity but i failed indefinitely with create.

      Regards,

      Vishnu

      Author's profile photo Pravinkumar Lokhande
      Pravinkumar Lokhande

      Hi Nagesh ,

      I have implemented service as per your given procedure but still getting error as.

      Method 'IMPORTSET_GET_ENTITYSET' not implemented in data provider class



      Author's profile photo Former Member
      Former Member

      Hello Nagesh,

      Thanks!!, really nice documentation and easy to follow . without any failure I was able to  create Gateway service with all CRUD operations and it's working fine 🙂 🙂 🙂

      Author's profile photo Hardik Patel
      Hardik Patel

      I am getting below error for CREATE operation. Can someone help? Please tell the steps that I need to perform as I have not much experienced with basis. Thanks.

      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

      <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

          <code>MG/171</code>

          <message xml:lang="en">You have not fully maintained the descriptions</message>

          <innererror>

              <transactionid>5773C666E2EF2CD8E10000000A000626</transactionid>

              <errordetails>

                  <errordetail>

                      <code>MG/171</code>

                      <message>You have not fully maintained the descriptions</message>

                      <propertyref/>

                      <severity>error</severity>

                  </errordetail>

                  <errordetail>

                      <code>MG/171</code>

                      <message>You have not fully maintained the descriptions</message>

                      <propertyref/>

                      <severity>error</severity>

                  </errordetail>

                  <errordetail>

                      <code>/IWBEP/CX_SD_GEN_DPC_BUSINS</code>

                      <message>You have not fully maintained the descriptions.</message>

                      <propertyref/>

                      <severity>error</severity>

                  </errordetail>

              </errordetails>

          </innererror>

      </error>

      Author's profile photo Tanmay Verma
      Tanmay Verma

      Hi Hardik,

      You need to pass the value for Langu as 'E' and LanguIso as 'EN' in Payload else the BAPI throws the above error "You have not fully maintained the descriptions".

      ~Tanmay

      Author's profile photo Former Member
      Former Member

      Great it's working fine. really good job. Similarly i am trying for 'BAPI_SALESORDER_CREATEFROMDAT2' i am getting errors 🙁

      please Guide how to do with this BAPI.

      Regards

      Venkatesh

      Author's profile photo David Raven
      David Raven

      Hi,

       

      Thank you for this tutorial.

      I have a question.

       

      I want to pass a table to my RFC as a create entry (POST).

      How do I do it ?

       

      Thanks.

      Regards.