Skip to Content

changing field values in free selections/ multiple variants

May 12, 2017 at 07:44 PM


avatar image

Dear Experts,

I wrote report to copy a variant for numerous company codes sing FM's out of SVAR FM-group.

However this does not work for changing/ updating fields in free selections.

Are there any options to change/ update free selections without selection screen,
(not manually since there are a lot of variants to be updated/ changed).

Thanks in advance for your recommendations


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Sandra Rossi May 13, 2017 at 01:00 PM

Maybe the function module RS_VARIANT_VALUE_SAVE could do the stuff. Use parameters P_VARIDYN, P_VDATDYN, P_DYNSFIELDS.

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hello Sandra,

thanks for your response.

I had already checked that fm and I did again. Still I do not see a way for passing a value to a field in the free selections.

The obligatory parameter RKEY is not clear (what is this?)

P_VARIDYN does not allow passing a value

P_VDATDYN seems to be for date values/ ranges only

While testing the FM I also noted that there is a popup window, problably depending on parameter SUBMODE
prompting to enter name etc... of the variant. The goal would be to maintain the free selections not via selection screen popup.




Sorry. Looked at it too quickly; I was thinking of P_VDATDYN which had low and high components but they are of type integer, so they can't store the values.

The solution seems more complex. I see that RS_VARIANT_VALUE_SAVE gets the dynamic selection from DYN_SEL-TEXPR internal table, DYN_SEL being a "common area", which is an old memory shared between programs. You could incorporate DYN_SEL into your custom program by including the include program RSDBCOM4.

Just before calling the function module, you'll simply have to initialize DYN_SEL-TEXPR with the free selections you want, and RS_VARIANT_VALUE_SAVE will be able to read it as it's in the "common area".

Maybe it will be more complex to do it. Just try.

To not display the popup, maybe try creating the program variant using RS_CREATE_VARIANT first (or RS_CREATE_VARIANT_255 if you have parameter values longer than 45 characters).


Hi Sandra,

well I have icorporated the include program RSDBCOM4.

But I guess include RSDBC1XX was the one bringing the breakthrough...

Thank you very much indeed for your Input


Here's a working code - don't touch the subroutine's code, it's very sensitive, if you touch anything it probably break something:

INCLUDE rsdbcom4. " common area DYN_SEL
INCLUDE rsdbc1xx. " common area DYNS_FIELDS
DATA: rkey       TYPE rsvarkey.
rkey-report  = 'DEMO_LIST_FORMAT_COLOR_2'.
rkey-variant = 'SRO2'.
*" initialize values of dynamic selections
DATA ls_table TYPE rsds_expr.
ls_table-tablename = 'SPFLI'.
DATA ls_field TYPE rsdsexpr.
CLEAR ls_field.
ls_field-logop = 'AND'.
ls_field-arity = 2.
APPEND ls_field TO ls_table-expr_tab.
CLEAR ls_field.
ls_field-fieldname = 'CONNID'.
ls_field-option = 'EQ'.
ls_field-low  = '0003'.
ls_field-high = '0000'.
APPEND ls_field TO ls_table-expr_tab.
CLEAR ls_field.
ls_field-fieldname = 'DEPTIME'.
ls_field-option = 'EQ'.
ls_field-low  = sy-uzeit.
ls_field-high = '000000'.
APPEND ls_field TO ls_table-expr_tab.
APPEND ls_table TO dyn_sel-texpr.

PERFORM update_dyn_sel USING rkey.


FORM update_dyn_sel USING rkey TYPE rsvarkey.
  " initialize VARI parameter so that values of VARIDYN below will be used
  DATA lt_vari TYPE TABLE OF rvari.
      program     = rkey-report
      dynnr       = '1000'
      screen_sscr = selctab
      no_objects  = 1
      OTHERS      = 2.
  CHECK sy-subrc = 0.
  PERFORM adjust_vari(saplsvar) TABLES selctab lt_vari.
  " Initialize VARIDYN parameter
  " 1) Pass program name to MODIFY_VARIDYN via global variable of SAPLSVAR.
  "    (a dummy PERFORM needed if SAPLSVAR is not loaded in internal session yet)
  PERFORM dummy_dummy_dummy(saplsvar) IF FOUND.
  FIELD-SYMBOLS <saplsvar_rsvar_report> TYPE simple.
  ASSIGN ('(SAPLSVAR)RSVAR-REPORT') TO <saplsvar_rsvar_report>.
  <saplsvar_rsvar_report> = rkey-report.
  " 2) prepare importing parameter needed to setup VARIDYN
  DATA lt_varidyn TYPE TABLE OF rsvaridyn.
  DATA ls_dyns_field TYPE rsdsfields.
  LOOP AT dyn_sel-texpr INTO ls_table.
    LOOP AT ls_table-expr_tab INTO ls_field WHERE fieldname IS NOT INITIAL.
      ls_dyns_field-tablename = ls_table-tablename.
      ls_dyns_field-fieldname = ls_field-fieldname.
      COLLECT ls_dyns_field INTO dyns_fields.
  " 3) convert into VARIDYN
  PERFORM modify_varidyn(saplsvar) TABLES dyns_fields lt_varidyn.
  " save values (dialog displayed if the variant does not exist yet)
  REFRESH selctab.
      rkey         = rkey
      status       = ' '
      submode      = 'VU'
      selctab      = selctab
      p_vari       = lt_vari
      p_varidyn    = lt_varidyn
      not_executed = 1.