Dear All,

I am writing this blog specifically for SMP 3.0 as from SMP 3.0 onwards the entire architecture is based on OData Framework. Be it any backend datasource, there is a concept of Entity Data Model (EDM) to expose your backend data in OData.

For SAP Backend systems, there are two ways to consume data from RFC(Remote Function Modules).

1. Expose the RFC as a SOAP Service using SOAP Manager and create Data Models on Eclipse IDE with SAP OData Plugins

2. Create a Gateway Service Project on Netweaver Gateway and import the service into your Eclipse IDE with SAP OData Plugins.

For method 2, the pre-requisite is to have an SAP Netweaver Gateway installed either in an Central Hub Deployment or Embedded Deployment

Central Hub Deployment of SAP Netweaver Gateway has SAP NW Gateway Server installed in a different instance then the SAP ERP instance whereas Embedded Deployment has all the components of SAP Netweaver Gateway installed in the same instance.

For this blog post we are going to follow method 2 and are using an Embedded Deployment model of SAP Netweaver Gateway.

Log in to you SAP Server Instance and go the the transaction SEGW

(If you are missing any roles, capture the SU53 logs and get in touch with your basis person to provide you with the required authorization. The basic authorization required would be of the Gateway Developer Role)

Once you log in to SEGW you would see the below screen

1.PNG

2.PNG

Click on the Create Button to create a new Project.

It will prompt you to enter the Project name, Description and the Package name if you wish to Transport the project to QAS. Else you can just create it

inside the Local Temp ($TMP) Directory by clicking Local Object button

3.PNG  4.PNG

Now we will create a Data Model Directly from the RFC,

I have an RFC made by name Z_SMP_PM_NOTIFICATION

which has two input parameters and returns a list as an output

35.PNG

36.PNG

So inside our project Right Click on Data Model and click on Import –> RFC/BOR Interface

/wp-content/uploads/2015/03/5_655467.png

Give the name of the Entity and the Destination RFC.

Here we will give the name of the Entity as NotificationList and the destination RFC as Z_SMP_PM_NOTIFICATION.

37.PNG

Click on Next to define the Fields that we require in our entity. For my RFC to work i need the REQ_INTERFACE_NAME as the input as the LT_NOTIF_LIST as output parameter so i would select only those fields.

6.PNG

Click on Next to define a key. You can also change the name of the fields under the name column. Defining a key for an entity is mandatory

38.PNG

Click on Finish to create the entity.

Next we will create an EntitySet which will be of the datatype the Entity that we created.

Double Click on the Entity Sets node and click on the Create Icon

11.PNG to create a new entity. Give the name of the Entity Set and the Entity Type name as the name of the Entity that we just created

12.PNG

Once this is done you would see an entry under the Service Implementation node with the same name as the Entity Set.

Expand it to see you will see 5 operations along with every entity set

Create – This operation will be used if you want to create any data within SAP from the webservice. for e.g Creating a new Employee in the master table

Delete  – This operation is used to delete existing entry within SAP from the webservice. for eg Deleting a particular Employee within the master table

GetEntity(Read) – This operation is used if you want to retrieve a single record against a key from SAP for e.g Retrieving details of a particular employee

GetEntitySet(Query) – This operation is used to retrieve a list of records from SAP against a query or without a queryfor e.g Retrieving list of employees or retrieving a list of employees with Country Code IN etc

Update – This operation is used to update the existing data of a record within SAP For e.g Updating contact details of a particular employee.

Since for this example our RFC returns a list of Notifications so we will proceed for defining a GetEntitySet(Query) Operation on our EntitySet.

Right Click on the GetEntitySet(Query) node and select Map to Datasource.

You can either map the fields manually or click on Propose Mapping button on the top to map it automatically

39.PNG

If your input parameter has any constant value then you can directly define it over here with ‘ ‘ quotes.

Once this is done we are done with the development of the Entity set and Mapping. Next this is we will Generate the Runtime Objects which all the Gateway Services require for operating.

Gateway Services based on Model Provider and Data Provider Classes.


Click on the Generate Runtime Objects button 19.PNG


If there are not errors you will see a below message that all these classes are created with a green box on their side.

23.PNG


Once all the classes are made, next thing we will do is to register this service against the SAP Netweaver Gateway Server so that we can access it.


The pre requisite for this would be that you create Destination for the Systems. If the destinations are not maintained you can make those using the TCODE SM59 and then create an alias using SPRO->SAP Netweaver–>Gateway–>OData Channel–>Configuration–>ConnectionSettings–>SAP Netweaver Gateway to SAP System–> Manage SAP System Alias and create a new Entry there against the RFC Destination.


Double Click on the Service Maintenance Node and you should see all the Destinations that you have created.

Select the Destination and click on Register Service.


21.PNG


Click on Register Button and it will ask you for a prompt


22.PNG


It will open a new page, Do not change any values, Within the package Assignment give the Package name if you wish to transport or

you can store it as a Local Object.


Click on the green tick to register the service.

Once the service is registered and deployed you will see a green box against the destination.


25.PNG

We have now deployed the service on the SAP Netweaver Gateway Server.

Next we will proceed to testing the Service that we just deployed. Go to the transaction /IWFND/MAINT_SERVICE

Here you will see a list of services

26.PNG

Select our service and click on the Gateway Client button

27.PNG

It will open up a new window

28.PNG

click on the 30.PNG and you will see the list of Entity Sets that we created under this Service

31.PNG

If you have any input parameters then you can give it after the Entity Set name. The RFC that we created had one input parameter which was a constant so i defined the constant value during mapping itself. If you have any input values for query operation you can supply it as follows

/sap/opu/odata/sap/ZTESTNOTIFICATION_SRV/NotificationCollection?$filter=parametername eq ‘value’

Once you add this click on the 32.PNG button to test the service.

It should return with a HTTP Request code 200 and with the data

34.PNG

This way you can develop multiple entity sets and test it.

Hope this helps you all.

For more info on SMP, follow SMP Developer Center

Thanks,

Rakshit Doshi

To report this post you need to login first.

2 Comments

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

Leave a Reply