Chapter 03 Β· Foundations
Your First ABAP Program
Write, activate, and run your very first ABAP program β the Hello World moment that makes everything click. Both ABAP Cloud and Classic ABAP covered.
Your environment is ready. In Chapter 2, you set up your ABAP environment β either a free BTP Trial ABAP Cloud instance or a paid company SAP system β and connected Eclipse ADT to it.
This is the chapter where you finally write code. Not a demo, not a screenshot β your own ABAP program, running on your own system, activated and executed within the next 20 minutes.
It will be a simple “Hello World” program. But the journey of activation, syntax checking, and console output that you go through here is the exact same journey you will follow for every ABAP program you ever write, from simple reports to full RAP business objects. And this chapter shows you both paths: ABAP Cloud and Classic ABAP.
π― Who Is This Chapter For?
This chapter serves both types of ABAP learners. Here is how to read it:
- If you are on the FREE BTP Trial β follow the π’ green dual path boxes. You will write Hello World as an ABAP Cloud class in Eclipse ADT using
cl_demo_output. - If you have PAID SAP access (company or institute) β follow the π΅ blue dual path boxes. You will write Hello World both ways: as an ABAP Cloud class in Eclipse ADT (modern approach) and as a Classic ABAP report in SE38 using
WRITE(traditional approach). - Both paths teach the same core concept: write, activate, run. The tooling differs; the workflow and thinking are identical.
π― What You Will Learn in This Chapter
- How ABAP Cloud organizes code β packages, classes, and the object model
- How to create a package in Eclipse ADT β both paths
- How to create an ABAP Cloud class and write Hello World in it β both paths
- How to write Classic ABAP Hello World in SE38 using
WRITEβ paid path - How to activate code and interpret syntax check messages
- How to run your program and see the output
- How the same concept maps across two different editors
π§ Which Path Should I Choose?
Before writing code, decide which path applies to you. This chapter has two tracks running in parallel.
Two learner types β find yourself
cl_demo_output. This is the modern, upgrade-safe approach and what most new SAP development uses in 2026.
WRITE). Learning both makes you a more versatile developer and prepares you for interviews that test either approach.
What You Can Do With Each Path
| Task | π’ Free Path (BTP Trial) | π΅ Paid Path (SAP System) |
|---|---|---|
| Hello World in ABAP Cloud | β Eclipse ADT | β Eclipse ADT |
| Hello World in Classic ABAP | β Not available | β SAP GUI SE38 |
| Output method (Cloud) | cl_demo_output=>write( ) | cl_demo_output=>write( ) |
| Output method (Classic) | N/A | WRITE statement |
| Editor for Cloud | Eclipse ADT | Eclipse ADT |
| Editor for Classic | N/A | SAP GUI (SE38, SE80) |
| Activation shortcut (Cloud) | Ctrl + F3 | Ctrl + F3 |
| Activation shortcut (Classic) | N/A | Ctrl + F2 |
| Run shortcut (Cloud) | F9 | F9 |
| Run shortcut (Classic) | N/A | F8 |
π How ABAP Organizes Code
Before writing a single line, you need to understand how ABAP structures its code. It is very different from writing a script.
In Classic ABAP, you can write a simple report in SE38 and run it directly. In ABAP Cloud, everything is structured. Think of it as a hierarchy:
| Level | What it is | Analogy |
|---|---|---|
| Package | A folder that groups related development objects | A project folder on your desktop |
| Class | A container for code β methods, variables, logic | A file inside that folder |
| Method | A block of code that does one job | A single chapter inside the file |
| Statement | A single instruction ending with a period | A single sentence |
You will learn classes and methods in detail in Chapter 8. For now, we just need one class with one method to run our Hello World.
Cloud Structure Only
In ABAP Cloud you only work with packages and classes. There is no “report program” concept in the classic sense.
- Create a package
- Create a class inside it
- Write a method
- Activate and run
Both Structures
In Classic ABAP you can also write a standalone report program in SE38 β no package or class required. You will write both versions.
- Cloud structure (same as free path)
- Plus Classic report program in SE38
- Two ways, same concept
π¦ Step 1: Create Your First Package
Every development object in ABAP Cloud must belong to a package. Think of the package as your project’s home address. This step is the same for both free and paid learners (working in ABAP Cloud).
Launch Eclipse and expand your ABAP Cloud Project in the Project Explorer on the left side.
Right-click on your project folder, then go to New β ABAP Package.
Enter a name like ZHELLO_WORLD. The Z prefix is the standard naming convention for custom objects in SAP β it tells the system this is customer-developed, not SAP standard.
Add a short description like “Chapter 3 Hello World Practice”.
When prompted, use the default transport request (or create a new one). Click Finish. Your package is now created and active.
Package Created in Cloud
Your package ZHELLO_WORLD is ready. Move to Step 2 to create your first class.
Package Created in Cloud + Classic Next
Your package is ready in your ABAP Cloud project. You will also do a Classic ABAP version in Step 6 using SE38 β no package needed there.
ποΈ Step 2: Create Your First ABAP Cloud Class
In ABAP Cloud, code lives inside classes. This is not optional. Even a simple Hello World program is a class with a method that runs it. Both paths do this step.
In the Project Explorer, right-click on ZHELLO_WORLD, then go to New β ABAP Class.
Enter a name like ZCL_HELLO_WORLD. The ZCL_ prefix is the convention for classes (Z for custom, CL for class).
Add a description like “My first ABAP class”.
Eclipse will generate a default class skeleton with a definition and an implementation section. Click Finish.
The ABAP editor opens with your new class. Notice the two main parts:
- Definition: declares what the class contains (methods, variables)
- Implementation: contains the actual code of each method
ZCL_ convention and that it is unique in your system. Names are case-sensitive in the definition but the compiler will resolve them.
βοΈ Step 3: Write the ABAP Cloud Hello World (Both Paths)
Now for the moment you have been waiting for. Replace the default class skeleton with the following code. Type it out rather than copy-pasting β muscle memory matters more than you think at this stage.
CLASS zcl_hello_world DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
CLASS-METHODS run.
ENDCLASS.
CLASS zcl_hello_world IMPLEMENTATION.
METHOD run.
cl_demo_output=>write( 'Hello World from ABAP Cloud!' ).
cl_demo_output=>display( ).
ENDMETHOD.
ENDCLASS.
Let’s break it down line by line.
The Definition Section
CLASS zcl_hello_world DEFINITION PUBLIC FINAL CREATE PUBLIC.
- PUBLIC: The class can be used from anywhere in the system
- FINAL: Nobody can inherit from this class (fine for now)
- CREATE PUBLIC: Anyone can create an instance of this class
CLASS-METHODS run. declares a single static method called run. A static method can be called without creating an object β perfect for our simple program.
The Implementation Section
METHOD run. begins the actual logic.
cl_demo_output=>write( 'Hello World from ABAP Cloud!' ). calls a built-in SAP utility class that collects output.
cl_demo_output=>display( ). opens a window and shows everything collected.
ENDMETHOD. closes the method.
WRITE directly. In ABAP Cloud, cl_demo_output is the modern, upgrade-safe way to display simple output. It is available in every ABAP Cloud system without any configuration.
β‘ Step 4: Activate Your Class (Both Paths)
In ABAP Cloud, nothing runs until it is activated. Activation is the compiler’s way of checking your code is correct and making it available to the runtime.
Press Ctrl + S. Eclipse auto-saves, but this also triggers a background syntax check.
Press Ctrl + F3 (or click the Activate icon on the toolbar, which looks like a small flame).
If everything is correct, you will see a green “Activation successful” message in the status bar.
If activation fails, Eclipse shows the errors in the Problems view at the bottom. Common causes:
- Missing period: Every ABAP statement ends with a period.
- Wrong class name: Make sure the name in the definition and implementation sections match exactly.
- Typo in
cl_demo_output: The method iswrite, notwritelnoroutput.
Fix the issue, save, and activate again.
βΆοΈ Step 5: Run Your ABAP Cloud Program (Both Paths)
Your code is activated. Now it is time to see it come alive.
Press F9, or right-click anywhere in the class editor and choose Run As β ABAP Application (Console).
Eclipse will open a console view at the bottom of the screen showing:
Hello World from ABAP Cloud!
Take a moment to appreciate what just happened. You connected to an SAP system, wrote code in SAP’s enterprise language, compiled it, and executed it. This is exactly what ABAP developers do every day.
You Are Done With the Cloud Version
Skip Step 6 (Classic ABAP) and go to the Bonus section to personalize your output. Then take the practice task and quiz.
Now Try Classic ABAP
You have run the Cloud version. Now let’s do the same thing in Classic ABAP using SAP GUI and SE38 β the traditional way 70% of ABAP jobs still work today.
π΅ Step 6: Classic ABAP Hello World in SE38 (Paid Path Only)
Free path learners: skip this section. You do not have SAP GUI access, so you cannot do this. That is fine β the Cloud version you already ran is what modern development uses.
Paid path learners: This is your bonus. You will now write the same Hello World in Classic ABAP. This is how 70% of ABAP developers still work today, and it is essential for interviews that test classic skills.
Open your SAP GUI client and log in with your credentials. You will see the SAP Easy Access menu screen.
In the command field at the top of the screen, type SE38 and press Enter. This opens the ABAP Editor.
In the Program field, type a name like ZHELLO_WORLD_REPORT. Click Create.
In the dialog that appears:
- Title: My First ABAP Report
- Type: Executable program
- Status: Save as a test object (or assign to a transport if your company requires it)
Click Save.
In the editor that opens, type the following code:
REPORT zhello_world_report.
WRITE: 'Hello World from Classic ABAP!',
/ 'I am learning ABAP in 2026.'.
Notice the differences from the Cloud version:
- There is no class β the program is standalone
- We use
REPORTat the top to declare the program type - We use the
WRITEstatement to output text - The slash (
/) at the start of the second line means “new line” - The colon after
WRITE:lets you chain multiple statements
WRITE statements because programs are self-contained. ABAP Cloud requires the modern structure to enforce Clean Core principles. Same concept, different syntax.
Press Ctrl + F2 to perform a syntax check. If there are errors, they will appear at the bottom.
Press Ctrl + F2 again (or click the Activate icon) to activate the program. You will see a confirmation message.
Press F8 (or click the Execute icon). The output appears on screen:
Hello World from Classic ABAP!
I am learning ABAP in 2026.
Cloud Only β That Is Fine
You have learned ABAP Cloud, which is where all new SAP development is heading. In interviews you will be tested on Cloud for modern roles and can describe Classic conceptually.
You Now Know Both
You have hands-on experience with both ABAP Cloud and Classic ABAP. This makes you a more versatile candidate and covers 100% of ABAP interview topics.
π¨ Bonus: Make It Yours
Before you move on, personalize the program. Change the strings to include your name.
π’ Free Path β ABAP Cloud
cl_demo_output=>write( 'Hello World, my name is Rahul!' ).
cl_demo_output=>write( 'I am learning ABAP in 2026.' ).
cl_demo_output=>display( ).
π΅ Paid Path β Classic ABAP
REPORT zhello_world_report.
WRITE: 'Hello World, my name is Rahul!',
/ 'I am learning ABAP in 2026.'.
Notice that you can call write or WRITE multiple times. Each call adds a new line to the output.
Save, activate (Ctrl + F3 for Cloud, Ctrl + F2 for Classic), and run again (F9 for Cloud, F8 for Classic). Your name is now printed by an SAP system.
π§ What Just Happened Under the Hood
Understanding the mechanics behind those three steps β write, activate, run β will help you debug faster and think like a developer. The table below shows both paths.
| Phase | What SAP Does | Cloud (Free) | Classic (Paid) |
|---|---|---|---|
| Write | Nothing yet β code is just text | Type in Eclipse ADT | Type in SE38 |
| Syntax Check | Reads your code, flags errors | Auto on save | Ctrl + F2 |
| Activate | Compiles, stores the active version | Ctrl + F3 | Ctrl + F2 |
| Run | Loads active version and executes it | F9 | F8 |
| Output | Sends result to the console/screen | Console view | Classic list |
The active version is what runs. If you edit the code but forget to activate, the old version runs. This trips up beginners constantly. Remember the rule: save, activate, run.
π Chapter Summary
- ABAP Cloud organizes code in a strict hierarchy: package β class β method β statement.
- Classic ABAP also allows standalone report programs in SE38 with direct
WRITEstatements. - Every Cloud class belongs to a package. Custom objects use the
Zprefix. - Cloud Hello World:
cl_demo_output=>write( )andcl_demo_output=>display( ). - Classic Hello World:
REPORTandWRITEstatements. - Both use the same rhythm: save, activate, run. Only the shortcuts differ.
- Free path learners master the Cloud version. Paid path learners master both.
π€ Interview Questions & Answers
These are the most common ABAP beginner interview questions. Being able to explain Hello World in both Cloud and Classic forms signals you understand the fundamentals.
A package is a container that groups related development objects β it is like a folder. A class is a single object that contains code. Every class must belong to a package.
Think of it this way: a package is the project folder; a class is a file inside that folder; a method is a chapter inside the file.
Activation is the compilation step. When you activate, SAP checks your code for syntax errors and stores a compiled version in the system. Only the active version can run.
If you edit code and forget to activate, the previous active version still runs. This is why the rhythm of ABAP development is always save, activate, run. In Cloud this is Ctrl + F3, in Classic it is Ctrl + F2.
The Z prefix is the standard SAP naming convention for customer-developed objects. It tells the system that the object is not part of SAP standard delivery β it is created by the customer.
Common prefixes include ZCL_ for classes, ZIF_ for interfaces, and Z_ or ZR_ for other custom objects. Following naming conventions is mandatory in real SAP projects because it keeps custom development separate from SAP standard during upgrades.
WRITE is the classic ABAP statement for output. It works only in classic report programs and on-premise systems. It is not permitted in ABAP Cloud.
cl_demo_output is a modern utility class that works in both Classic ABAP and ABAP Cloud. It collects output and displays it in a formatted window. In ABAP Cloud, it is the standard way to produce simple console output for learning and testing.
For real production applications, output is usually delivered through Fiori apps and OData services, which we cover in Chapter 19.
A static method belongs to the class itself, not to an instance of the class. This means you can call it without creating an object.
We used CLASS-METHODS run because Hello World does not need any object state β it just prints a string. For a simple program, a static method is the simplest possible structure.
In contrast, an instance method requires you to create an object with CREATE OBJECT or NEW before calling it. Instance methods are used when the method needs access to instance-specific data.
Yes. In ABAP Cloud, you write a class with a static method that calls cl_demo_output=>write( ) and cl_demo_output=>display( ), then activate with Ctrl + F3 and run with F9.
In Classic ABAP, you write a standalone report program in SE38 with a REPORT statement at the top and WRITE statements for output, then activate with Ctrl + F2 and run with F8.
Both follow the same rhythm β write, activate, run β but use different tools. Knowing both makes you a stronger and more versatile ABAP developer.
π Practice Task for This Chapter
Complete the tasks for your path before moving to Chapter 4. Each takes about 20 minutes and solidifies everything you just learned.
π’ Free Path (BTP Trial)
- Create a new class called
ZCL_PRACTICE_CH3inside your package. - Add a static method called
run. - Inside the method, print three lines using
cl_demo_output=>write( ):- Your name
- Your city
- The reason you are learning ABAP
- Save (Ctrl + S), activate (Ctrl + F3), and run (F9).
- Take a screenshot of the output as proof of completion.
π΅ Paid Path (SAP System)
- Complete all the free path steps above in ABAP Cloud (Eclipse ADT).
- Then open SE38 in SAP GUI and create a report called
ZPRACTICE_CH3_REPORT. - Inside the report, use
WRITEto print the same three lines: your name, your city, and your reason for learning ABAP. - Check syntax (Ctrl + F2), activate (Ctrl + F2), and run (F8).
- Screenshot both outputs β Cloud and Classic β as proof you can work in both environments.
Test: Kon Banega Crorepati?
5 questions. βΉ1 Crore. Prove you understood Chapter 3. No pressure β restart anytime.
Explore Our Instructor-Led SAP & IT Courses
Self-study works. But if you want guided training, real project practice, and placement support β here are the courses we offer. Book a free demo before you decide.
WhatsApp us