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

Create a Global ABAP Class

You will learn how to create a global ABAP class, in which you will retrieve data from a database.

Overview

🎓 beginner 45 min. ABAP DevelopmentBeginnerSAP Netweaver

You will learn

  • โœ”How to create a global class that retrieves data from the back end
  • โœ”How to use an internal table
  • โœ”How to use an ABAP structure as a type for the returning parameter
  • โœ”How to display data in a SAP List Viewer ("ALV Grid")
Unknown U Unknown March 21, 2023
Created by March 21, 2023
Contributors

Prerequisites

Prerequisites

  • You have a valid instance of an on-premise AS ABAP server, version 7.51 or higher (some ABAP Development Tools may not be available in earlier versions)
  • Tutorial: Create an ABAP Project in ABAP Development Tools (ADT)
  • You have generated the data for the relevant database table by running the transaction SEPM_DG.

Steps

Step 1 Open your ABAP program and remove the WRITE statement
โ€”

  1. First, open your ABAP program, ZSO_INVOICE_ITEMS_EURO which you created in the previous tutorial, Create and run an ABAP application.

    Image depicting step1-open-abap-program
    Image depicting step1-open-abap-program

  2. Remove the existing method implementation for the run method.

    Image depicting step2-delete-write
    Image depicting step2-delete-write

Step 2 Create an instance of a new global class
+
Step 3 Check the syntax
+
Step 4 Create a method to get the database records
+
Step 5 Add the method implementation
+
Step 6 Format your code
+
Step 7 Declare the local variable explicitly
+
Step 8 Replace `helper_type` with a Dictionary structure
+
Step 9 Declare the local variable as a returning parameter
+
Step 10 Save and activate your class
+
Step 11 Use the returning parameter in the program
+
Step 12 Generating the ALV Grid
+
Step 13 Adapt the ALV Grid factory method
+
Step 14 Check your code
+
Step 15 Save and activate the program
+
Step 16 Test yourself
+

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. Open your ABAP program and remove the WRITE statement 2. Create an instance of a new global class 3. Check the syntax 4. Create a method to get the database records 5. Add the method implementation 6. Format your code 7. Declare the local variable explicitly 8. Replace `helper_type` with a Dictionary structure 9. Declare the local variable as a returning parameter 10. Save and activate your class 11. Use the returning parameter in the program 12. Generating the ALV Grid 13. Adapt the ALV Grid factory method 14. Check your code 15. Save and activate the program 16. Test yourself

Learn more →