Developing Your First ABAP Program

Objective

After completing this lesson, you will be able to create a 'Hello World' application

A 'Hello World' App in ABAP

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 'Hello World' Application

Task 1: 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 the 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_WORLD where ## is your group number, and enter a description for your class.

    4. Choose Add... (next to the Interfaces group box).

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

    6. Choose Next.

    7. Select 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
      Copy code
      Switch to dark mode
      123
      out->write( 'Hello World' ).
  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.

Log in to track your progress & complete quizzes