Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Copy variants between programs

Hi!

I've copied a Z program into an another Z program in the development system. Unfortunately there are a lot of variants to the old program in the productive system. Because these variants are only in the productive syste I could not copy them.

After the new program is transported into the productive system I have to restore the variants also.

I see a few ways to it, but I don't have experience in it yet, and I don't know, which one is possible to solve:

- download from the old and upload the variants to the new program

- copy them using a standard program/FM

If you know a solution, feel free to share it with me.

Thank you

Tamá

Tags:
Former Member
Former Member replied

Hi

This is a my utility program to copy a variant between two programs:

REPORT ZUT_COPY_VARIANT .
SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-T01.
PARAMETERS: P_REP1 LIKE  RSVAR-REPORT OBLIGATORY,
            P_REP2 LIKE  RSVAR-REPORT OBLIGATORY.
SELECTION-SCREEN END OF BLOCK BL1.

DATA  BEGIN OF DYNPFIELDS OCCURS 1.
        INCLUDE STRUCTURE DYNPREAD.
DATA  END   OF DYNPFIELDS.


DATA: TEXT_1(100),
      TEXT_2(100).

DATA: ANSWER.

AT SELECTION-SCREEN.

  IF P_REP1 = P_REP2.
    MESSAGE E208(00) WITH 'Programmi di orig. e destin. identici'(E02).
  ENDIF.


  MESSAGE W208(00) WITH 'Verificare omogeneità scherm. selez.'(W01).

AT SELECTION-SCREEN ON P_REP1.
  PERFORM CHECK_REPORT USING P_REP1.

AT SELECTION-SCREEN ON P_REP2.
  PERFORM CHECK_REPORT USING P_REP2.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_REP1.
  PERFORM F4_REPORT USING 'P_REP1'.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_REP2.
  PERFORM F4_REPORT USING 'P_REP2'.



START-OF-SELECTION.

  TEXT_1 = 'Tutte le varianti del report &'(001).
  REPLACE '&' WITH P_REP1 INTO TEXT_1.

  TEXT_2 = 'saranno copiate nel report &'(002).
  REPLACE '&' WITH P_REP2 INTO TEXT_2.


  CALL FUNCTION 'POPUP_TO_CONFIRM_WITH_MESSAGE'
       EXPORTING
            DIAGNOSETEXT1 = TEXT_1
            DIAGNOSETEXT2 = TEXT_2
            TEXTLINE1     = 'Eseguire copia varianti?'(003)
            TITEL         = 'Copiare Varianti'(004)
       IMPORTING
            ANSWER        = ANSWER.

  CHECK ANSWER = 'J'.

  CALL FUNCTION 'RS_COPY_SELECTION_SETS'
    EXPORTING
      SOURCE_REPORT        = P_REP1
      TARGET_REPORT        = P_REP2
*   DEVC                 =
*   CHANGE_ENAME         = 'X'
   EXCEPTIONS
     VARIANT_LOCKED       = 1
     OTHERS               = 2
            .
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ELSE.
    MESSAGE S208(00) WITH 'Varianti copiate positivamente'(S01).
  ENDIF.
*&---------------------------------------------------------------------*
*&      Form  CHECK_REPORT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_REP  text
*----------------------------------------------------------------------*
FORM CHECK_REPORT USING    P_REP.
  SELECT SINGLE NAME FROM TRDIR INTO P_REP WHERE NAME = P_REP.
  IF SY-SUBRC <> 0.
    MESSAGE E368(00) WITH P_REP 'inesistente o inattivo'(E01).
  ENDIF.
ENDFORM.                    " CHECK_REPORT
*&---------------------------------------------------------------------*
*&      Form  F4_REPORT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_PARAM  text
*----------------------------------------------------------------------*
FORM F4_REPORT USING    P_PARAM.
  FIELD-SYMBOLS: <REPORT> TYPE ANY.


  ASSIGN (P_PARAM) TO <REPORT>.

  REFRESH DYNPFIELDS.
  CLEAR DYNPFIELDS.

  DYNPFIELDS-FIELDNAME  = P_PARAM.
  APPEND DYNPFIELDS.

  CALL FUNCTION 'DYNP_VALUES_READ'
       EXPORTING
            DYNAME     = SY-CPROG
            DYNUMB     = SY-DYNNR
       TABLES
            DYNPFIELDS = DYNPFIELDS
       EXCEPTIONS
            OTHERS.

  IF SY-SUBRC = 0.
    READ TABLE DYNPFIELDS INDEX 1.
    <REPORT> = DYNPFIELDS-FIELDVALUE.
  ENDIF.

  PERFORM PROGRAM_DIRECTORY                                 "#EC *
        USING <REPORT>
              'X'.
ENDFORM.                                                    " F4_REPORT

*---------------------------------------------------------------------*
*       FORM PROGRAM_DIRECTORY                                        *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  PROGRAMM                                                      *
*  -->  F4_CALL                                                       *
*---------------------------------------------------------------------*
FORM PROGRAM_DIRECTORY USING PROGRAMM LIKE RS38M-PROGRAMM
                             F4_CALL.
  DATA: L_PROGRAMM LIKE RS38M-PROGRAMM.

  L_PROGRAMM = PROGRAMM.

  IF L_PROGRAMM = SPACE.
    SUBMIT RSABADAB AND RETURN VIA SELECTION-SCREEN
                    WITH F4_CALL =    F4_CALL.
  ELSE.
    SUBMIT RSABADAB AND RETURN VIA SELECTION-SCREEN
                    WITH REPNAME CP   L_PROGRAMM
                    WITH F4_CALL =    F4_CALL.
  ENDIF.

  GET PARAMETER ID 'RID' FIELD PROGRAMM.                    "#EC *

ENDFORM.

Max

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question