Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Ranjitha_cs
Explorer
1,909

Extending Standard Fiori Application By Extending Standard OData Service In Sap Gateway: 

Why Do We Need To Extend The OData Service? 

Imagine if you are using an OData service in your company and they want you to extend this application, but the problem is that application is a standard Fiori application. 

A standard Fiori application delivered by sap also comes with a standard OData service. 

Let's check how can we identify the OData service pertaining to a standard sap application and then how do you discover the required implementation into the system and enrich our data structure including the service structure with Custome fields so that you can return and read the data of Custome fields using  standard OData services using standard gateway project. 

It is predominantly required when you have a project which is already running or a Fiori application which is already used by business and SAP provides a standard service which is used by that Fiori project. 

 So now our goal is to add Custome fields to the standard OData service, to add custome fields to the OData service is extremely important, we first find where that OData service and is it active. 

Now take an example the standard Fiori application My Travel and Expenses     Extend the standard OData service relevant to the application. 

Steps:    

   1.  Go to Fiori App Reference library to get the standard Fiori app and find the relevant OData service for the same. 

2. Once we find the service in the configuration, check if the service is active or not. 

3.Check what is the GW project is for this service, add the standard project to our SEGW. 

4. Check the Entity Types, find the DDIC Structure relevant for entity and open the structure in se11(e.g.: expense).

5. Append the fields you want to append to the structure and save and activate it. 

6. Goto SEGW  transaction code and create custome service for travel expenses. 

7. Right click on the data model, select Redefine and choose OData Service (SAP GW). 

8. To add the custome fields to your standard structure, just right click on the expense entity->import->Properties and check the custome fields in order to import to your entity. 

9. Now check and Generate runtime artifacts, now DPC_ext, MPC_EXT,new odata service has been generated. 

10. Register the service.

11. Go to the documentation of the Fiori application and check for the extension point for the service and give custome implantation you needed for your costume OData service. 

  1. Go to Fiori app reference library in browser and check the list of standard Fiori apps and find the relevant OData for the same. 
  • Navigate to app reference library throw browser.  

Ranjitha_cs_9-1724750159937.png

 

  •  Search for My Travel and Expenses fiori app. 

Ranjitha_cs_10-1724750159940.png

Select My travel and Expenses. 

Ranjitha_cs_11-1724750159943.png

Click on implementation information. 

Ranjitha_cs_12-1724750159945.png

Expand Configuration. 

Ranjitha_cs_13-1724750159947.png

Under Configuration we can get the OData service name. 

Ranjitha_cs_14-1724750159950.png

2. Once we find the service in the configuration, check if the service is active or not. 

Copy the OData service name and go to transaction code /iwfnd/maint_service and search for the OData and check if it is active or not. 

Ranjitha_cs_15-1724750159952.png

We can see the odata service is in an active state i.e. the ICF node is active. 

Ranjitha_cs_16-1724750159953.png

3. Check what the GW project is for this service. 

Select the service and click on service implementation, we can get the service implementation detailed display which contains technical model name, Model provider class name, and the package in which the service is stored etc. 

Ranjitha_cs_17-1724750159955.png

 

Ranjitha_cs_18-1724750159957.png

Try for technical model name by removing the _mdl at the end to find the gate way project name in segw tcode. 

Go to SEGW and try to open the project PAOC_TRV. 

Ranjitha_cs_19-1724750159958.png

You can see the project is present. 

Ranjitha_cs_20-1724750159959.png

The above project is delivered by SAP we can’t change it directly, we are not allowed to change directly because it is a sap delivered service. 

As we can’t change the standard sap project, we need to create a service extension project. 

4. Check the Entity Types, find the DDIC Structure relevant for entity and open the structure in se11(e.g.: expense). 

Here our goal is to extend the expense entity data. 

So go to segw and find the structure related to expense entity and   

Ranjitha_cs_21-1724750159961.png

Double click on the entity type you will get all the abap structures for all the entity types already available for us. 

Ranjitha_cs_22-1724750159964.png

Double click on the structure relevant to expense entity and open it in SE11. 

Ranjitha_cs_23-1724750159965.png

 

Ranjitha_cs_24-1724750159967.png

Now we want to add some Custome fields to this structure. 

As it is a standard structure add Custome fields to the structure by using append structure. 

Click on append structure and provide the name of the append structure. 

Ranjitha_cs_25-1724750159969.png

 

Ranjitha_cs_26-1724750159971.png

5. Append the fields you want to append to the structure and save and activate it. 

Ranjitha_cs_27-1724750159973.png

To allow for future extension we use the setting called enhancement category. 

Ranjitha_cs_28-1724750159974.png

Now go back and check the structure our z-fields will be added to the structure. 

Ranjitha_cs_29-1724750159977.png

6.Goto SEGW  tcode and create Custome service for travel expenses. 

Ranjitha_cs_30-1724750159979.png

 

 

