Your First ABAP Program

In ABAP Cloud there are no lists (WRITE) — use a class implementing IF_OO_ADT_CLASSRUN and press F9:

4.1 Hello, World (classic report)

REPORT names the executable program (type 1).

Statements end with a period. Keywords are case-insensitive.

WRITE: with a colon is a chained statement: WRITE: a, b. = WRITE a. WRITE b.

/ starts a new line; sy-datum and sy-uzeit are system fields (§44.4).

Comments: * in column 1 (full line) or " (rest of line).

REPORT zhello_world.

WRITE 'Hello, World!'.
NEW-LINE.
WRITE: / 'Today is', sy-datum, 'and the time is', sy-uzeit.

4.2 Creating it

SE38 → program name ZHELLO_WORLD → *Create* → type *Executable program* → package $TMP.

Type the code, Ctrl+F2 (check), Ctrl+F3 (activate), F8 (run).

4.3 Hello, World in ADT / ABAP Cloud (console class)

In ABAP Cloud there are no lists (WRITE) — use a class implementing IF_OO_ADT_CLASSRUN and press F9:

CLASS zcl_hello_world DEFINITION
  PUBLIC FINAL CREATE PUBLIC.
  PUBLIC SECTION.
    INTERFACES if_oo_adt_classrun.
ENDCLASS.

CLASS zcl_hello_world IMPLEMENTATION.
  METHOD if_oo_adt_classrun~main.
    out->write( |Hello, World! Today is { cl_abap_context_info=>get_system_date( ) DATE = ISO }| ).
  ENDMETHOD.
ENDCLASS.

4.4 Program types

Executable (1) Reports, started with F8/SA38/job Module pool (M) Dialog transactions with screens Function group (F) Container for function modules Class pool (K) Interface pool (J)

Source fragment included in other programs Subroutine pool (S) Forms called externally (legacy) Type group (T)

Global types/constants (obsolete; use interfaces/classes)

4.5 Basic syntax rules

DATA lv_count TYPE i VALUE 10.        " declaration
lv_count = lv_count + 1.              " assignment
lv_count += 1.                        " 7.54+ calculation assignment
WRITE: / 'Count:', lv_count.          " chained output
* This whole line is a comment