You can use a combination of function modules FREE_SELECTIONS_INIT
and FREE_SELECTIONS_DIALOG
. (You can trigger this off a button that you put on the dynpro). The function modules are a bit complicated, but they have online documentation.
To extend your dynpro to simulate the select-option from a report selection screen, you can show the low and high values from the first row of the selected data.
Here is an example to get you started (The documentation for function module FREE_SELECTIONS_DIALOG
in fact contains some sample code):
report ztest_free_seldiag.
data: lv_selid type RSDYNSEL-SELID.
data: lt_fld type table of RSDSFIELDS.
data: ls_fld type RSDSFIELDS.
ls_fld-tablename = 'T001'.
ls_fld-fieldname = 'BUKRS'.
append ls_fld to lt_fld.
call function 'FREE_SELECTIONS_INIT'
EXPORTING
KIND = 'F'
IMPORTING
SELECTION_ID = lv_selid
TABLES
FIELDS_TAB = lt_fld
EXCEPTIONS
FIELDS_INCOMPLETE = 1
FIELDS_NO_JOIN = 2
FIELD_NOT_FOUND = 3
NO_TABLES = 4
TABLE_NOT_FOUND = 5
EXPRESSION_NOT_SUPPORTED = 6
INCORRECT_EXPRESSION = 7
ILLEGAL_KIND = 8
AREA_NOT_FOUND = 9
INCONSISTENT_AREA = 10
KIND_F_NO_FIELDS_LEFT = 11
KIND_F_NO_FIELDS = 12
TOO_MANY_FIELDS = 13
DUP_FIELD = 14
FIELD_NO_TYPE = 15
FIELD_ILL_TYPE = 16
DUP_EVENT_FIELD = 17
NODE_NOT_IN_LDB = 18
AREA_NO_FIELD = 19
OTHERS = 20.
if sy-subrc <> 0.
* Implement suitable error handling here
exit.
endif.
call function 'FREE_SELECTIONS_DIALOG'
exporting
selection_id = lv_selid
TITLE = 'Select Company Code'
AS_WINDOW = 'X'
TREE_VISIBLE = ' '
* IMPORTING
* WHERE_CLAUSES =
* EXPRESSIONS =
* FIELD_RANGES =
* NUMBER_OF_ACTIVE_FIELDS =
tables
fields_tab = lt_fld
EXCEPTIONS
INTERNAL_ERROR = 1
NO_ACTION = 2
SELID_NOT_FOUND = 3
ILLEGAL_STATUS = 4
OTHERS = 5.
if sy-subrc <> 0.
BREAK-POINT.
exit.
endif.