Get Started with ABAP Programming on SAP BTP

Developing your First ABAP Program

Objectives
After completing this lesson, you will be able to:

After completing this lesson, you will be able to:

  • Create a Hello World Application

Creating a Hello World App

As in all other programming languages, the first thing that you should do in ABAP is familiarize yourself with the development environment and the most elementary aspects of the language by writing a short "Hello World" app.

The main user interface technology that you will use in modern ABAP programming is Fiori Elements. However, ADT provides a console for you to create output quickly and simply in test applications.

How to Create A Hello World Application

Create a Package and a Hello World Application

Task 1: Create a Package

Create an ABAP package in which you can store the development objects, that you will create during this class. Add the package to your favorites so you can easily access it anytime.

Steps

  1. Create ABAP package ZS4D400_##, where ## is your group number. Assign the package to the software component ZLOCAL. When you are prompted to assign the package to a transport request, create a new one.

    1. Choose FileNewABAP Package.

    2. Enter the name ZS4D400_##, where ## is your group number.

    3. Enter a description for your package.

    4. Choose Next.

    5. Enter the software component, ZLOCAL, and choose Next.

    6. Mark Create a new request and enter a description for the new transport request.

    7. Choose Finish.

  2. Add the package to your favorites.

    1. Expand your ABAP project tree until you can see the node Favorite Packages.

    2. Right-click and choose Add Package.

    3. In the dialog box, enter the package name ZS4D400_##, where ## is your group number.

    4. Double-click the name of the package in the hit list to add it to your list of favorite packages.

Task 2: Create a Hello World Application

In your package, create an new ABAP class. Let the class implement interface IF_OO_ADT_CLASSRUN so that you can use the class as main program for an Eclipse console app.

Steps

  1. In your package, create a new ABAP class with the name ZCL_##_HELLO_WORLD. Ensure that it uses the interface IF_OO_ADT_CLASSRUN. When you are prompted to assign the class to a transport request, use the transport request that you created in the previous task.

    1. Choose FileNewABAP Class.

    2. Enter your package ZS4D400_##, where ## is your group number.

    3. Enter the name ZCL_##_HELLO_WORLDwhere ## is your group number, and enter a description for your class.

    4. Choose Add... (next to the Interfacesgroup box).

    5. Enter the filter text IF_OO_ADT_CLASSRUN. Double-click the matching entry in the hit list.

    6. Choose Next.

    7. Mark Choose from requests in which I am involved and your own transport request.

    8. Choose Finish.

  2. In the if_oo_adt_classrun~main( ) method, use out->write( ) to output the phrase Hello World.

    1. In the editor, enter the following coding between METHOD if_oo_adt_classrun~main and ENDMETHOD.:

      Code snippet
      out->write( 'Hello World' ).
      Copy code
  3. Activate and test your class.

    1. Activate the class with the keyboard shortcut Ctrl + F3.

    2. Run the class with the F9 key.

  4. Check the output in the Console view of eclipse.

    1. Check the Console view that should have opened as a new tab below the editor view.

    2. If the Console view is not visible, open it by choosing WindowShow viewOther. Double-click Console in the hit list.

Save progress to your learning plan by logging in or creating an account