I am looking to make a selection screen in which I have to take an input of the table name and then based of which table is selected I have to ask for some parameters.
I tried to use POPUP_TO_GET_VALUE / POPUP_GET_VALUES
but it does not help because I need to use select option instead of just value.
For dynamic select options you can use free selections. Wrote a little sample program to demonstrate the usage. You can check the FM's documentation and FM's parameters for more customized behavior.
TYPE-POOLS: rsds.
DATA: ls_field TYPE rsdsfields,
lt_field TYPE STANDARD TABLE OF rsdsfields,
l_selid TYPE dynselid,
l_repid TYPE sy-repid,
ls_pfkey TYPE rsdspfkey,
lt_trange TYPE rsds_trange.
START-OF-SELECTION.
ls_field-tablename = 'T001'.
ls_field-fieldname = 'BUKRS'.
ls_field-type = 'S'.
APPEND ls_field TO lt_field.
CALL FUNCTION 'FREE_SELECTIONS_INIT'
EXPORTING
kind = 'F'
IMPORTING
selection_id = l_selid
TABLES
fields_tab = lt_field[].
ls_pfkey-program = sy-repid.
CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
EXPORTING
selection_id = l_selid
title = 'Select Company'
as_window = 'X'
pfkey = ls_pfkey
tree_visible = ''
IMPORTING
field_ranges = lt_trange
TABLES
fields_tab = lt_field[]
EXCEPTIONS
internal_error = 1
no_action = 2
selid_not_found = 3
illegal_status = 4
OTHERS = 5.
The user selection can be found in lt_trange
.