Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member207835
Participant

In the first part Detailed step by step procedure for Creating Gateway Service with all the CRUD Operations and testin...

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 '00000000...

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   

              

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/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns: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/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns: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.

17 Comments
Labels in this area