Part 3 · A Working Day

#17The Client API: What the Client Can Do

The whole of z2ui5_if_client by shape - show a screen, bind data, read the event, navigate, message, follow-up actions - before knowing it by name.

2 min read · 17 of 42

The app implements one interface with one method. The single parameter of that method is the other interface, z2ui5_if_client. It is everything an app can ask the framework for, and it is small. The table groups its methods by what the app wants to do:

The app wants to… …and calls
show a screen view_display( ), popup_display( ), popover_display( ), nest_view_display( )
put ABAP data on that screen _bind( ) — the attribute, by reference, both directions
find out what the user did check_on_event( ), get_event( ), get_event_arg( )
find out why main( ) was called check_on_init( ), check_on_navigated( )
talk to the user message_toast_display( ), message_box_display( )
move to another app and back nav_app_call( ), nav_app_leave( ), get_app_prev( )
ask the browser to do something follow_up_action( ) with a cs_event constant
know where it runs get( ) — device, launchpad, URL parameters, the raw event

The main view fills the screen; a nested view is a part of it, a popup lies on top of it, a popover sits beside one control.

The four places the first row of the table fills.

The API is small enough to remember, and that was a design goal.

Two of the smallest rows do the most work. _bind( ) takes an ABAP variable and returns the binding path the view needs; the framework builds the model around whatever was bound, ships it, and writes the user’s changes back into the same variable:

    )->tag( `Input`
        )->a( n = `value` v = client->_bind( customer )

And _event( ) names what the frontend should send when a control fires:

    )->tag( `Button`
        )->a( n = `text`  v = `Save`
        )->a( n = `press` v = client->_event( `SAVE` ) ).

Both only return a string. The attribute name and the event name are written into the view and read back from the request; nothing is registered or declared anywhere else.

The last row covers everything that is a browser matter rather than an ABAP matter — focus a field, scroll, copy to the clipboard, download a file, set the tab title, raise the model size limit. Each is a constant in cs_event, and each is one call:

    client->follow_up_action( val   = client->cs_event-set_focus
                              t_arg = VALUE #( ( `inputCustomer` ) ) ).

The full list with every parameter is on the Client API page. It is generated from the interface itself, so it always matches what the framework offers.

In short: an app talks to the framework only through client: show a view, bind data, read the event, navigate, show a message, ask the browser to do something.