i_dynnr type sy-dynnr -> subscreen number
method get_variant_for_ss.
data: ft_params type table of rsparams.
data: f_variant type rsvar-variant.
data: f_text type rsvar-vtext.
data: fs_params type rsparams.
data: fs_paramsscr type rsparams.
data f_fieldname type fieldname.
data: ft_sscr type table of rsscr.
field-symbols <any_selopt_itab> type standard table.
field-symbols <any_selopt> type any.
field-symbols <any_field> type any.
"now I will display pop-up with variants for one subscreen
call function 'RS_VARIANT_CATALOG'
exporting
report = sy-repid
* NEW_TITLE = ' '
dynnr = i_dynnr
* INTERNAL_CALL = ' '
* MASKED = 'X'
* VARIANT = ' '
pop_up = 'X'
importing
sel_variant = f_variant
sel_variant_text = f_text
* TABLES
* BELONGING_DYNNR = BELONGING_DYNNR
exceptions
no_report = 1
report_not_existent = 2
report_not_supplied = 3
no_variants = 4
no_variant_selected = 5
variant_not_existent = 6
others = 7
.
if sy-subrc eq 0 .
"if variant was supplied then I read its content
call function 'RS_VARIANT_CONTENTS'
exporting
report = sy-repid
variant = f_variant
move_or_write = 'M'
* NO_IMPORT = ' '
* EXECUTE_DIRECT = ' '
* IMPORTING
* SP = SP
tables
* L_PARAMS = L_PARAMS
* L_PARAMS_NONV = L_PARAMS_NONV
* L_SELOP = L_SELOP
* L_SELOP_NONV = L_SELOP_NONV
valutab = ft_params
* OBJECTS = OBJECTS
* FREE_SELECTIONS_DESC = FREE_SELECTIONS_DESC
* FREE_SELECTIONS_VALUE = FREE_SELECTIONS_VALUE
exceptions
variant_non_existent = 1
variant_obsolete = 2
others = 3
.
if sy-subrc eq 0.
"let's see what fields are on this subscreen
call function 'RS_ISOLATE_1_SELSCREEN'
exporting
program = sy-repid
dynnr = i_dynnr
* TABIX = 0
* IMPORTING
* LAST_TABIX = LAST_TABIX
tables
screen_sscr = ft_sscr
* GLOBAL_SSCR = GLOBAL_SSCR
exceptions
no_objects = 1
others = 2
.
if sy-subrc eq 0.
sort ft_sscr by name ascending.
" clear current content of selection fields
loop at ft_params into fs_params.
read table ft_sscr with key name = fs_params-selname binary search transporting no fields.
if sy-subrc ne 0.
continue.
endif.
concatenate '(' sy-repid ')' fs_params-selname into f_fieldname.
case fs_params-kind.
when 'S'.
concatenate f_fieldname '[]' into f_fieldname.
assign (f_fieldname) to <any_selopt_itab>.
if sy-subrc eq 0.
refresh <any_selopt_itab>.
endif.
when 'P'.
assign (f_fieldname) to <any_field>.
if sy-subrc eq 0.
clear <any_field>.
endif.
when others.
endcase.
endloop.
"add values from saved variant to selection fields
loop at ft_params into fs_params.
read table ft_sscr with key name = fs_params-selname binary search transporting no fields.
if sy-subrc ne 0.
continue.
endif.
concatenate '(' sy-repid ')' fs_params-selname into f_fieldname.
case fs_params-kind.
when 'S'. "select-options
concatenate f_fieldname '[]' into f_fieldname.
assign (f_fieldname) to <any_selopt_itab>.
if sy-subrc eq 0.
"firstly append initial line to be able to assign components
append initial line to <any_selopt_itab> assigning <any_selopt>.
"now fill each component separately
assign component 'SIGN' of structure <any_selopt> to <any_field>.
if sy-subrc eq 0.
<any_field> = fs_params-sign.
endif.
assign component 'OPTION' of structure <any_selopt> to <any_field>.
if sy-subrc eq 0.
<any_field> = fs_params-option.
endif.
assign component 'LOW' of structure <any_selopt> to <any_field>.
if sy-subrc eq 0.
<any_field> = fs_params-low.
endif.
assign component 'HIGH' of structure <any_selopt> to <any_field>.
if sy-subrc eq 0.
<any_field> = fs_params-high.
endif.
"just to be sure that select options are filled
assign component 'SIGN' of structure <any_selopt> to <any_field>.
if sy-subrc ne 0.
delete table <any_selopt_itab> from <any_selopt>.
elseif <any_field> is initial.
delete table <any_selopt_itab> from <any_selopt>.
endif.
endif.
when 'P'. "parameters
assign (f_fieldname) to <any_field>.
if sy-subrc eq 0.
clear <any_field>.
<any_field> = fs_params-low.
endif.
when others.
endcase.
endloop.
endif.
endif.
endif.
endmethod.