Developing your First ABAP Program
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
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.
Choose File → New → ABAP Package.
Enter the name ZS4D400_##, where ## is your group number.
Enter a description for your package.
Choose Next.
Enter the software component, ZLOCAL, and choose Next.
Mark Create a new request and enter a description for the new transport request.
Choose Finish.
Add the package to your favorites.
Expand your ABAP project tree until you can see the node Favorite Packages.
Right-click and choose Add Package.
In the dialog box, enter the package name ZS4D400_##, where ## is your group number.
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
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.
Choose File → New → ABAP Class.
Enter your package ZS4D400_##, where ## is your group number.
Enter the name ZCL_##_HELLO_WORLDwhere ## is your group number, and enter a description for your class.
Choose Add... (next to the Interfacesgroup box).
Enter the filter text IF_OO_ADT_CLASSRUN. Double-click the matching entry in the hit list.
Choose Next.
Mark Choose from requests in which I am involved and your own transport request.
Choose Finish.
In the if_oo_adt_classrun~main( ) method, use out->write( )
to output the phrase Hello World.
In the editor, enter the following coding between METHOD if_oo_adt_classrun~main
and ENDMETHOD.
:
Activate and test your class.
Activate the class with the keyboard shortcut Ctrl + F3.
Run the class with the F9 key.
Check the output in the Console view of eclipse.
Check the Console view that should have opened as a new tab below the editor view.
If the Console view is not visible, open it by choosing Window → Show view → Other. Double-click Console in the hit list.
Save progress to your learning plan by logging in or creating an account
Login or Register