|
| 1 | +--- |
| 2 | +outline: [2, 4] |
| 3 | +--- |
| 4 | +# Value Help |
| 5 | + |
| 6 | +A field that asks *"which one?"* is the F4 moment of ABAP. abap2UI5 covers the basics with two built-in popups and lets you build anything custom on top. |
| 7 | + |
| 8 | +#### Suggestions on the Input |
| 9 | + |
| 10 | +The lightest variant — type-ahead from a bound list, no popup, no roundtrip after the initial render. Bind `suggestionitems` to an internal table and pick the columns via the `suggestion_item` template: |
| 11 | + |
| 12 | +```abap |
| 13 | +TYPES: BEGIN OF ty_country, |
| 14 | + code TYPE c LENGTH 3, |
| 15 | + name TYPE string, |
| 16 | + END OF ty_country. |
| 17 | +DATA mt_countries TYPE STANDARD TABLE OF ty_country. |
| 18 | +DATA mv_country TYPE string. |
| 19 | +
|
| 20 | +mt_countries = VALUE #( ( code = `DE` name = `Germany` ) |
| 21 | + ( code = `FR` name = `France` ) |
| 22 | + ( code = `IT` name = `Italy` ) ). |
| 23 | +
|
| 24 | +client->view_display( z2ui5_cl_xml_view=>factory( |
| 25 | + )->page( |
| 26 | + )->input( |
| 27 | + value = client->_bind_edit( mv_country ) |
| 28 | + showsuggestion = abap_true |
| 29 | + suggestionitems = client->_bind( mt_countries ) |
| 30 | + )->suggestion_items( |
| 31 | + )->list_item( text = `{CODE}` additionaltext = `{NAME}` |
| 32 | + )->stringify( ) ). |
| 33 | +``` |
| 34 | + |
| 35 | +#### Selection Popup |
| 36 | + |
| 37 | +For a *"pick from this list"* dialog use the built-in `Z2UI5_CL_POP_TO_SELECT`. Pass any internal table, navigate to it as a sub-app, and read the result on return: |
| 38 | + |
| 39 | +```abap |
| 40 | +CLASS z2ui5_cl_sample_f4 DEFINITION PUBLIC. |
| 41 | +
|
| 42 | + PUBLIC SECTION. |
| 43 | + INTERFACES z2ui5_if_app. |
| 44 | + DATA mv_carrid TYPE string. |
| 45 | +
|
| 46 | +ENDCLASS. |
| 47 | +
|
| 48 | +CLASS z2ui5_cl_sample_f4 IMPLEMENTATION. |
| 49 | + METHOD z2ui5_if_app~main. |
| 50 | +
|
| 51 | + CASE abap_true. |
| 52 | +
|
| 53 | + WHEN client->check_on_init( ). |
| 54 | + client->view_display( z2ui5_cl_xml_view=>factory( |
| 55 | + )->page( |
| 56 | + )->input( |
| 57 | + value = client->_bind_edit( mv_carrid ) |
| 58 | + showvaluehelp = abap_true |
| 59 | + valuehelprequest = client->_event( `F4` ) |
| 60 | + )->stringify( ) ). |
| 61 | +
|
| 62 | + WHEN client->check_on_event( `F4` ). |
| 63 | + SELECT carrid, carrname, url FROM scarr INTO TABLE @DATA(lt_carriers). |
| 64 | + client->nav_app_call( z2ui5_cl_pop_to_select=>factory( |
| 65 | + i_tab = lt_carriers |
| 66 | + i_title = `Choose airline` ) ). |
| 67 | +
|
| 68 | + WHEN client->check_on_navigated( ). |
| 69 | + DATA(lo_prev) = CAST z2ui5_cl_pop_to_select( client->get_app_prev( ) ). |
| 70 | + DATA(ls_res) = lo_prev->result( ). |
| 71 | + IF ls_res-check_confirmed = abap_true. |
| 72 | + FIELD-SYMBOLS <row> TYPE any. |
| 73 | + ASSIGN ls_res-row->* TO <row>. |
| 74 | + ASSIGN COMPONENT `CARRID` OF STRUCTURE <row> TO FIELD-SYMBOL(<carrid>). |
| 75 | + mv_carrid = <carrid>. |
| 76 | + ENDIF. |
| 77 | +
|
| 78 | + ENDCASE. |
| 79 | +
|
| 80 | + ENDMETHOD. |
| 81 | +ENDCLASS. |
| 82 | +``` |
| 83 | + |
| 84 | +Pass `i_multiselect = abap_true` for multi-pick; the result table is then in `ls_res-table`. |
| 85 | + |
| 86 | +#### DDIC Search Help |
| 87 | + |
| 88 | +For value helps that exist as DDIC search help objects (`SE11` → search help), the [generic search help builder](https://github.com/axelmohnen/a2UI5-generic_search_hlp) wraps the F4 framework so you can fire any standard search help by name and get the picked row back. Install it like any other [add-on](../../resources/addons.md). |
| 89 | + |
| 90 | +#### Custom Dialog |
| 91 | + |
| 92 | +When neither popup fits — e.g. a filter bar with multiple columns, ranges, fuzzy search — build the F4 as a separate app with its own view and call it via `nav_app_call`. See [Popup → Separated App](../popups/popup.md#separated-app) for the pattern. |
0 commit comments