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: 

Modify Varaint

Former Member
0 Kudos

I have one variant now i need to modify same variant into another variant.

What are the ways for this ?

3 REPLIES 3

Former Member
0 Kudos

Pick the variant .. and click save .. give a different name .. and save it.

Or need to write a program to download variant to a .txt

file and Upload

get the variants using FM - YRS_VARIANT_CONTENTS

and create the variant using FM - YRS_CREATE_VARIANT

0 Kudos

either do as per suggessted by sriniavs or go to se38 ,give progrma name and select the varinat radiobutton and display ,there give the variant nam ein thge next scree and cilick on copy ,it wil ask u for the new variant name ,give the name and if necessary change the new varinat by same method..

hope it helps..

reward point if helpfull

Former Member
0 Kudos

Hi Vilas,

Given is a sample code for playing with Variants.....Hope that helps

http://help.sap.com/saphelp_470/helpdata/en/c0/980398e58611d194cc00a0c94260a5/frameset.htm

Find the Content in variant:

FM - RS_VARIANT_CONTENTS

Give program name and Variant name ->F8 -> check structure VALUTAB.

REPORT ZEXAMPLE.

DATA: JVARI_DESC LIKE VARID,

RC LIKE SY-SUBRC,

VARIANT_TEXT LIKE VARIT-VTEXT,

JVT LIKE VARIT OCCURS 0 WITH HEADER LINE,

SELPA LIKE RSPARAMS OCCURS 0 WITH HEADER LINE,

PARMS LIKE RSPARAMS OCCURS 0 WITH HEADER LINE,

OBJS LIKE VANZ OCCURS 0 WITH HEADER LINE.

PARAMETERS: P_VAR LIKE RSVAR-VARIANT. "NAME OF VARIANT

JVARI_DESC-REPORT = SY-REPID.

JVARI_DESC-VARIANT = P_VAR.

JVARI_DESC-ENAME = 'EXAMPLES'.

JVT-REPORT = SY-REPID.

JVT-VARIANT = P_VAR.

JVT-LANGU = SY-LANGU.

JVT-VTEXT = 'FUNCTION EXAMPLES'.

APPEND JVT.

CLEAR SELPA.

SELPA-SIGN = 'I'.

SELPA-OPTION = 'EQ'.

SELPA-KIND = 'P'.

SELPA-SELNAME = 'P_VAR'.

SELPA-LOW = P_VAR.

APPEND SELPA.

  • CHECK IF VARIANT EXISTS

CALL FUNCTION 'RS_VARIANT_EXISTS'

EXPORTING

REPORT = JVARI_DESC-REPORT

VARIANT = P_VAR

IMPORTING

R_C = RC

EXCEPTIONS

NOT_AUTHORIZED = 1

NO_REPORT = 2

REPORT_NOT_EXISTENT = 3

REPORT_NOT_SUPPLIED = 4

OTHERS = 5.

IF RC = 0 AND SY-SUBRC EQ 0.

  • DELETE OLD VARIANT

CALL FUNCTION 'RS_VARIANT_DELETE'

EXPORTING

REPORT = JVARI_DESC-REPORT

VARIANT = P_VAR

FLAG_CONFIRMSCREEN = 'X'

EXCEPTIONS

NOT_AUTHORIZED = 1

NOT_EXECUTED = 2

NO_REPORT = 3

REPORT_NOT_EXISTENT = 4

REPORT_NOT_SUPPLIED = 5

VARIANT_LOCKED = 6

VARIANT_NOT_EXISTENT = 7

NO_CORR_INSERT = 8

VARIANT_PROTECTED = 9

OTHERS = 10.

IF SY-SUBRC NE 0.

WRITE: 'UNABLE TO DELETE VARIANT:', P_VAR ,'STATUS=', SY-SUBRC.

EXIT.

ELSE.

WRITE:/ P_VAR, 'DELETED'.

ENDIF.

ELSE.

WRITE:/ P_VAR, 'DOES NOT EXIST'.

ENDIF. " ALREADY EXISTS

CALL FUNCTION 'RS_CREATE_VARIANT'

EXPORTING

CURR_REPORT = JVARI_DESC-REPORT

CURR_VARIANT = P_VAR

VARI_DESC = JVARI_DESC

TABLES

VARI_CONTENTS = SELPA

VARI_TEXT = JVT

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 EQ 0.

WRITE:/ 'VARIANT', P_VAR, 'CREATED FOR PROGRAM', JVARI_DESC-REPORT.

ELSE.

WRITE:/ 'VARIANT', P_VAR, 'NOT CREATED FOR PROGRAM', JVARI_DESC-REPORT.

EXIT.

ENDIF.

CALL FUNCTION 'RS_VARIANT_CONTENTS'

EXPORTING

REPORT = JVARI_DESC-REPORT

VARIANT = P_VAR

TABLES

VALUTAB = PARMS

OBJECTS = OBJS

EXCEPTIONS

VARIANT_NON_EXISTENT = 1

VARIANT_OBSOLETE = 2

OTHERS = 3.

IF SY-SUBRC NE 0.

WRITE : / 'ERROR READING VARIANT CONTENTS.'.

ELSE.

CALL FUNCTION 'RS_VARIANT_TEXT'

EXPORTING

LANGU = SY-LANGU

CURR_REPORT = JVARI_DESC-REPORT

VARIANT = P_VAR

IMPORTING

V_TEXT = VARIANT_TEXT.

WRITE:/ 'VARIANT DESCRIPTION:', VARIANT_TEXT.

LOOP AT PARMS.

CHECK PARMS-LOW NE SPACE OR PARMS-HIGH NE SPACE.

READ TABLE OBJS WITH KEY NAME = PARMS-SELNAME.

WRITE : /2 PARMS-SELNAME, OBJS-TEXT,

45 PARMS-KIND,

PARMS-SIGN,

PARMS-OPTION,

PARMS-LOW,

PARMS-HIGH.

NEW-LINE.

ENDLOOP.

SKIP.

ENDIF.

Reward points if this helps.

Manish