Part 1 · Foundations

#5Hello World: A Classrun for the Browser

The shape abap2UI5 copied from if_oo_adt_classrun - one interface, one method, and it runs - and why a one-class app is one thing to read.

2 min read · 5 of 42

Every ABAP developer already knows the smallest program that does something:

CLASS zcl_sample_adt DEFINITION PUBLIC.
  PUBLIC SECTION.
    INTERFACES if_oo_adt_classrun.
ENDCLASS.

CLASS zcl_sample_adt IMPLEMENTATION.
  METHOD if_oo_adt_classrun~main.
    out->write( `Hello World` ).
  ENDMETHOD.
ENDCLASS.

One interface, one method, F9. No transaction, no program, no repository object beside it. It runs where it was written, and every ABAP developer has used it to answer a question in thirty seconds.

abap2UI5 copied that form on purpose. This is a complete app:

CLASS zcl_sample_ui5 DEFINITION PUBLIC.
  PUBLIC SECTION.
    INTERFACES z2ui5_if_app.

  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.

CLASS zcl_sample_ui5 IMPLEMENTATION.
  METHOD z2ui5_if_app~main.
    client->message_toast_display( `Hello World` ).
  ENDMETHOD.
ENDCLASS.

The form is the same; only the output goes somewhere else. The second class runs in a browser instead of the console and follows the Fiori design guidelines. You can send it to a colleague as a URL, where the first one needs the instruction to open ADT and press F9. People open a link; an instruction gets postponed.

One property deserves a mention. A small application is one class, and a class is one thing to read: state, screen and logic in the same place, top to bottom. A reviewer, a colleague inheriting it, a search across the system, an agent asked to change something — each can hold the whole thing at once. Code that is understood in one piece is code that gets changed confidently.

That holds for the small screens this series keeps coming back to. A larger app splits into several classes like any other ABAP program does, and how is its own article. The point is where it starts.

In short: the smallest abap2UI5 app is one class that implements z2ui5_if_app, with one method, main.