2012 Aug 07 4:32 AM
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?
2012 Aug 07 5:13 AM
What do you want to change? A parameter value or Parameter name?
2012 Aug 07 6:05 AM
2012 Aug 07 6:16 AM
2012 Aug 07 6:23 AM
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
2012 Aug 07 6:33 AM
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
2012 Aug 07 6:33 AM
2012 Aug 07 6:54 AM
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
2012 Aug 07 6:35 AM
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
2012 Aug 07 6:57 AM
2012 Aug 07 7:09 AM
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
2012 Aug 07 7:59 AM
check the following link Former Member past full code
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