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

Estimated read time 16 min read

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. 

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.  

 

 Search for My Travel and Expenses fiori app. 

Select My travel and Expenses. 

Click on implementation information. 

Expand Configuration. 

Under Configuration we can get the OData service name. 

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. 

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

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. 

 

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. 

You can see the project is present. 

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   

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

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

 

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. 

 

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

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

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

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

 

 

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. 

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

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

 

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

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

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. 

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. 

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

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

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

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

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

Select the service and click on add selected service. 

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. 

 

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. 

 

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

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

IF_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. 

Provide the enhancement implementation name and short text. 

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. 

Click on copy sample class. 

Now the Badi implementation is created. 

Activate the Badi implementation and after the Badi. 

Goto the implementing class. 

 

 

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

You will get implementing methods for all the entity Sets. 

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

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

 

 

 

 

 

 

 

  

 

 

 

 

​ 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. 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.    Search for My Travel and Expenses fiori app. Select My travel and Expenses. Click on implementation information. Expand Configuration. Under Configuration we can get the OData service name. 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. We can see the odata service is in an active state i.e. the ICF node is active. 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.  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. You can see the project is present. 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   Double click on the entity type you will get all the abap structures for all the entity types already available for us. Double click on the structure relevant to expense entity and open it in SE11.  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.  5. Append the fields you want to append to the structure and save and activate it. To allow for future extension we use the setting called enhancement category. Now go back and check the structure our z-fields will be added to the structure. 6.Goto SEGW  tcode and create Custome service for travel expenses.   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. Provide the technical service name as the standard OData service name PAOC_TRV_SRV as we are redefining it. Click on next , now all the entity sets from the standard service have been fetched.  We want to reuse everything so select all the entities and click on finish. Now all the entity sets from the standard service are inherited to the custome service. 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. 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. Now we can see the z properties added to the system. Or click F4 help of any field you will get the z fields appended. Check all the check boxes like creatable, updatable etc. For each of the custome field. 10. Now check and Generate runtime artifacts, now DPC_ext, MPC_EXT,new odata service has been generated. 11.Now we need to Register our Custome OData service,go to tcode Maint_services by adding the service. Select the service and click on add selected service. 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.  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.  Goto SE18 transaction and check the Badi which is mentioned in the extension point. The Badi is already present in the system given by SAP. IF_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. Provide the enhancement implementation name and short text. 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. Click on copy sample class. Now the Badi implementation is created. Activate the Badi implementation and after the Badi. Goto the implementing class.   Double click on the implementing class name and you will get all the implementing methods. You will get implementing methods for all the entity Sets. Now Use the expense set Get entity set method which will be responsible for sending data for expense set. Write the relevant implementation in the Badi method or wherever needed to get the custome field data in the Fiori application.                Read More Application Development Blog Posts articles 

#SAP

You May Also Like

More From Author