Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
gaddamarunkumar
Participant
0 Kudos
412

In this post, you’ll learn how to adapt to cloud-based ABAP development using the ABAP Development Tools (ADT) in Eclipse for SAP Business Technology Platform (BTP) projects. We’ll explore the key differences from traditional SAP GUI programming, focusing on the absence of classic reports and screens, and guide you through executing and testing code using the ABAP Console. By the end, you’ll understand how to set up a class with the if_oo_adt_classrun interface, implement logic, and display results—complete with a practical example of fetching data from a flight table.

When working on a BTP cloud project in Eclipse with ADT, you might find yourself wanting to execute code directly within the ABAP environment. However, if you're accustomed to the traditional SAP GUI, you'll quickly notice a key difference: there are no classic reports or programs to develop in this setup. This shift to a cloud-based paradigm requires a new approach, accompanied by certain restrictions that can feel limiting at first. The most notable constraints when moving away from SAP GUI are:

  1. No Traditional Screens: Selection screens, module pool screens, and output screens are unavailable.
  2. Class-Based Development: Instead of writing standalone programs, you must create classes to test or execute your code.

How to Execute Code Without Screens?

In the absence of traditional screens, the ABAP Console becomes your go-to tool for running and testing code in this environment. Here's how to set it up and use it effectively:

Step 1: Set Up the Class

To enable console-based execution, integrate the if_oo_adt_classrun interface into your class. This interface allows your class to run as an ABAP application in the console. Here’s a sample code snippet to get started:

 

INTERFACES: if_oo_adt_classrun.

 

Step 2: Implement the Main Method

Next, implement the if_oo_adt_classrun~main method. This method serves as the entry point when the class is executed. Inside it, insert the logic you need to run.

 

METHOD if_oo_adt_classrun~main.

  " Your logic goes here

ENDMETHOD.

 

Step 3: Display Results

Once your logic is implemented, use the write method to output results to the ABAP Console. This can include local variables, structures, or internal tables. The syntax is straightforward:

 

out->write( lv_variable ).  " For a variable

out->write( ls_workarea ).  " For a structure

out->write( lt_table ).     " For an internal table

 

Practical Example: Fetching Data from a Flight Table

Let’s walk through a simple example of retrieving data from a flight table and displaying it in the ABAP Console:

  • Create the Class: Define a new class, integrate the if_oo_adt_classrun interface, and implement the if_oo_adt_classrun~main method with your logic. For instance, you might fetch data from a flight table into an internal table (lt_flights).

Source code:

 

CLASS z2793_class1 DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
    INTERFACES if_oo_adt_classrun.
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.

CLASS z2793_class1 IMPLEMENTATION.
  METHOD if_oo_adt_classrun~main.
    DATA:
*   Internal table to store flight data
      lt_testdata TYPE TABLE OF z00007_flight,
*   Work area to store flight data
      ls_testdata TYPE z00007_flight.

*   Fetch flight data
    SELECT *
    FROM z00007_flight
    INTO TABLE @lt_testdata.

*   count of records.
    DATA(lv_count) = lines( lt_testdata ).

*   Display data from internal table lt_testdata
    out->write( lt_testdata ).
*   Display count from lv_count.
    out->write( lv_count ).
  ENDMETHOD.
ENDCLASS.

 

 

  • Run the Class: In ADT, click the Run button, hover over "Run As," and select ABAP Application (Console). This executes the class and directs the output to the console.

gaddamarunkumar_3-1742487623865.png

 

  • View the Output: The results—such as the contents of lt_flights—will appear in the ABAP Console for review.

gaddamarunkumar_2-1742486550292.png

 

Conclusion

By leveraging the ABAP Console and the if_oo_adt_classrun interface, you can seamlessly test and execute code in a cloud-based ABAP environment. While the absence of traditional screens and programs may initially feel restrictive, this class-based approach offers a streamlined and modern way to develop and debug directly within ADT. With these steps, transitioning to ABAP in the cloud becomes a manageable—and even empowering—experience.

Please feel free to share your thoughts in the comments section below.

If you enjoyed reading this blog post and would like to receive similar content in the future, please consider following my profile. By following my profile @gaddamarunkumar , you will receive updates on new blog posts and other content related to ABAP development best practices.

Follow the SAP ABAP environment Topic page: SAP ABAP

This page is a great resource for staying up-to-date on the latest news and developments in the SAP ABAP environment. You can follow the page to receive updates, post and answer questions, and read other posts on the topic

 

Labels in this area