Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Change Variant Issue [RS_VARIANT_CHANGE]

Former Member
0 Kudos

Hi,

I'm hoping to get some help with the problem below.

There are currently a number of variants set-up to be used with Program RGJVUXDT. On the bottom of the screen on the 2nd tab "Selections" there is a GL Accounts Range. I want to change the GL Accounts Selection Parameters that are associated with the variants.

The problem is I want to do this in an automated manner. A potential solution to this would be to use the RS_Variant* FM's to achieve this. But I have limited experience in the use of them.

Can I achieve the above by using RS_VARIANT_CHANGE? As I can't see any way for me to pass in the parameters I want to change.

Any sample code of a simple example of how to do this would be greatly appreciated.

Many thanks,

Philip Johannesen

2 REPLIES 2

Former Member
0 Kudos

I've managed to write up some template code that works after looking at the range of RS_Variant FM's. If anyone else had a similiar question to mine above then here is a template solution:


REPORT  ZCHANGE_VARIANT.

data:  LS_VARIANTDESC      LIKE VARID,
       ls_report_name type VARI_REPRT,
       ls_variant type VARIANT,
       it_selparam like standard table of RSPARAMS,
       wa_selparam like line of it_selparam.
       CLEAR LS_VARIANTDESC.


  wa_selparam-selname ='S_MATNR'.
  wa_selparam-kind ='S'.
  wa_selparam-sign ='I'.
  wa_selparam-option ='EQ'.
  wa_selparam-low ='10830'.

  append wa_selparam to it_selparam.

  wa_selparam-selname ='S_MATNR'.
  wa_selparam-kind ='S'.
  wa_selparam-sign ='I'.
  wa_selparam-option ='EQ'.
  wa_selparam-low ='10860'.

  append wa_selparam to it_selparam.

  ls_report_name = 'ZDEMO_ALV_001'.
  ls_variant = 'TEST1'.


  LS_VARIANTDESC-REPORT  = ls_report_name.
  LS_VARIANTDESC-VARIANT = ls_variant.
  LS_VARIANTDESC-ENVIRONMNT = 'A'.

  LS_VARIANTDESC-AENAME   = sy-mandt.
  LS_VARIANTDESC-AENAME   = SY-UNAME.
  LS_VARIANTDESC-AEDAT    = SY-DATUM.
  LS_VARIANTDESC-AETIME   = SY-UZEIT.

CALL FUNCTION 'RS_CHANGE_CREATED_VARIANT'
  EXPORTING
    CURR_REPORT                     = ls_report_name
    CURR_VARIANT                    = ls_variant
    VARI_DESC                       = LS_VARIANTDESC
*   ONLY_CONTENTS                   =
  TABLES
    VARI_CONTENTS                   = it_selparam
*   VARI_TEXT                       =
*   VARI_SEL_DESC                   =
*   OBJECTS                         =
* EXCEPTIONS
*   ILLEGAL_REPORT_OR_VARIANT       = 1
*   ILLEGAL_VARIANTNAME             = 2
*   NOT_AUTHORIZED                  = 3
*   NOT_EXECUTED                    = 4
*   REPORT_NOT_EXISTENT             = 5
*   REPORT_NOT_SUPPLIED             = 6
*   VARIANT_DOESNT_EXIST            = 7
*   VARIANT_LOCKED                  = 8
*   SELECTIONS_NO_MATCH             = 9
*   OTHERS                          = 10

Points to note:

Make sure the values of <b>wa_selparam-selname</b>, <b>ls_report_name</b> & <b>ls_variant</b> are Uppercase. Otherwise the variant will not be updated, as the select query makes no match on Table: VARID.

Regards,

Philip Johannesen

0 Kudos

something else to consider is to create/change and delete your variants during run time.

Unless your error handling is tight, you may wind up running your program with a variant it was unable to create/change properly.