Ranjitha_cs_31-1724750159980.png

We should not rewrite everything rather we will reuse everything, before when we use to extend a program sometimes, we use to copy the standard one but this copy decouples you from standard permanently and in next subsequent patch or release or any new feature come to that program you need to copy it  again. 

So, I want to reuse the standard as much as there. On top I will add my custome so if any updatation to standard is there we could continue to use them if we followed this procedure of extension. 

So, to achieve this, we need to redefine our standard OData service in order to get the standard functionalities as below.  

 7.Right click on the data model and select Redefine and choose OData Service (SAP GW) as below. 

Ranjitha_cs_32-1724750159981.png

Provide the technical service name as the standard OData service name PAOC_TRV_SRV as we are redefining it. 

Ranjitha_cs_33-1724750159982.png

Click on next , now all the entity sets from the standard service have been fetched. 

 

Ranjitha_cs_34-1724750159985.png

We want to reuse everything so select all the entities and click on finish. 

Ranjitha_cs_35-1724750159988.png

Now all the entity sets from the standard service are inherited to the custome service. 

Ranjitha_cs_36-1724750159989.png

Goto expense entity properties as standard entity does not have the custome fields that we had added to the structure it won't contains those fields. 

8.Just right click on the expense entity->import->Properties. 

Ranjitha_cs_37-1724750159992.png

9. Select the Custome fields that we have added and click on next and then finish this fields should get added to our service. 

This is how we can add standard service to our system. 

Ranjitha_cs_38-1724750159994.png

Now we can see the z properties added to the system. 

Ranjitha_cs_39-1724750159998.png

Or click F4 help of any field you will get the z fields appended. 

Ranjitha_cs_40-1724750160000.png

Check all the check boxes like creatable, updatable etc. For each of the custome field. 

Ranjitha_cs_41-1724750160003.png

10. Now check and Generate runtime artifacts, now DPC_ext, MPC_EXT,new odata service has been generated. 

Ranjitha_cs_42-1724750160008.png

11.Now we need to Register our Custome OData service,go to tcode Maint_services by adding the service. 

Ranjitha_cs_43-1724750160009.png

Select the service and click on add selected service. 

Ranjitha_cs_44-1724750160011.png

Now our custome service is active, click on Sap gateway client and execute the URI with metadata and check the metadata whether the custome fields are there for expense entity type. 

Ranjitha_cs_45-1724750160014.png

Ranjitha_cs_46-1724750160016.png

 

Ranjitha_cs_47-1724750160019.png

Now in order get the data for our custome fields we need to write the logic in dpc ext or in a Badi implementation. 

Goto the documentation of the Fiori application and check for the extension point for the service. 

Goto Fiori application and then check the extension point in the extensibility point. 

Expand the expensibility section and you will get the extensibility point where we get the badi name where we can write logic for our custome fields . 

Click on Extensibility documentation for app and there you will get the all the UI and back-end extension points. 

Here we will get the Badi name for extension. 

Ranjitha_cs_49-1724750160022.png

 

Ranjitha_cs_50-1724750160025.png

Goto SE18 transaction and check the Badi which is mentioned in the extension point. 

Ranjitha_cs_51-1724750160026.png

The Badi is already present in the system given by SAP. 

Ranjitha_cs_52-1724750160027.pngIF_PAOC_MY_TRAVEL_EXPENSES is the Badi interface where we can write our custome logic. 

Now implement the, go to se19 and create the implementation. 

Provide the enhancement spot name and click on create. 

Ranjitha_cs_53-1724750160029.png

Provide the enhancement implementation name and short text. 

Ranjitha_cs_54-1724750160031.png

Ranjitha_cs_55-1724750160034.png

Provide the implementation name and implementation class name. 

For implementing class name go back to se18 and get the implementing class of the Badi. 

Usually, we will take the interface name as the Badi class. 

Fill all the fields and click on continue. 

Ranjitha_cs_56-1724750160036.png

Click on copy sample class. 

Ranjitha_cs_57-1724750160037.png

Now the Badi implementation is created. 

Ranjitha_cs_58-1724750160039.png

Activate the Badi implementation and after the Badi. 

Goto the implementing class. 

Ranjitha_cs_59-1724750160041.png

 

 

Ranjitha_cs_60-1724750160045.png

Double click on the implementing class name and you will get all the implementing methods. 

Ranjitha_cs_61-1724750160048.pngYou will get implementing methods for all the entity Sets. 

Ranjitha_cs_62-1724750160051.png

Now Use the expense set Get entity set method which will be responsible for sending data for expense set. 

Ranjitha_cs_63-1724750160054.png

Write the relevant implementation in the Badi method or wherever needed to get the custome field data in the Fiori application. 

 

 

 

 

 

 

 

  

 

 

 

1 Comment
S0025287418
Newcomer

Very informative and detailed - Thank you.

Labels in this area