Here is a step by step guide on how to build an RFC based OData service with multiple selection (input) values.This document would help developers who are new to the Odata services. You can also find few sample queries at the end of the document.

The business requirement given here is to build an OData service which can retrieve shopping cart information from the system based on a combination of input fields (single and multiple values).

Below is the list of input fields:

Selection fields

Multiple values?

User ID (Requestor)

User ID (Creator)

Creation Date  (From)

Creation Date  (To)

Product Category Code

Yes

Vendor Number

Yes

Shopping Cart Number

External Req Number

Shopping Cart Status

Supplier Part Number

Cost Center

Line Item Description

Company Code

Purchasing Group

Yes

Plant

Below is the expected output:

Display fields

Shopping Cart Number

Creation Date

Shopping Cart Status

Shopping Cart Requestor

Shopping Cart Creator

Shopping Cart Description

Total Price of Shopping Cart

Process Level

Current Work Agent

Step1.

Create a RFC function module in the backend system with below parameters as input

/wp-content/uploads/2014/12/1_600145.jpg

For the input parameters that need multiple values to be supplied, create them as range table types.

/wp-content/uploads/2014/12/2_600183.jpg

/wp-content/uploads/2014/12/3_600165.jpg

Step2.

Go to SAP Netweaver Gateway Service builder (SEGW) and create a project.

/wp-content/uploads/2014/12/4_600184.jpg

Step3.

Click on Data Model -> Import -> RFC/BOR Interface

/wp-content/uploads/2014/12/5_600185.jpg

Step4.

Enter the Entity Type name and the RFC details.

/wp-content/uploads/2014/12/6_600164.jpg

Step5.

Select all the fields to be used in the entity type

/wp-content/uploads/2014/12/7_600186.jpg

Step6.

Make the Shopping Cart ID as the key field.

/wp-content/uploads/2014/12/8_600187.jpg

Step7.

Change the field names and set rest of the attributes as required.

/wp-content/uploads/2014/12/9_600173.jpg

Step8.

Now create an entity set and link the entity type to the entity set.

/wp-content/uploads/2014/12/10_600166.jpg

Step9.

Now go to Service Implementation and create a GetEntitySet (Query) operation

/wp-content/uploads/2014/12/11_600174.jpg

Step10.

Do the mapping between entityset and RFC for both input and output fields.

The fields which are of range table type would appear with a [ ] sign.

/wp-content/uploads/2014/12/12_600175.jpg

Step11.

After all the mapping is completed, click on the “Generate” button (highlighed below in yellow).

/wp-content/uploads/2014/12/13_600188.jpg

This will generate all the runtime artifacts for this service as shown below.

/wp-content/uploads/2014/12/14_600189.jpg

Step12.

Now go to tcode /IWFND/MAINT_SERVICE in the Netweaver gateway system and search for the service.

/wp-content/uploads/2014/12/15_600176.jpg

Step13.

Double click on the service ZGSTS_ITM_SC_PO_DISPLAY_SRV to add and activate it.

/wp-content/uploads/2014/12/16_600177.jpg

ICF Nodes and System Aliases are populated. Now the service is activated.

Now we can construct queries in order to retrieve the shopping cart information using this OData service (few examples given below):

/sap/opu/odata/sap/ZGSTS_ITM_SC_PO_DISPLAY_SRV/SCHeaderCollection?$filter= IN_ShopCartId eq ‘1000045468’ and IN_IsidRequestor eq ‘USMANAGER6’

/sap/opu/odata/sap/ZGSTS_ITM_SC_PO_DISPLAY_SRV/SCHeaderCollection?$format=json&$top=10&$filter= IN_ShopCartId eq ‘1000045468’and IN_IsidRequestor eq ‘USMANAGER6’

/sap/opu/odata/sap/ZGSTS_ITM_SC_PO_DISPLAY_SRV/SCHeaderCollection?$filter= IN_IsidRequestor eq ‘USEMPLOYEE15′ and IN_CreateDate eq datetime’2013-12-01T00:00:00′ and IN_CreateDateTo eq datetime’2013-12-31T00:00:00’

/sap/opu/odata/sap/ZGSTS_ITM_SC_PO_DISPLAY_SRV/SCHeaderCollection?$filter= IN_IsidRequestor eq ‘USEMPLOYEE15’ and (IN_CategoryId eq ‘10100000’ or IN_CategoryId eq ‘43211507’)

/sap/opu/odata/sap/ZGSTS_ITM_SC_PO_DISPLAY_SRV/SCHeaderCollection?$format=json&$filter= IN_IsidRequestor eq ‘USEMPLOYEE15’ and (IN_VendorId eq ‘0001010250’ or IN_VendorId eq ‘0001201715’) and (IN_PurGroup eq ‘101’ or IN_PurGroup eq ‘105’) and IN_ItemDesc eq ‘*MOUSE*’

To report this post you need to login first.

1 Comment

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

Leave a Reply