oData service which consumes RFC

light

OData with RFC function module.

 

 

In this step-by-step post we will create oData project which consumes RFC: BAPI_FLIGHT_GETLIST. After getting input from frontend this oData service will execute and send filtered records back to frontend as output.

Here we will take AIRLINE as input: 

1

and Table parameter FLIGHT_LIST will be used as output:

2

Step 1: To create oData project Goto TCode: SEGW → Click on create button

1

Step 2: Provide the Project name and description

2.jpg

Step 3: Your project is created and you’ll get the below screen

3

Step 4: Now we need to create Entity and Entity set: Right click on Data Model → Import → RFC/BOR Interface

4

Step 5: Provide Entity name and BAPI name as below. Select Remote radiobutton and Provide RFC destination if your destination is not local → Click on Next.

5

Step 6: Select  FLIGHT_LIST here and click on next.

1

Step 7: As we have discusses earlier, at least one key field is necessary, so selecting here AIRLINEID as key and select default entity set checkbox. 

2

Step 8: Entity Type and Entity Set are created now.

3

Step 9: Now we need to maintain mapping between oData service and BAPI. Expand Service Implementation folder → Right click on GetEntitySet (Query) → Click on Map to Data Source.

1

Step 10: Provide Data Source type = RFC & Name = BAPI_FLIGHT_GETLIST.

2

Step 11: We will get the following screen

3

Drag the respective fields of FLIGHT_LIST to Data Source Parameter to maintain mapping.

4

5

Step 12: Mapping for output fields is done in above step, now we need to do mapping for input field AIRLINEID.

Click on Insert Row button to add a new row.

1

Do F4 and select Airlineid.

2

Drag Input parameter AIRLINE and drop to newly added field.

3

Now mapping is done.

Step 13: Generate Runtime Artifacts by clicking on below marked button.

4

Step 14: Click on OK and save.

5

Step 15: You can check the auto generated code by this mapping in _GET_ENTITYSET method of Data Provider Base Class ( _DPC Class ).

4

Step 16: Now we need to register the Service.

GoTo the TCode: /IWFND/MAINT_SERVICE or follow below path5

Click on Add Service button

6

Step 17: Provide System Alias name and Technical Service Name (you can get it from Runtime Artifacts) → Press Enter or Click on Get Services → Select your service and click on Add Selected Services button. 

9

Step 18: To test the oData service, select your Service and go to the TCode- /IWFND/GW_CLIENT or click on SAP Gateway Client.

1

Step 19: You’ll get the following screen → Click on EntitySets button and select your entity.

2

URL has been updated.

3

After executing, we get the following output.

3

Step 20: We can provide input values through filter keyword in URL.

URL = /sap/opu/odata/sap/ZMTEST1_RFC_SRV/FLIGHTSet?$filter=Airlineid eq ‘AA’

4

 


 

 

 

 

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s