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: Test the Business API (BAPI) with An ABAP Console App

Test that the connection to the BAPI works (A BAPI is a type of RFC).

Overview

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

You will learn

  • โœ”How to call a BAPI using RFC in an ABAP class
  • โœ”How to test this class by outputting the data to the ABAP Console
Julie Plummer J Julie Plummer April 10, 2024
Created by March 9, 2023
Contributors

Prerequisites

Prerequisites

Steps

Intro

The class:

  1. Connects to the backend system, such as an S/4HANA on-premise system.
  2. Calls the BAPI remotely via RFC.
  3. Reads the data from the back end into a local table.
  4. Outputs that local table to the ABAP Console.

In future, we hope to provide a helper class that generates the appropriate DDL source code for a custom entity and associated type definition - for any BAPI in your backend system. In the meantime, I have provided all the necessary code to use with BAPI_EPM_PRODUCT_GET_LIST and BAPI_EPM_PRODUCT_GET_DETAIL.

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


Step 1 Create an ABAP class
โ€”

  1. As before, in the Package Explorer, select your package and choose New > ABAP Class from the context menu.

  2. Enter the following for your class, then choose Next.

    • Name: ZCL_OUTPUT_TEST_000
    • Description for your class, e.g. Test RFC BTP to on-premise
    • Interface: if_oo_adt_classrun. This enables you to run the class in the console.

Remember to change 000 to your group number.

  1. Choose the transport request, then choose Finish.

The class is displayed in a new editor.

Step 2 Define the type for the local table variable
+
Step 3 Create a TRY...CATCH block
+
Step 4 Set up the connection
+
Step 5 Define some variables
+
Step 6 Call the BAPI
+
Step 7 Add the exception handling statements
+
Step 8 Check your code
+
Step 9 Test the class in the ABAP Console
+
Step 10 Test yourself
+
Step 11 Troubleshooting the SAP Cloud Connector
+

Resources

Discussion

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

Submit detailed feedback Discuss in Community
Steps
Step 1 of 11
1. Create an ABAP class 2. Define the type for the local table variable 3. Create a TRY...CATCH block 4. Set up the connection 5. Define some variables 6. Call the BAPI 7. Add the exception handling statements 8. Check your code 9. Test the class in the ABAP Console 10. Test yourself 11. Troubleshooting the SAP Cloud Connector

Learn more →