SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

RFC: Get Data from an On-Premise System Using a Custom Entity

Get data from an on-Premise System Using RFC, by Implementing a Custom Entity in ABAP Environment

Overview

🎓 intermediate 45 min. ABAP DevelopmentIntermediateSAP BTP ABAP EnvironmentSAP Business Technology Platform

You will learn

  • โœ”How to create a suitable custom entity to get data from a remote system
  • โœ”How to implement a query provider class to get the data, using a BAPI (Business Application Programming Interface)
  • โœ”How to expose the custom entity as a service definition
  • โœ”How to display the data in a Fiori Elements Preview, using a service binding
Julie Plummer J Julie Plummer April 10, 2024
Created by March 9, 2023
Contributors

Prerequisites

Prerequisites

Steps

Intro

Note that, if you are using the trial version, currently you cannot access an on-premise system using RFC. In that case, you will test the class using mock data.

A BAPI is a standard interface to a business object model, implemented as a function module.

Custom entities are used for data models for which you do not run a SELECT statement from an existing data source in the database. Rather, you: 1. Define the elements and their types in the custom entity 2. Implement the data retrieval logic manually in an ABAP class 3. Reference this class in an entity annotation.

Custom entities allow you to get data using an OData service or, as here, using RFC.

Throughout this tutorial, replace ### or 000 with your initials or group number.


Step 1 Create a class
โ€”

First, you create the class that implements the data retrieval logic.

  1. In ADT, open your ABAP package and choose New > Class.

    Image depicting step1-new-class
    Image depicting step1-new-class

  2. Enter the following, then choose Next:

    • Name: zcl_product_via_rfc_###
    • Description: Read product data via RFC
    • Interfaces: if_rap_query_provider
  3. Choose the transport request, then choose Finish.

The signature of the method IF_RAP_QUERY_PROVIDER~SELECT contains the import parameter io_request. This parameter represents the OData query options that are delegated from the UI and used as input for the SELECT method. Whenever the OData client requests data, the query implementation class must return the data that matches the request, or throw an exception if the request cannot be fulfilled. Later in this tutorial, you will implement the SELECT method of the interface.

Step 2 Create a custom entity (CDS View)
+
Step 3 Specify the class in the custom entity
+
Step 4 Define the CDS view
+
Step 5 Define some variables in the class
+
Step 6 Define the connection to the on-premise system
+
Step 7 Call the remote BAPI or insert the mock data
+
Step 8 Set the total number of records and return the data
+
Step 9 Catch the exception if raised
+
Step 10 Check the code for your class
+
Step 11 Create a service definition
+
Step 12 Create the service binding
+
Step 13 Activate service binding
+
Step 14 Display the Fiori Elements preview
+
Step 15 Test yourself
+
Step 16 Troubleshooting: Test data retrieval using the ABAP Console
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 16
1. Create a class 2. Create a custom entity (CDS View) 3. Specify the class in the custom entity 4. Define the CDS view 5. Define some variables in the class 6. Define the connection to the on-premise system 7. Call the remote BAPI or insert the mock data 8. Set the total number of records and return the data 9. Catch the exception if raised 10. Check the code for your class 11. Create a service definition 12. Create the service binding 13. Activate service binding 14. Display the Fiori Elements preview 15. Test yourself 16. Troubleshooting: Test data retrieval using the ABAP Console

Learn more →