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: 

Program variants

Former Member
0 Kudos

Hi,

Is it possible to copy one program's variants to another program by a standard program or in any other way? The selection screen of the programs looks exactly the same.

Thanks!

Br Benita

5 REPLIES 5

Lakshmant1
Active Contributor
0 Kudos

Hi Benita,

Have a look at program RSDBVCOP

Thanks

Lakshman

Former Member
0 Kudos

Use the FM

SUBST_WRITE_UPGRADE_VARIANT

Here you need to pass the program name and the target also.

Thanks

Eswar

lajitha_menon
Contributor
0 Kudos

you can read the programs variants by using fm RS_VARIANT_CONTENTS

0 Kudos

Hi, I already have one program which has some variants and when I now take a new program into production with exactly the same screen I wondered if there is just an easy way to copy the variants from one program to another.

I of course can create the variants manually but the risk is that I'll miss something. I have looked to your replies but I don't think that will help me, but thanks!

Br Benita

0 Kudos

Hi Benita,

I worked out a round about solution for the problem that we both are facing... I copied an existing SAP Standard program and customized according to suit our custom requirements. I am sending the code of the program. Please copy and paste the same and enter the parameters accordinly.. I tested for my scenario.. it worked for me fine...

To fellow ABAPer's.. please correct me if something is wrong in the program.. i am not sure whether its a right approach or not.. this worked for my problem... and i have a query regarding the RELID in the table VARI.. as my problem dealt with copying variants of RELID type VA & VB.. i used them as constants in the program...

Let me explain you the scenario when this program is helpful...

When you have Z Program with some variants and then u have another program with the same screen.. if you want the variants of the earlier program to be available to your new program then my program is useful in copying the variants in the same client or across the clients..

I know that there is a procedure of copying the variants when u copy the existing program to a new program.. but unfortunately in my case they didnt copy the variants.. so i had to work on a round about solution for this...

*----


*

  • Report ZRSDBVCOP *

*----


*

  • Utility fuer Varianten *

  • - Kopieren von Varianten zwischen zwei Mandanten *

*----


*

REPORT ZRSDBVCOP MESSAGE-ID DB.

TABLES: RALDB,

T000,

TRDIR,

VARIV,

VARID,

VARIT.

  • Selektionsbild

SELECT-OPTIONS:

REPORT FOR RALDB-REPORT, " Reportmenge

REPORT1 FOR RALDB-REPORT, " Reportmenge

VARIANT FOR RALDB-VARIANT. " Variantenmenge

PARAMETERS: QMANDT LIKE VARI-MANDT, " Quellmandant

ZMANDT LIKE VARI-MANDT. " Zielmandant

  • Tabelle der zu bearbeitenden Reports

DATA: BEGIN OF REPORTS OCCURS 100,

REPORT LIKE RALDB-REPORT, " Reportname

END OF REPORTS.

  • Tabelle der zu bearbeitenden Varianten für einen Report

DATA: BEGIN OF VARIANTS OCCURS 20,

VARIANT LIKE RALDB-VARIANT, " Variantenname

END OF VARIANTS.

RANGES: R_RELID FOR VARIV-RELID.

*|----

-


*

INITIALIZATION

*|----

-


|

INITIALIZATION.

R_RELID-LOW = 'VA'.

R_RELID-SIGN = 'I'.

R_RELID-OPTION = 'EQ'.

APPEND R_RELID.

CLEAR R_RELID.

R_RELID-LOW = 'VB'.

R_RELID-SIGN = 'I'.

R_RELID-OPTION = 'EQ'.

APPEND R_RELID.

CLEAR R_RELID.

*----


*

  • START-OF-SELECTION *

*----


*

START-OF-SELECTION.

IF SY-BATCH NE SPACE.

EXIT.

ENDIF.

PERFORM GET_REPORTS.

LOOP AT REPORTS.

PERFORM COPY_VARIANTS USING REPORTS-REPORT.

ENDLOOP.

*----


*

  • TOP-OF-PAGE *

*----


*

TOP-OF-PAGE.

WRITE: / 'Kopieren von Varianten von Mandant'(040),

QMANDT,

'nach Mandant'(050),

ZMANDT.

ULINE.

WRITE: / 'Report'(060),

10 'Variante'(070).

ULINE.

*----


*

  • AT SELECTION-SCREEN *

*----


*

AT SELECTION-SCREEN.

IF SY-UCOMM <> 'GET' AND

SY-UCOMM <> 'DEL' AND

SY-UCOMM <> 'LIST' AND

SY-UCOMM <> 'SAVE' AND

SY-UCOMM <> 'SHOW'.

  • für REPORT muss eine Selektion angegeben werden

DESCRIBE TABLE REPORT LINES SY-TFILL.

IF SY-TFILL = 0.

MESSAGE E674. " Selektion fuer Reports angeben

ENDIF.

  • Überprüfung von Quell- und Zielmandant

SELECT SINGLE * FROM T000 WHERE MANDT = QMANDT.

IF SY-SUBRC <> 0.

MESSAGE E646 WITH 'falscher Quellmandant'(010).

ENDIF.

SELECT SINGLE * FROM T000 WHERE MANDT = ZMANDT.

IF SY-SUBRC <> 0.

MESSAGE E646 WITH 'falscher Zielmandant'(020).

ENDIF.

  • IF QMANDT = ZMANDT.

  • MESSAGE E646 WITH

  • 'Quell- und Zielmandant müssen verschieden sein'(030).

  • ENDIF.

