There is an easy method to obtain the values you want without dealing with screen creation. For this, there is a standard function in SAP; POPUP_GET_VALUES.
Let’s illustrate its usage with an example.
data : lt_fields type standard table of sval,
ls_field type sval,
lv_popup_title type string,
lv_returncode type char1.
lv_popup_title = 'Popup Value Screen'.
ls_field-tabname = 'BKPF'.
ls_field-fieldname = 'BUKRS'.
ls_field-value = '1000'. " default value
ls_field-field_attr = '01'. " label blue, text red
append ls_field to lt_fields.
clear ls_field.
ls_field-tabname = 'BKPF'.
ls_field-fieldname = 'BELNR'.
ls_field-field_attr = '02'. "label black, no input
append ls_field to lt_fields.
clear ls_field.
ls_field-tabname = 'BKPF'.
ls_field-fieldname = 'GJAHR'.
ls_field-field_attr = '03'. "label blue, no input
append ls_field to lt_fields.
clear ls_field.
ls_field-tabname = 'BKPF'.
ls_field-fieldname = 'BLART'.
ls_field-field_attr = '04'. "no display
append ls_field to lt_fields.
clear ls_field.
ls_field-tabname = 'BKPF'.
ls_field-fieldname = 'BLDAT'.
ls_field-field_obl = 'X'. "required
append ls_field to lt_fields.
clear ls_field.
call function 'POPUP_GET_VALUES'
exporting
popup_title = lv_popup_title
start_column = '5'
start_row = '5'
importing
returncode = lv_returncode
tables
fields = lt_fields
exceptions
error_in_fields = 1
others = 2.
if sy-subrc <> 0.
* Implement suitable error handling here
endif.
if lv_returncode eq 'A'.
"Cancel
elseif lv_returncode eq ''.
"OK
endif.
You can read the values returned from the value field by iterating through lt_fields.
When you first open the sentence