Skip to Content

changing field values in free selections/ multiple variants

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


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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: selctab TYPE STANDARD TABLE OF rsscr.
        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.