data:
myattrname type string,
myvaluelist type string,
myddlstring type string.
myddlstring =
s10dropdownlist(
exporting
attrname = myattrname
valuelist = myvaluelist ).
Parameters
Name
Type
Description
attrname
string
Attribute name
valuelist
string
Value list (filter)
ddlstring
string
Dropdown list
Description
The s10dropdownlist() method is implicitly called by the S10 framework when the
dropdown list for an attribute is requested in HTML for a class attribute
"attr" via "attr@dropdownlist". Example:
HTML
The S10 framework automatically builds the dropdown list from the information
in the SAP Data dictionary. You can specify in HTML whether the internal codes
should also be displayed, or only the texts. Example:
s10dropdownlist() always returns the values in alphabetical order of the keys.
If you turn off the display of the keys in HTML, the dropdown list will be
displayed sorted by the text:
The dropdown list is returned as a string in which the key and the text are
separated by a TAB character and the entries by a line feed. Here is the display
of the country list in the ABAP Debugger:
If the default dropdown list contains too many values, you can include a value
list as a filter. Since the call to s10dropdownlist() for the value list in
HTML is implicitly made by the S10 framework, this requires overriding the
s10dropdownlist() method in your class.
We show the procedure using the
country list and assume that you only want to offer a selection of countries in
the dropdown list for selection.
methods:
s10dropdownlist redefinition.
* redefinition of s10dropdownlist() for certain attributes
method s10dropdownlist.
case to_lower( attrname ).
when 'countries01'.
ddlstring = super->s10dropdownlist(
exporting
attrname = 'land1'
valuelist = 'AT,AU,BE,CA,CH,DE,FR,IT' ).
* call up super method for all other attributes
when others.
ddlstring = super->s10dropdownlist(
exporting
attrname = attrname
valuelist = valuelist ).
endcase.
endmethod.
Dynamically generated lists are also possible. For example, when selecting
customers, it would make sense to offer only those countries in which there
actually are customers. We can either implement this again with the same inheritance
mechanism or build the list ourselves without s10dropdownlist(). We show both
methods here.
methods:
s10dropdownlist redefinition.
* redefinition of s10dropdownlist() for certain attributes
method s10dropdownlist.
case to_lower( attrname ).
when 'countries01'.
ddlstring = super->s10dropdownlist(
exporting
attrname = 'land1'
valuelist = 'AT,AU,BE,CA,CH,DE,FR,IT' ).
when 'countries02'.
* build up country code list from existing customers
data:
valuelist02 type string,
tabland1 type table of kna1-land1.
select distinct land1 from kna1 into table tabland1.
concatenate lines of tabland1 into valuelist02
separated by ','.
ddlstring = super->s10dropdownlist(
exporting
attrname = 'land1'
valuelist = valuelist02 ).
* call up super method for all other attributes
when others.
ddlstring = super->s10dropdownlist(
exporting
attrname = attrname
valuelist = valuelist ).
endcase.
endmethod.