abap2UI5

Basics I

The smallest app that runs: one class, one view_display( ), a Page with a title - the shape every other sample starts from.

Z2UI5_CL_SMP_APP_493

Learn Basics UI5 1.71

The facts

Repository
abap2UI5/samples
Class
Z2UI5_CL_SMP_APP_493
Source file
z2ui5_cl_smp_app_493.clas.abap
Category
Basics
Learning path
Start here
Minimum UI5
1.71 — the floor abap2UI5 holds its samples to
In the playground
runs in the browser, with no system and nothing installed
Documentation
abap2ui5.github.io/docs/get_started/hello_world ↗

Keywords: hello, world, smallest, first, app, minimal, start, here, template

Controls it builds

Read out of the builder chain by the abap2UI5 linter, not from the category this sample is filed under — which is what makes “which samples build one of these” a question the catalogue can answer at all.

Libraries

Run it here

The sample running, in this page — the app on its own, with no editor over it. Switch to Playground with this code

Nothing is installed and nothing is sent anywhere: the ABAP is compiled to JavaScript in this browser and runs against abap2UI5 itself.

The ABAP

z2ui5_cl_smp_app_493.clas.abap — 52 lines Read it on GitHub ↗
" @keywords hello world smallest first app minimal start here template
" @summary The smallest app that runs: one class, one view_display( ), a Page with a title - the shape every other sample starts from.
" @docs https://abap2ui5.github.io/docs/get_started/hello_world https://abap2ui5.github.io/docs/cookbook/view/definition https://abap2ui5.github.io/docs/cookbook/expert_more/snippets https://abap2ui5.github.io/docs/tutorials/walkthrough/step-1
CLASS z2ui5_cl_smp_app_493 DEFINITION PUBLIC.

  PUBLIC SECTION.
    INTERFACES z2ui5_if_app.

  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.


CLASS z2ui5_cl_smp_app_493 IMPLEMENTATION.

  METHOD z2ui5_if_app~main.

    IF client->check_on_navigated( ).

      DATA(view) = z2ui5_cl_ui5_view_builder=>factory(
          )->ele( n = `View` ns = `mvc`
              )->a( n = `displayBlock` v = `true`
              )->a( n = `height`       v = `100%`
              )->a( n = `xmlns`        v = `sap.m`
              )->a( n = `xmlns:mvc`    v = `sap.ui.core.mvc`
              )->a( n = `xmlns:core`   v = `sap.ui.core` ).
      DATA(page) = view->ele( `Shell`
          )->ele( `Page`
              )->a( n = `title`          v = `abap2UI5 - Basics I - Hello World, the Smallest App`
              )->a( n = `showNavButton`  b = client->check_app_prev_stack( )
              )->a( n = `navButtonPress` v = client->_event_nav_app_leave( ) ).

      page->tag( `MessageStrip`
          )->a( n = `text`     v = `The whole app is what you see below: a class implementing z2ui5_if_app, ` &&
                     `one main( ) method, a view built as XML and handed to client->view_display( ). ` &&
                     `abap2UI5 calls main( ) on every roundtrip - here only the first one matters, ` &&
                     `which is what check_on_init( ) asks. Copy this class as the starting point ` &&
                     `for your own app.`
          )->a( n = `type`     v = `Information`
          )->a( n = `showIcon` b = abap_true
          )->a( n = `class`    v = `sapUiSmallMargin` ).

      page->tag( `Title`
          )->a( n = `text`  v = `Hello World`
          )->a( n = `class` v = `sapUiSmallMargin`
          )->a( n = `level` v = `H2` ).
      client->view_display( view->stringify( ) ).

    ENDIF.

  ENDMETHOD.
ENDCLASS.

More in Basics

Search every abap2UI5 sample · the full list on one page

On this page