Select-options with saved variants for your abap2UI5 apps - generated from a table name or your data.
You pass a database table name or an internal table; range-filter builds
one select-option per field, lets the user enter ranges in a popup, and saves
and loads the whole selection as a variant. Your app gets the filter back and
turns it into a SQL WHERE clause or filters an internal table with it. For
developers of abap2UI5 apps that read data on user-defined criteria.
Documentation · Guide · range-filter or abap-cloud-gui?
Part of abap2UI5-addons - addons and apps for abap2UI5, installed with abapGit.
In SAP GUI a report gets its selection screen and variants for free with
SELECT-OPTIONS. In a UI5 app each filter field, its range dialog and the
variant handling would have to be built by hand.
range-filter does that generically: it reads the fields via RTTI, renders
the select-options either inline in your page or as a filter popup, and keeps
variants in its own table z2ui5_t_13 - per app, optionally per user, with a
default variant.
Good for:
- Data browsers and reports on abap2UI5 that select from a database table.
- Filtering an internal table the user already sees, with ranges instead of a search field.
The data browser abap2UI5-addons/se16n builds its selection on range-filter.
Requirements
- ABAP Cloud (S/4 Public Cloud, BTP ABAP Environment), S/4 Private Cloud or On-Premise, or SAP NetWeaver AS ABAP 7.50 or higher
- NetWeaver 7.02 - 7.40: the branch
702, downported automatically frommainon every push - pull abap2UI5 from its702branch as well - abap2UI5
Steps - with abapGit, in this order:
- abap2UI5
- this repository (branch
main, on NetWeaver 7.02 - 7.40702) - classes and the tablez2ui5_t_13for the variants; nothing else to set up
Start - run a sample like any abap2UI5 app, e.g.
?app_start=z2ui5_cl_sel_sample_01 for select-options over table T100.
All samples are listed under Samples.
To run a second copy next to the original in the same system, rename it the
way abap2UI5 itself is renamed: run the workflow build-rename (Actions →
build-rename → Run workflow) with the name your abap2UI5 installation was
renamed to - e.g. ZMYUI5 or /CA2UI5/. It pushes the branch rename_<name>, in
which every object and every reference to abap2UI5 and to the addons this one
needs carries that name; pull it with abapGit. Rename abap2UI5 and every addon
of the installation with the same name.
Select-options for every field of a database table, inline in your page
(condensed from z2ui5_cl_sel_sample_01):
" DATA mo_multiselect TYPE REF TO z2ui5_cl_sel_multisel.
METHOD z2ui5_if_app~main.
IF client->check_on_init( ).
mo_multiselect = z2ui5_cl_sel_multisel=>factory_by_name( val = `T100`
s_variant = VALUE #( handle01 = `ZMY_APP` ) ).
view_display( ). " calls mo_multiselect->set_output( client = client view = lo_panel )
RETURN.
ENDIF.
" range popups, Clear, Load and Save variant are handled here
IF mo_multiselect->main( client ).
RETURN.
ENDIF.
IF client->check_on_event( `GO` ).
DATA(lv_where) = z2ui5_cl_sel_context=>filter_get_sql_where( mo_multiselect->ms_result-t_filter ).
SELECT FROM t100 FIELDS * WHERE (lv_where) INTO TABLE @mt_t100 UP TO 100 ROWS.
client->view_model_update( ).
ENDIF.
ENDMETHOD.The select-options are bound to the view, so ms_result-t_filter - field
names included - comes back from the browser. Before the names go into a
dynamic WHERE, keep only those that are fields of your table, as
z2ui5_cl_sel_sample_01 does: a forged name could otherwise carry a condition
or a subquery on another table.
As a filter popup over an internal table (condensed from
z2ui5_cl_sel_sample_02):
" on init
mo_variant = z2ui5_cl_sel_multisel_pop=>factory_by_data( data = mt_table
var_handle1 = `ZMY_APP` ).
" on the Filter button
client->nav_app_call( mo_variant ).
" back in your app
IF client->check_on_navigated( ).
DATA(lo_filter) = CAST z2ui5_cl_sel_multisel_pop( client->get_app_prev( ) ).
IF lo_filter->result( )-check_confirmed = abap_true.
z2ui5_cl_sel_context=>filter_itab( EXPORTING filter = lo_filter->result( )-t_filter
CHANGING val = mt_table ).
ENDIF.
ENDIF.- Select-options for every field of a database table or an internal table
- Ranges entered in a popup - inline in your page or as a filter popup
- Variants saved and loaded - per app, optionally per user, with a default
| Class | Purpose |
|---|---|
z2ui5_cl_sel_multisel |
select-options for a table name (factory_by_name), for data (factory_by_data) or for a filter (factory_by_filter); renders into your view with set_output( ), handles its events in main( ) |
z2ui5_cl_sel_multisel_pop |
the same as a popup app; returns the filter with result( ) |
z2ui5_cl_sel_var_pop_read, z2ui5_cl_sel_var_pop_save |
popups to load and save a variant |
z2ui5_cl_sel_var_db |
variant persistence in table z2ui5_t_13 |
range-filter is a building block for an abap2UI5 app you build yourself: the
filter fields come from a table or your data, at runtime, and your app does
the rest. For an app that works like a classic report - a selection screen
with PARAMETERS, SELECT-OPTIONS, radio buttons and event blocks, then a
list or an ALV - or to convert the reports you have, use
abap2UI5-addons/abap-cloud-gui.
| Question | Use |
|---|---|
| Do I build the UI5 app myself and only need filters? | range-filter |
| Are the filter fields known only at runtime (any table)? | range-filter |
| Does the app work like a report (selection, then output)? | abap-cloud-gui |
| Does the report exist already in SAP GUI? | abap-cloud-gui, converted with report2UI5 |
This repository was called selection-screen until it was renamed to say
what it is; GitHub forwards the old address. The ABAP objects keep their
names (z2ui5_cl_sel_*, table z2ui5_t_13), so an installation pulls on
as before.
| Sample | Shows |
|---|---|
z2ui5_cl_sel_sample_01 |
Select-options for table T100 inline in the page, result read with a dynamic WHERE |
z2ui5_cl_sel_sample_02 |
Filter popup over an internal table |
npm ci
npm run check # all gates below, as in CI
npm run lint # abaplint, Standard ABAP (v750)
npm run check:cloud # abaplint, ABAP Cloud
npm run check:abap2ui5 # abap2UI5-linter over apps and views
npm run rename # namespace rename check
npm run downport # downport the source to 7.02 syntax
npm run site # the GitHub Pages site (VitePress) into build/site
npm run site:dev # the same with the VitePress dev serverIssues and pull requests are welcome - whether you're fixing bugs, adding new functionality, or improving documentation. Read CONTRIBUTING.md first.
MIT - see LICENSE.