Appearance
Lesson 1 — ABAP Cloud Foundations
This lesson establishes the development workflow used throughout the course.
You will create an ABAP class in Eclipse with ADT, run it with the ABAP Console, and use modern ABAP syntax for values and decisions.
First-time setup
Need to install the tools or connect your trial system? Follow the Eclipse, ADT, and SAP BTP Trial setup guide first. If your ABAP Cloud project already opens in ADT, continue below.
text
Eclipse + ADT
↓
ABAP Cloud project
↓
ABAP class
↓
IF_OO_ADT_CLASSRUN~MAIN
↓
ABAP ConsoleLesson information
| Duration | About 90–120 minutes |
| Environment | SAP BTP ABAP Trial |
| Tooling | Eclipse + ABAP Development Tools |
| Prerequisites | General programming knowledge is helpful but not required |
| Main object | ZCL_ABAP_L01_### |
Learning objectives
After this lesson, you should be able to:
- create or locate a development package in ADT;
- create a global ABAP class;
- implement
IF_OO_ADT_CLASSRUN; - activate and run a console class;
- declare variables with explicit and inline declarations;
- use common elementary ABAP types;
- distinguish text literals from string templates;
- perform arithmetic calculations;
- use comparison and Boolean expressions;
- use
IF,ELSEIF, andELSE; - explain
abap_trueandabap_false; - use
FINAL(...)when a local value should not be reassigned.
Replace ###
Use your assigned suffix in every custom object name.
text
ZCL_ABAP_L01_### → ZCL_ABAP_L01_0171. ABAP Cloud development happens in the backend
Eclipse is your development client. Your ABAP source code is stored, checked, activated, and executed in the connected ABAP backend.
text
Your computer
Eclipse + ADT
↓
ABAP Cloud Project
↓
ABAP backend
↓
active ABAP class
↓
executionThe class does not run locally inside Eclipse.
2. Find your package
In Project Explorer:
- expand your ABAP Cloud project;
- locate the package or structure package assigned for the course;
- create your own development package only if your course setup requires it.
If creating a package:
text
Right-click parent package
→ New
→ ABAP PackageUse the naming convention provided for the course and the transport request assigned to you.
Package responsibility
Packages organize repository objects and define development/transport boundaries. They are not folders on your local computer.
3. Create your first ABAP class
Right-click your package:
text
New
→ ABAP ClassEnter:
text
Name: ZCL_ABAP_L01_###
Description: ABAP Lesson 1Finish the wizard.
ADT creates an inactive class definition.
4. Make the class executable
Use:
abap
CLASS zcl_abap_l01_### DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
ENDCLASS.
CLASS zcl_abap_l01_### IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
out->write( 'Hello from ABAP Cloud' ).
ENDMETHOD.
ENDCLASS.The interface:
text
IF_OO_ADT_CLASSRUNprovides the executable main method and the out object used by these lessons.
5. Check, activate, run
Use these ADT shortcuts:
| Action | Shortcut |
|---|---|
| Syntax check | Ctrl + F2 |
| Activate current object | Ctrl + F3 |
| Run as ABAP Application (Console) | F9 |
| Format source | Shift + F1 |
| Code completion | Ctrl + Space |
Always remember:
text
edit → check → activate → runThe console runs the active version.
6. Variables
ABAP variables can be declared explicitly:
abap
DATA student_name TYPE string.
DATA age TYPE i.
student_name = 'Maya'.
age = 22.Or declared inline when ABAP can infer the type:
abap
DATA(student_name) = `Maya`.
DATA(age) = 22.Both styles are useful.
Use an explicit declaration when the intended type is part of the design. Use inline declarations when the type is already obvious from context.
7. Common elementary types
You will see types such as:
| Type | Purpose |
|---|---|
string | variable-length character text |
c LENGTH n | fixed-length character data |
i | integer |
decfloat34 | decimal floating-point calculations |
d | date |
t | time |
abap_bool | ABAP Boolean convention |
Example:
abap
DATA product_code TYPE c LENGTH 6 VALUE 'A10001'.
DATA quantity TYPE i VALUE 4.
DATA unit_price TYPE decfloat34 VALUE '12.50'.
DATA active TYPE abap_bool VALUE abap_true.Numeric design
For business decimal calculations, prefer an appropriate decimal type such as decfloat34 rather than using integer arithmetic for values that can contain fractions.
8. Output with out->write
Write one value:
abap
out->write( student_name ).Write a text message:
abap
out->write( 'Registration result' ).Write a string template:
abap
out->write( |Student: { student_name }, Age: { age }| ).String templates are useful because expressions inside { ... } are evaluated and inserted into the resulting string.
9. Arithmetic expressions
ABAP uses familiar arithmetic operators:
abap
DATA(quantity) = 4.
DATA(unit_price) = CONV decfloat34( '12.50' ).
DATA(total) = quantity * unit_price.
out->write( |Total: { total }| ).Common operators:
text
+ addition
- subtraction
* multiplication
/ divisionParentheses make precedence explicit:
abap
DATA(result) = ( 10 + 5 ) * 2.10. Comparisons
Examples:
abap
age >= 18
quantity = 0
student_name <> ``
total > 100Useful relational operators include:
text
= equal
<> not equal
< less than
> greater than
<= less than or equal
>= greater than or equal11. Decisions with IF
abap
IF age >= 18.
out->write( 'Adult' ).
ELSE.
out->write( 'Under 18' ).
ENDIF.Use ELSEIF when several mutually exclusive conditions are tested:
abap
IF score >= 80.
out->write( 'High' ).
ELSEIF score >= 50.
out->write( 'Medium' ).
ELSE.
out->write( 'Low' ).
ENDIF.Order matters: the first true branch is executed.
12. Boolean values in ABAP
The conventional Boolean type is:
abap
abap_booland the constants are:
abap
abap_true
abap_falseExample:
abap
DATA registered TYPE abap_bool VALUE abap_true.
IF registered = abap_true.
out->write( 'Registered' ).
ENDIF.ABAP Boolean conventions are character-based rather than a separate built-in Boolean primitive like some other languages. Use the ABAP Boolean type/constants rather than inventing your own Y/N convention.
13. Immutable local values with FINAL
If a value should be assigned once and then remain unchanged, use an immutable inline declaration:
abap
FINAL(course_name) = `ABAP Cloud`.This is useful for local values whose immutability makes the code easier to understand.
It is different from a class-level CONSTANTS declaration, which you will learn later.
14. Build a Student Registration Checker
Inside main, create values such as:
text
name
age
course
has_paidApply rules:
text
age must be at least 18
name must not be empty
course must not be empty
payment must be completeProduce a readable result using a string template.
A possible shape is:
abap
IF name IS INITIAL.
out->write( 'Name is required' ).
ELSEIF age < 18.
out->write( 'Student is too young for this registration' ).
ELSEIF course IS INITIAL.
out->write( 'Course is required' ).
ELSEIF has_paid = abap_false.
out->write( 'Payment is required' ).
ELSE.
out->write( |{ name } is registered for { course }| ).
ENDIF.15. Modern ABAP habits from the beginning
Prefer:
text
inline DATA(...) where the type is obvious
FINAL(...) for immutable local values
string templates
functional method calls later in the course
NEW and VALUE constructor expressions later in the course
clear names
small responsibilitiesAvoid copying older ABAP syntax merely because it appears in legacy examples. ABAP Cloud uses the modern ABAP language environment and restricted/released APIs.
16. Summary
You can now:
text
create an ABAP class
implement IF_OO_ADT_CLASSRUN
activate and run it
create values
write output
perform calculations
make decisions
work with ABAP Boolean valuesThe next lesson introduces ABAP's main in-memory collection type:
text
internal tables