Overview Entering values via
dropdown lists is fast and user-friendly. The S10 Framework
supports constant value lists, automatic generation of value
lists based on the SAP Data Dictionary and also dynamic
generation in a separate ABAP method.
Example 1: Constant value list
To do this, define an attribute in the ABAP class for the
value of the drop-down list, e.g.
ABAP
data:
orderlimit type string.
And in HTML a <label> as well as a <select> element with one
<option> element per value:
The ABAP method called in this example is "select_orders".
The selected value is automatically available in the variable
"orderlimit". Details on the function "S10Apply" can be found in
the article S10Apply().
With the addition "required" you can achieve that before
sending the screen data to the application; a check is made that
the user has selected a value:
The S10 framework builds the dropdown list according to the
value tables T005 and T005T listed in the data dictionary for
"kna1-land1". Details can be found in the article
s10dropdownlist().
Value lists that are not compiled from customizing tables but
are constantly stored in the data dictionary can also be
displayed in this way. For example, the following values are
stored in the SAP Data Dictionary for "document status" with the
corresponding language-dependent texts:
Example 3: Value list generated dynamically in an
ABAP method
Here, the contact persons stored in the SAP system for a
customer are offered for selection as a drop-down list. The
value list is built up dynamically in an ABAP method depending
on the current client number. The following should be noted:
Create the value list as a class attribute of the type
"string "
It is best to then define a build method for this, in
which the import parameters determine which other attributes
the value list is dependent on. This ensures that
the value list is rebuilt if an import attribute has
changed.
The value list consists of lines separated from each
other by line feeds
Each line consists of the value, a tab character and the
text
A line feed at the end of the list is ignored
The value list is automatically sorted by the S10
framework for display, by key values if they are displayed,
otherwise by the text
ABAP
data:
kunnr type kna1-kunnr,
parnr type knvk-parnr,
ddl_contacts type string.
methods:
build_ddl_contacts
importing
kunnr type kna1-kunnr
exporting
ddl_contacts type string.
method build_ddl_contacts.
clear ddl_contacts.
data: knvk type knvk.
select parnr namev name1 from knvk
into corresponding fields of knvk
where kunnr = kunnr.
ddl_contacts =
ddl_contacts
&& knvk-parnr
&& cl_abap_char_utilities=>horizontal_tab
&& knvk-namev
&& | |
&& knvk-name1
&& cl_abap_char_utilities=>cr_lf.
endselect.
endmethod.