Skip to Content

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.

Enter system alias and press enter. From the displayed list locate our service and click o it.

Save it in a package and click on Ok.

Select the request and click on Ok. Again click on ok. Come back and click on our service.

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

Click on Create System alias button and enter the required system details and save the changes and come back.

Save the changes in the request.

Now we can see our system alias details.

Now we will explore our service for that click on Explore service button.

Click on Execute to get Service Document .

Service Document:  Describes the location and capabilities of one or more Collections.

Here we can check our Entity set name and we will get our Service URI.

Here our URI: http://<hostname>:<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/

Now come back and now choose Get Service Metadata option as shown below and click on execute to get the service mete data.

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.

Note the URI of our service and we will use it further.

URI: http:// <hostname>:<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/$metadata


Testing Our Service.


Now we will test our service in Gateway Client transaction for that is /IWFND/GW_CLIENT.

Paste our URI in Request URI field and click on Get HTTP Method.

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:

QUERY:

Query is to get multiple entries and here we can pass ranges for selection.

In our example we will try to fetch Materials within the range ‘000000000000000023’ to ‘000000000000000038’.

URI:

http:// <hostname>:<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/matrset?$filter=Material ge ‘000000000000000023’ and Material le ‘000000000000000053’

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

Output: We will get three materials in our output   

        Untitled.jpg       

CREATE:

Now we will try to create Material ‘000000000000000016’. For this first we will READ an existing material and using that XML we will CREATE desired material.

First try to READ Material ‘000000000000000023’ by using the URI same as in our READ operation in Gateway client.

Now click on Use as request button as below.

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

OUTPUT:

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>

OUTPUT:

Now we will check that whether that Material is updated or not by using READ operation. Select the HTTP Method GET and check the output.

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>

OUTPUT:

With this we have completed all the CRUD operations.

To report this post you need to login first.

16 Comments

You must be Logged on to comment or reply to a post.

  1. Bhavya Garg

    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 ‘=’.

    (0) 
  2. Vishnu Pankajakshan Panicker

    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

    (0) 
  3. 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 .

    (0) 
    1. Nagesh A Post author

      Hi,

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


      Thanks

      Nageswar

      (0) 
      1. 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”.

        (0) 
  4. saigowtham thangavelu

    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.

    (0) 
    1. 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

      (0) 
  5. SANTHOSHI GORLE

    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 🙂 🙂 🙂

    (0) 
  6. 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>

    (0) 
    1. 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

      (0) 
  7. Venkatesh Ummarrao

    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

    (0) 

Leave a Reply