No STATUS-GUI da tela onde vai ser gravado a variante habilitar o comando salvar.
Codificar no user-command da tela as funções do botão
Abaixo o código F_SAVE_VARIANT
Como tinha muitos parâmetros em tela eu utilizei a função DYNPRO_FIELD_GET dentro do perform F_DYNPRO_FIELD_GET e fiz um filtro eliminando os campos de tela que não são variáveis, no meu caso eu tenho uma tela com 2 subtelas diferentes então eu pego os campos conforme a tela q estou trabalhando.
*&---------------------------------------------------------------------*
*& Form F_SAVE_VARIANT
*&---------------------------------------------------------------------*
FORM f_save_variant .
DATA: lt_sval TYPE TABLE OF sval,
lt_rspar TYPE TABLE OF rsparams,
lt_varit TYPE TABLE OF varit,
lt_dyn TYPE TABLE OF rsdcf,
lt_field TYPE TABLE OF fieldname,
lt_range TYPE TABLE OF rsvarrange.
DATA: lw_sval TYPE sval,
lw_rspar TYPE rsparams,
lw_varit TYPE varit,
lw_varid TYPE varid,
lw_dyn TYPE rsdcf,
lw_range TYPE rsvarrange.
DATA: l_retcode TYPE char1,
l_tab TYPE tabname,
l_subrc TYPE sy-subrc,
l_offset TYPE i,
l_function TYPE char50.
FIELD-SYMBOLS: <lfs_par> TYPE any,
<lfst_selopt> TYPE ANY TABLE,
<lfsw_selopt> TYPE ANY.
DEFINE lm_comp.
ASSIGN COMPONENT &1 OF STRUCTURE <lfsw_selopt> TO <lfs_par>.
IF sy-subrc = 0.
&2 = <lfs_par>.
ENDIF.
END-OF-DEFINITION.
CLEAR lw_sval.
lw_sval-tabname = 'RSVAR'.
lw_sval-fieldname = 'VARIANT'.
lw_sval-field_obl = 'X'.
APPEND lw_sval TO lt_sval.
CLEAR lw_sval.
lw_sval-tabname = 'VARIT'.
lw_sval-fieldname = 'VTEXT'.
lw_sval-field_obl = 'X'.
APPEND lw_sval TO lt_sval.
CALL FUNCTION 'POPUP_GET_VALUES'
EXPORTING
no_value_check = 'X'
popup_title = text-006
IMPORTING
returncode = l_retcode
TABLES
fields = lt_sval
EXCEPTIONS
error_in_fields = 1
OTHERS = 2.
CHECK sy-subrc = 0 AND l_retcode <> 'A'.
* Tabellen initialisieren
CLEAR: lt_varit[], lt_rspar[].
CLEAR lw_varit.
*fill VARID structure - variant description
LOOP AT lt_sval INTO lw_sval.
CASE lw_sval-fieldname.
WHEN 'VARIANT'.
lw_varid-variant = lw_sval-value.
WHEN 'VTEXT'.
lw_varit-vtext = lw_sval-value.
ENDCASE.
ENDLOOP.
lw_varid-report = sy-repid.
lw_varid-environmnt = 'A'.
lw_varit-mandt = sy-mandt.
lw_varit-langu = sy-langu.
lw_varit-report = sy-repid.
lw_varit-variant = lw_varid-variant.
APPEND lw_varit TO lt_varit.
CLEAR lt_dyn[].
PERFORM f_dynpro_field_get TABLES lt_dyn
USING '1000'.
IF r_novo = 'X'.
PERFORM f_dynpro_field_get TABLES lt_dyn
USING '9001'.
ELSE.
PERFORM f_dynpro_field_get TABLES lt_dyn
USING '1002'.
ENDIF.
LOOP AT lt_dyn INTO lw_dyn.
CASE lw_dyn-dynpro_fld(2).
WHEN 'P_' OR 'R_'.
ASSIGN (lw_dyn-dynpro_fld) TO <lfs_par>.
CHECK sy-subrc = 0.
CLEAR lw_rspar.
lw_rspar-selname = lw_dyn-dynpro_fld.
lw_rspar-kind = 'P'.
lw_rspar-sign = 'I'.
lw_rspar-option = 'EQ'.
lw_rspar-low = <lfs_par>.
lw_rspar-high = space.
APPEND lw_rspar TO lt_rspar.
WHEN 'S_'.
l_tab = lw_dyn-dynpro_fld.
FIND '-' IN l_tab MATCH OFFSET l_offset.
CHECK l_offset <> 0.
CONCATENATE l_tab+0(l_offset) '[]' INTO l_tab.
ASSIGN (l_tab) TO <lfst_selopt>.
CHECK sy-subrc = 0.
LOOP AT <lfst_selopt> ASSIGNING <lfsw_selopt>.
CLEAR lw_rspar.
lw_rspar-selname = l_tab.
lw_rspar-kind = 'S'.
lm_comp 'SIGN' lw_rspar-sign.
lm_comp 'OPTION' lw_rspar-option.
lm_comp 'LOW' lw_rspar-low.
lm_comp 'HIGH' lw_rspar-high.
APPEND lw_rspar TO lt_rspar.
ENDLOOP.
ENDCASE.
ENDLOOP.
*Check variant
CALL FUNCTION 'RS_VARIANT_EXISTS'
EXPORTING
report = lw_varid-report
variant = lw_varid-variant
IMPORTING
r_c = l_subrc
EXCEPTIONS
not_authorized = 01
no_report = 02
report_not_existent = 03
report_not_supplied = 04.
IF sy-subrc <> 0.
MESSAGE e001(vl) WITH text-e22 DISPLAY LIKE 'S'.
ENDIF.
IF l_subrc = 0. " Variante existiert
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = text-007
text_question = text-008
display_cancel_button = space
IMPORTING
answer = l_retcode
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
CHECK sy-subrc = 0 AND l_retcode = '1'.
l_function = 'RS_CHANGE_CREATED_VARIANT'.
ELSE.
l_function = 'RS_CREATE_VARIANT'.
ENDIF.
CALL FUNCTION l_function
EXPORTING
curr_report = lw_varid-report
curr_variant = lw_varid-variant
vari_desc = lw_varid
TABLES
vari_contents = lt_rspar
vari_text = lt_varit
EXCEPTIONS
illegal_report_or_variant = 01
illegal_variantname = 02
not_authorized = 03
not_executed = 04
report_not_existent = 05
report_not_supplied = 06
variant_doesnt_exist = 07
variant_locked = 08
selections_no_match = 09.
l_subrc = sy-subrc.
ENDFORM. " F_SAVE_VARIANT
*&---------------------------------------------------------------------*
*& Form F_DYNPRO_FIELD_GET
*&---------------------------------------------------------------------*
FORM f_dynpro_field_get TABLES ft_dyn STRUCTURE rsdcf
USING f_dynnr TYPE sy-dynnr.
DATA: lt_tline TYPE TABLE OF tline,
lt_dyn_aux TYPE TABLE OF rsdcf.
DATA: lw_tstc TYPE tstc.
lw_tstc-dypno = f_dynnr.
lw_tstc-pgmna = sy-repid.
CALL FUNCTION 'DYNPRO_FIELD_GET'
EXPORTING
dynpro = lw_tstc-dypno
program = lw_tstc-pgmna
TABLES
dynp_fields = lt_dyn_aux
lines = lt_tline
EXCEPTIONS
dynpro_not_found = 1
OTHERS = 2.
DELETE lt_dyn_aux
WHERE flg11 EQ '00'
OR dynpro_fld EQ space
OR dynpro_fld(1) EQ '%'
OR dynpro_fld CS '-HIGH'.
APPEND LINES OF lt_dyn_aux TO ft_dyn.
ENDFORM. " F_DYNPRO_FIELD_GET
=======================================================
Abaixo o código para o botão de exibição de variante.
*&---------------------------------------------------------------------*
*& Form F_VARIANT_DISPLAY
*&---------------------------------------------------------------------*
FORM f_variant_display .
DATA: l_variant TYPE rsvar-variant.
PERFORM f_choose_variant CHANGING l_variant.
IF l_variant NE space.
CALL FUNCTION 'RS_SUPPORT_SELECTIONS'
EXPORTING
report = sy-repid
variant = l_variant
EXCEPTIONS
variant_not_existent = 1
variant_obsolete = 2
OTHERS = 3.
ENDIF.
ENDFORM. " F_VARIANT_DISPLAY
*&---------------------------------------------------------------------*
*& Form F_CHOOSE_VARIANT
*&---------------------------------------------------------------------*
FORM f_choose_variant CHANGING f_variant TYPE rsvar-variant.
DATA: l_vtext TYPE rsvar-vtext.
CALL FUNCTION 'RS_VARIANT_CATALOG'
EXPORTING
report = sy-repid
masked = 'X'
IMPORTING
sel_variant = f_variant
sel_variant_text = l_vtext
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.
ENDFORM. " F_CHOOSE_VARIANT