Skip to content

Lesson 1 Companion — ABAP Cloud Foundations ​

This companion explains the choices behind Lesson 1 and provides a complete reference solution.

1. Why start with a class instead of an executable report? ​

ABAP Cloud development is class-centric. IF_OO_ADT_CLASSRUN gives students a simple executable entry point without introducing classic report events or legacy report-oriented programming.

The development loop is:

text
class source → syntax check → activation → classrun console

2. Activation matters ​

ABAP repository objects have inactive and active versions. Running the class executes the active version, so students should build the habit:

text
Ctrl+F2 → Ctrl+F3 → F9

3. Explicit vs inline declarations ​

Both are modern ABAP.

Explicit:

abap
DATA price TYPE decfloat34.

Inline:

abap
DATA(price) = CONV decfloat34( '19.95' ).

Use explicit types when the type communicates an important contract; use inline declarations when context already defines the type clearly.

4. Text literals ​

ABAP supports different literal forms. For beginner code:

abap
'fixed text'
`string text`
|template { value }|

String templates are especially useful for output.

5. IS INITIAL ​

Instead of comparing a string with a hand-written blank value, ABAP provides:

abap
IF name IS INITIAL.

This works across many data types and expresses the intent clearly.

6. Boolean convention ​

abap_bool, abap_true, and abap_false are widely used ABAP Boolean conventions. They are intentionally introduced before OOP because later methods will return Boolean results.

7. Reference solution ​

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.

    FINAL(name) = `Maya`.
    DATA(age) = 22.
    FINAL(course) = `ABAP Cloud`.
    DATA(has_paid) = abap_true.

    out->write( |Student: { name }| ).
    out->write( |Age: { age }| ).
    out->write( |Course: { course }| ).

    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.

  ENDMETHOD.

ENDCLASS.

8. Common problems ​

Running old output ​

Activate before running.

out is unknown ​

The class must implement IF_OO_ADT_CLASSRUN and the code must be inside if_oo_adt_classrun~main.

Object naming collision ​

Use the assigned suffix.

Treating Eclipse as the runtime ​

ADT is the client; the active ABAP code runs in the backend.

SAP references ​