Step 8: Selection Screen
Real apps rarely show all the data at once. They ask first: a selection screen on top, a result below, and a button between them. This step adds that form — and with it the way a real app reads its data.
The invoice record gains a delivery date, so there is a date to select on:
CLASS zcl_app_walkthrough DEFINITION PUBLIC.
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
TYPES:
BEGIN OF ty_s_invoice,
product TYPE string,
supplier TYPE string,
quantity TYPE string,
delivery_date TYPE string,
END OF ty_s_invoice.
DATA:
BEGIN OF s_search,
supplier TYPE string,
date_from TYPE string,
date_to TYPE string,
END OF s_search.
DATA t_invoices TYPE STANDARD TABLE OF ty_s_invoice WITH EMPTY KEY.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_app_walkthrough 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 = `xmlns` v = `sap.m`
)->a( n = `xmlns:mvc` v = `sap.ui.core.mvc`
)->a( n = `xmlns:form` v = `sap.ui.layout.form` ).
DATA(page) = view->ele( `Shell`
)->ele( `Page`
)->a( n = `title` v = `Walkthrough - Step 8` ).
page->ele( n = `SimpleForm` ns = `form`
)->a( n = `title` v = `Selection`
)->a( n = `editable` v = `true`
)->ele( n = `content` ns = `form`
)->tag( `Label`
)->a( n = `text` v = `Supplier`
)->tag( `Input`
)->a( n = `value` v = client->_bind( s_search-supplier )
)->tag( `Label`
)->a( n = `text` v = `Delivery Date From`
)->tag( `DatePicker`
)->a( n = `value` v = client->_bind( s_search-date_from )
)->a( n = `valueFormat` v = `yyyy-MM-dd`
)->tag( `Label`
)->a( n = `text` v = `Delivery Date To`
)->tag( `DatePicker`
)->a( n = `value` v = client->_bind( s_search-date_to )
)->a( n = `valueFormat` v = `yyyy-MM-dd`
)->tag( `Button`
)->a( n = `text` v = `Read Invoices`
)->a( n = `press` v = client->_event( `READ` )
)->a( n = `type` v = `Emphasized` ).
page->ele( `List`
)->a( n = `headerText` v = `Invoices`
)->a( n = `items` v = client->_bind( t_invoices )
)->ele( `items`
)->tag( `StandardListItem`
)->a( n = `title` v = `{PRODUCT}`
)->a( n = `description` v = `{SUPPLIER}`
)->a( n = `info` v = `{DELIVERY_DATE}` ).
client->view_display( view->stringify( ) ).
ELSEIF client->check_on_event( `READ` ).
" demo data — in your system, replace this with a SELECT, e.g.:
" SELECT product, supplier, quantity, delivery_date
" FROM zinvoice
" WHERE supplier LIKE @( |%{ s_search-supplier }%| )
" AND delivery_date >= @s_search-date_from
" AND delivery_date <= @( COND #( WHEN s_search-date_to IS INITIAL
" THEN `9999-12-31`
" ELSE s_search-date_to ) )
" INTO TABLE @t_invoices.
" (an empty field filters nothing, as with the DELETEs below)
t_invoices = VALUE #(
( product = `Pineapple` supplier = `ACME` quantity = `21` delivery_date = `2026-07-15` )
( product = `Milk` supplier = `Green Growers` quantity = `4` delivery_date = `2026-07-20` )
( product = `Canned Beans` supplier = `Corner Deli` quantity = `3` delivery_date = `2026-08-01` )
( product = `Salad` supplier = `Green Growers` quantity = `2` delivery_date = `2026-08-10` )
( product = `Bread` supplier = `Corner Deli` quantity = `1` delivery_date = `2026-08-12` ) ).
IF s_search-supplier IS NOT INITIAL.
" NS = `contains no string` — drop the rows whose supplier does not match
DELETE t_invoices WHERE supplier NS s_search-supplier.
ENDIF.
IF s_search-date_from IS NOT INITIAL.
DELETE t_invoices WHERE delivery_date < s_search-date_from.
ENDIF.
IF s_search-date_to IS NOT INITIAL.
DELETE t_invoices WHERE delivery_date > s_search-date_to.
ENDIF.
ENDIF.
ENDMETHOD.
ENDCLASS.You should see
A form titled Selection with the fields Supplier, Delivery Date From and Delivery Date To, and a button Read Invoices. The list under it is empty. Press the button: the list fills. Enter a supplier and press it again: only that supplier's invoices stay.
What Is New
This step is longer than the ones before, but only one idea is new: the app asks first and reads the data on an event, not at the start. The other points below are details of the form. Read them when you need them.
The New Idea
- The event handler reads data, and nothing else. No
view_display( )in theREADbranch: the view already exists in the browser, onlyt_invoiceschanged, and every roundtrip that changed bound data pushes the new model by itself. - The
SELECTis the point. In your system the demo data and the threeDELETEs are oneSELECTwith aWHEREclause. abap2UI5 does not abstract the database layer. Reading and writing stays plain ABAP, which makes it easy to plug into code you already have.
Details of the Form
- A form, from a second statement. The chain is split:
viewholds the root,pageholds thePage, and the form and the list are each filled frompagein a statement of their own. That is the shape most abap2UI5 apps use once a view has more than one part — see View → Definition. sap.ui.layout.formneeds its own namespace.xmlns:formis declared on the root next toxmlns:mvc, andSimpleFormand itscontentaggregation are written withns = `form`. ASimpleFormlays out label/field pairs by itself — no grid, no widths.DatePickerwithvalueFormat. The picker shows the date in the user's locale and hands your ABAP attribute the format you asked for — hereyyyy-MM-dd, so a string comparison sorts correctly. ThevalueFormathas to match the ABAP type behind the binding:yyyy-MM-ddis the shape astringcompares by and the one an ABAPdtravels in, so the same pattern works for both — see Formatter → Date.
Next, the list becomes a real table.
Working Samples
Complete apps from the sample catalog that use what this page describes. Each is a single class in abap2UI5/samples unless its row names another of the three sample repositories — pull that repository with abapGit and start the class with ?app_start=<class>.
| Sample | Class |
|---|---|
| Editable Cells, Add and Delete Rows | Z2UI5_CL_SMP_APP_011 |
