Application Development and Automation 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: 
Read only

variant name change

Former Member
0 Likes
3,565

I have a z program with 50 variants defined for it, now we want to change all the variants because one common "name of variable" needs to be changed.

is there any faster way we can change all the variants in one go?

I have a z program with 50 variants defined for it, now we want to change all the variants because one common "name of variable" needs to be changed.

is there any faster way we can change all the variants in one go?

11 REPLIES 11
Read only

Former Member
0 Likes
2,951

What do you want to change? A parameter value or Parameter name?

Read only

0 Likes
2,951

both

Read only

0 Likes
2,951

Also what are the tables to keep variant detail?

Read only

0 Likes
2,951

Tables: VARID, VARIT and VARI.

Use this Wiki to change the variants programatically.

http://wiki.sdn.sap.com/wiki/display/Snippets/Mass+Change+of+Variants

Thanks,

Shambu

Read only

0 Likes
2,951

Hi the tables are not useful.

I want to change variant attributes, for example I want to change variant Z1 attribute, one field fiscal year, selection variable:T, name of variable: Zperiod1, (we want to change from Zperiod1 to zperiod2)

It is not appearing in the tables mentioned above

Read only

0 Likes
2,951

VARID table holds all the details related to variants.

Read only

0 Likes
2,951

You will not be able to see the values directly as they are stored in a Cluster table.

Call FM 'RS_VARIANT_CONTENTS' with table L_PARAMS.

This table will have the Selction method and variant variable.

Change this to the new variable and call 'RS_CHANGE_CREATED_VARIANT' with OBJECTS table.

Thanks,

Shambu

Read only

Former Member
0 Likes
2,951

Hi Siva,

Please reffer the below code to change programaticaly.

FORM changevariant .

  DATA: h_rc LIKE sy-subrc.

  DATA: ival TYPE STANDARD TABLE OF rsparams WITH HEADER LINE.

  DATA: ls_variantdesc LIKE varid.

*1st check to see that the variant exists.

  CALL FUNCTION 'RS_VARIANT_EXISTS'

    EXPORTING

      report              = sy-repid

      variant             = variant_name

    IMPORTING

      r_c                 = h_rc

    EXCEPTIONS

      not_authorized      = 01

      no_report           = 02

      report_not_existent = 03

      report_not_supplied = 04.

* If variant exists then obtain the contents of the variants.

  IF h_rc = 0.

    CALL FUNCTION 'RS_VARIANT_CONTENTS'

      EXPORTING

        report                      = sy-repid

        variant                     = variant_name

        move_or_write               = 'W'

*   NO_IMPORT                   = ' '

*   EXECUTE_DIRECT              = ' '

* IMPORTING

*   SP                          =

      TABLES

*   L_PARAMS                    =

*   L_PARAMS_NONV               =

*   L_SELOP                     =

*   L_SELOP_NONV                =

        valutab                     = ival

*   OBJECTS                     =

*   FREE_SELECTIONS_DESC        =

*   FREE_SELECTIONS_VALUE       =

* EXCEPTIONS

*   VARIANT_NON_EXISTENT        = 1

*   VARIANT_OBSOLETE            = 2

*   REPORT_NOT_EXISTENT         = 3

*   OTHERS                      = 4

              .

    IF sy-subrc = 0.

*     Change value of the variants to what you want it to be.

      LOOP AT ival WHERE selname EQ 'PNPBEGDA' OR

                         selname EQ 'PNPBEGPS' OR

                         selname EQ 'PNPENDDA' OR

                         selname EQ 'PNPENDPS'.

        ival-low = ''.

        MODIFY ival.

      ENDLOOP.

      LOOP AT ival WHERE selname EQ 'P_CNGDAT'.

        ival-low  = '20000201'.

        ival-high = '20001231'.

        MODIFY ival.

      ENDLOOP.

*   Now re-save the variant with the appropriate changes.

*     Clear and re-populate the variant description.

      CLEAR ls_variantdesc.

      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                     = sy-repid

          curr_variant                    = variant_name

          vari_desc                       = ls_variantdesc

*   ONLY_CONTENTS                   =

        TABLES

          vari_contents                   = ival

*   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.

      IF sy-subrc = 0.

        PERFORM set_pnp_default.

      ENDIF.

    ENDIF.

  ENDIF.

ENDFORM.                    " changevariant

Regards,

Arun

Read only

0 Likes
2,951

we can't use program to change. any other method

Read only

0 Likes
2,951

I dont think there is any other way to do this.

You should have mentioed in the first post itself that using a program is not an option.

Thanks,

Shambu

Read only

Former Member
0 Likes
2,951

check the following link Not Active Contributor

 

http://scn.sap.com/thread/903100

Using taht  zreport you can download all variant and modify it and then upload that modify variant

See the following screen shot

now open VARIT.TXT file and modify variant and then upload all file using upload button