ENDIF.

*----


*

  • Unterprogramme *

*----


*

*----


*

  • FORM GET_REPORTS *

*----


*

  • Bestimmung der Tabelle REPORTS *

  • enthält alle Reports, für die im Quellmandanten eine Variante *

  • existiert *

*----


*

FORM GET_REPORTS.

DATA: OLDREPORT LIKE RALDB-REPORT.

  • Lesen der duplikativen Katalogeintraege der vorgegebenen Reports.

  • Für jeden Report, der solche Katalogeinträge im Quellmandanten

  • besitzt, werden Angaben in REPORTS gesammelt

SELECT * FROM VARIV CLIENT SPECIFIED

WHERE MANDT = QMANDT

AND RELID IN R_RELID

AND REPORT IN REPORT.

CHECK VARIV-REPORT <> OLDREPORT.

REPORTS-REPORT = OLDREPORT = VARIV-REPORT.

TRDIR-NAME = REPORTS-REPORT.

READ TABLE TRDIR.

IF SY-SUBRC EQ 0.

APPEND REPORTS.

ENDIF.

ENDSELECT.

SORT REPORTS BY REPORT.

ENDFORM.

*----


*

  • FORM COPY_VARIANTS *

*----


*

  • Kopieren der Varianten eines Reports *

*----


*

  • --> RNAME Reportname *

*----


*

FORM COPY_VARIANTS USING RNAME.

REFRESH VARIANTS.

SELECT * FROM VARIV CLIENT SPECIFIED

WHERE MANDT = QMANDT

AND RELID IN R_RELID

AND REPORT = RNAME

AND VARIANT IN VARIANT.

CHECK VARIV-VARIANT <> VARIANTS-VARIANT.

CLEAR VARIANTS.

VARIANTS-VARIANT = VARIV-VARIANT.

APPEND VARIANTS.

ENDSELECT.

WRITE: / RNAME.

SORT VARIANTS BY VARIANT.

DELETE ADJACENT DUPLICATES FROM VARIANTS COMPARING VARIANT.

LOOP AT VARIANTS.

PERFORM COPY_VARIANT USING RNAME VARIANTS-VARIANT.

ENDLOOP.

ULINE.

ENDFORM.

*----


*

  • FORM COPY_VARIANT *

*----


*

  • Kopieren einer Variante eines Reports *

*----


*

  • --> RNAME Reportname *

  • VNAME Variantenname *

*----


*

FORM COPY_VARIANT USING RNAME VNAME.

DATA: ERROR(1).

  • Sperren werden nicht gesetzt

WRITE: 10 VNAME.

ERROR = SPACE.

SELECT * FROM VARI CLIENT SPECIFIED

WHERE MANDT = QMANDT

AND RELID IN R_RELID

AND REPORT = RNAME

AND VARIANT = VNAME.

VARI-MANDT = ZMANDT.

VARI-REPORT = REPORT1-LOW.

INSERT VARI CLIENT SPECIFIED.

IF SY-SUBRC <> 0.

ERROR = 'X'.

EXIT.

ENDIF.

ENDSELECT.

SELECT SINGLE * FROM VARID CLIENT SPECIFIED INTO VARID

WHERE MANDT = QMANDT

AND REPORT = RNAME

AND VARIANT = VNAME

AND FLAG1 = ' '

AND FLAG2 = ' '.

IF SY-SUBRC = 0.

VARID-MANDT = ZMANDT.

VARID-REPORT = REPORT1-LOW.

  • varid-ename = sy-uname.

  • varid-edat = sy-datum.

  • varid-etime = sy-uzeit.

INSERT INTO VARID CLIENT SPECIFIED VALUES VARID.

IF SY-SUBRC <> 0.

ERROR = 'X'.

EXIT.

ELSEIF SY-SUBRC = 0.

ERROR = SPACE.

ENDIF.

ENDIF.

SELECT SINGLE * FROM VARIT CLIENT SPECIFIED INTO VARIT

WHERE MANDT = QMANDT

AND LANGU = SY-LANGU

AND REPORT = RNAME

AND VARIANT = VNAME.

IF SY-SUBRC = 0.

VARIT-MANDT = ZMANDT.

VARIT-REPORT = REPORT1-LOW.

INSERT INTO VARIT CLIENT SPECIFIED VALUES VARIT.

IF SY-SUBRC <> 0.

ERROR = 'X'.

EXIT.

ELSEIF SY-SUBRC = 0.

ERROR = SPACE.

ENDIF.

ENDIF.

IF ERROR = SPACE.

SELECT * FROM VARI CLIENT SPECIFIED

WHERE MANDT = QMANDT

AND RELID = 'VC'

AND REPORT = RNAME

AND VARIANT = VNAME.

VARI-MANDT = ZMANDT.

INSERT VARI CLIENT SPECIFIED.

IF SY-SUBRC <> 0.

ERROR = 'X'.

EXIT.

ENDIF.

ENDSELECT.

ENDIF.

IF ERROR = SPACE.

WRITE: 30 'kopiert'(100).

COMMIT WORK.

ELSE.

WRITE: 30 'nicht kopiert, da vorhanden'(110).

ROLLBACK WORK.

ENDIF.

NEW-LINE.

ENDFORM.

This is the end of the program.. Please suggest or clarify regarding the necessary changes..

Thank You,

Suresh