Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Save a Variant on a Subscreen

Hi Folks,

I am facing an issue with saving variants on a subscreen. I initiall solved the issue by creating parameters on the subscreen, passing the values back into global variables. Using the values in those global variables to create a variant (code below).

It worked satisfactorily, however I now have an issue. The user needs to store a value longer than 45 characters but the vari_contents table in function module RS_CREATE_VARIANT only stores a maximum of 45 characters as it is using the SAP standard RSPARAMS table.

However if I have a standard selection screen on a report I can store the 60 characters I need to. I am trying to use the function module 'RS_VARIANT_SAVE_FROM_SELSCREEN' but it keeps returning that I don't have a selection screen (I do but the selection screen is screen 1000 and my variant is being saved on screen 9040).

Apart from that, any other FMs I see to save variants all use the RSPARMS table and therefore are restricted to 45 characters.

Does anyone have any idea how I can achieve my requirement: Save a variant from a subscreen with values of more than 45 characters.

Thanks for any help,

Colm

How I save my variant currently:

  PERFORM build_sel_tab TABLES li_int_tab
                        USING 'P_CONTEX'
                              v_contex.

  PERFORM build_sel_tab TABLES li_int_tab
                      USING 'P_SAGENC'
                            v_sagenc.

  PERFORM build_sel_tab TABLES li_int_tab
                      USING 'P_SSCHEM'
                            v_sschem.

  PERFORM build_sel_tab TABLES li_int_tab
                    USING 'P_SVALUE'
                          v_svalue.

  PERFORM build_sel_tab TABLES li_int_tab
                    USING 'P_RAGENC'
                          v_ragenc.

  PERFORM build_sel_tab TABLES li_int_tab
                    USING 'P_RSCHEM'
                          v_rschem.

  CALL FUNCTION 'POPUP_TO_MODIFY_TEXT'
    EXPORTING
     titel                = 'Save Variant'
   IMPORTING
     answer               = answer
     value1               = lv_value1
   EXCEPTIONS
     titel_too_long       = 1
     OTHERS               = 2.

  variant_name = lv_value1 .
  lv_strlen = STRLEN( variant_name ).

  lv_variant_fail = 'N'.
  IF sy-subrc <> 0.
    lv_variant_fail = 'Y'.
  ELSEIF answer = 'N'.
    lv_variant_fail = 'Y'.
  ELSEIF variant_name IS INITIAL.
    lv_variant_fail = 'Y'.
  ELSEIF lv_strlen > 14.
    lv_variant_fail = 'Y'.
  ENDIF.

  CLEAR lv_value1.
  CALL FUNCTION 'POPUP_TO_MODIFY_TEXT'
    EXPORTING
     textline3            = 'Variant Description'
     titel                = 'Save Variant'
   IMPORTING
     answer               = answer
     value1               = lv_value1
   EXCEPTIONS
     titel_too_long       = 1
     OTHERS               = 2.

  lv_variant_des = lv_value1 .
  lv_strlen = STRLEN( lv_variant_des ).

  IF sy-subrc <> 0.
    lv_variant_fail = 'Y'.
  ELSEIF answer = 'N'.
    lv_variant_fail = 'Y'.
  ELSEIF variant_name IS INITIAL.
    lv_variant_fail = 'Y'.
  ELSEIF lv_strlen > 30.
    lv_variant_fail = 'Y'.
  ENDIF.

  DATA lv_uzeit TYPE sy-uzeit.
  lv_uzeit = sy-uzeit.
  REFRESH lt_varianttext.
  CLEAR lt_varianttext.
  TRANSLATE variant_name TO UPPER CASE.
  lt_varianttext-mandt    = sy-mandt.                       " gr 46A
  lt_varianttext-langu    = sy-langu.
  lt_varianttext-report   = sy-repid.
  lt_varianttext-variant  = variant_name.
  lt_varianttext-vtext    =  lv_variant_des.
  APPEND lt_varianttext.

  CLEAR ls_variantdesc.
  ls_variantdesc-mandt   = sy-mandt.                        " gr 46A
  ls_variantdesc-report  = sy-repid.
  ls_variantdesc-variant =  variant_name.
  ls_variantdesc-environmnt = 'A'.          " Online & Batch
  ls_variantdesc-ename   = sy-uname.
  ls_variantdesc-edat    = sy-datum.
  ls_variantdesc-etime   = sy-uzeit.

  curr_report = sy-repid.
  curr_variant =  variant_name.

  ls_vscreens-dynnr = '9040'.
  APPEND ls_vscreens TO lt_vscreens.

  IF lv_variant_fail = 'Y'.
    MESSAGE 'Variant did not save' TYPE 'W'.
  ELSE.
    CALL FUNCTION 'RS_CREATE_VARIANT'
      EXPORTING
        curr_report               = curr_report
        curr_variant              = curr_variant
        vari_desc                 = ls_variantdesc
      TABLES
        vari_contents             = li_int_tab
        vari_text                 = lt_varianttext
        vscreens                  = lt_vscreens
      EXCEPTIONS
        illegal_report_or_variant = 1
        illegal_variantname       = 2
        not_authorized            = 3
        not_executed              = 4
        report_not_existent       = 5
        report_not_supplied       = 6
        variant_exists            = 7
        variant_locked            = 8
        OTHERS                    = 9.
    IF sy-subrc = 0.
      MESSAGE 'Variant Saved' TYPE 'S'.
    ENDIF.
  ENDIF.

Former Member
Not what you were looking for? View more on this topic or Ask a question