SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Copy Selected Program Variants to another Client



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP Dictionary
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Wed Aug 20, 2008 9:48 am    Post subject: Copy Selected Program Variants to another Client Reply with quote

Code:
REPORT ZCOPYTAB MESSAGE-ID ZZ.
PARAMETERS: MANDT LIKE T000-MANDT DEFAULT SY-MANDT.
TABLES:  VARIT, VARID, ZPGM.

DATA: BEGIN OF TVARI OCCURS 500.
        INCLUDE STRUCTURE VARI.
DATA: END OF TVARI.

DATA: BEGIN OF TVARIT OCCURS 500.
        INCLUDE STRUCTURE VARIT.
DATA: END OF TVARIT.

DATA: BEGIN OF TVARID OCCURS 500.
        INCLUDE STRUCTURE VARID.
DATA: END OF TVARID.

DATA: BEGIN OF TZPGM OCCURS 500.
        INCLUDE STRUCTURE ZPGM.
DATA: END OF TZPGM.

PERFORM CHECK-TCODE-AUTHORITY USING 'SE38'.
IF MANDT EQ SY-MANDT.
  MESSAGE E999 WITH 'Cannot Specify Own Client'.
ENDIF.
IF SY-SYSID(3) EQ 'DEV'.
  IF SY-MANDT NE 220
     OR SY-SYSID(3) NE 'DEV'.
    MESSAGE E999 WITH 'Can Only Run this Program in Client 220 on DEV'.
  ENDIF.
ENDIF.
IF SY-SYSID(3) EQ 'PRD'.
  IF SY-MANDT NE 402
     OR SY-SYSID(3) NE 'PRD'.
    MESSAGE E999 WITH 'Can Only Run this Program in Client 402 on PRD'.
  ENDIF.
ENDIF.

*   Delete Data from Specified Client
SELECT * FROM VARI CLIENT SPECIFIED WHERE MANDT EQ MANDT.
  IF VARI-REPORT(1) EQ 'Z'
  OR VARI-REPORT EQ 'RFYTXM00'
  OR VARI-REPORT EQ 'RMMMPERI'.
    MOVE VARI TO TVARI.
    APPEND TVARI.
  ENDIF.
ENDSELECT.
LOOP AT TVARI.
  SELECT SINGLE FOR UPDATE * FROM VARI CLIENT SPECIFIED
          WHERE MANDT   EQ TVARI-MANDT
            AND RELID   EQ TVARI-RELID
            AND REPORT  EQ TVARI-REPORT
            AND VARIANT EQ TVARI-VARIANT
            AND SRTF2   EQ TVARI-SRTF2.
  IF SY-SUBRC EQ 0.
    DELETE VARI CLIENT SPECIFIED.
  ENDIF.
ENDLOOP.
COMMIT WORK.

SELECT * FROM VARIT CLIENT SPECIFIED WHERE MANDT EQ MANDT.
  IF VARIT-REPORT(1) EQ 'Z'
  OR VARIT-REPORT EQ 'RFYTXM00'
  OR VARIT-REPORT EQ 'RMMMPERI'.
    MOVE VARIT TO TVARIT.
    APPEND TVARIT.
  ENDIF.
ENDSELECT.
LOOP AT TVARIT.
  SELECT SINGLE FOR UPDATE * FROM VARIT CLIENT SPECIFIED
          WHERE MANDT   EQ TVARIT-MANDT
            AND LANGU   EQ TVARIT-LANGU
            AND REPORT  EQ TVARIT-REPORT
            AND VARIANT EQ TVARIT-VARIANT.
  IF SY-SUBRC EQ 0.
    DELETE VARIT CLIENT SPECIFIED.
  ENDIF.
ENDLOOP.
COMMIT WORK.

SELECT * FROM VARID CLIENT SPECIFIED WHERE MANDT EQ MANDT.
  IF VARID-REPORT(1) EQ 'Z'
  OR VARID-REPORT EQ 'RFYTXM00'
  OR VARID-REPORT EQ 'RMMMPERI'.
    MOVE VARID TO TVARID.
    APPEND TVARID.
  ENDIF.
ENDSELECT.
LOOP AT TVARID.
  SELECT SINGLE FOR UPDATE * FROM VARID CLIENT SPECIFIED
          WHERE MANDT   EQ TVARID-MANDT
            AND REPORT  EQ TVARID-REPORT
            AND VARIANT EQ TVARID-VARIANT
            AND FLAG1   EQ TVARID-FLAG1
            AND FLAG2   EQ TVARID-FLAG2.
  IF SY-SUBRC EQ 0.
    DELETE VARID CLIENT SPECIFIED.
  ENDIF.
ENDLOOP.
COMMIT WORK.

SELECT * FROM ZPGM CLIENT SPECIFIED WHERE MANDT EQ MANDT.
  MOVE ZPGM TO TZPGM.
  APPEND TZPGM.
ENDSELECT.
LOOP AT TZPGM.
  SELECT SINGLE FOR UPDATE * FROM ZPGM CLIENT SPECIFIED
          WHERE MANDT   EQ TZPGM-MANDT
            AND PGM   EQ TZPGM-PGM.
  IF SY-SUBRC EQ 0.
    DELETE ZPGM CLIENT SPECIFIED.
  ENDIF.
ENDLOOP.
COMMIT WORK.
*   Load up Internal Tables - with Data from this Client
REFRESH TVARI.
REFRESH TVARIT.
REFRESH TVARID.
REFRESH TZPGM.
SELECT * FROM VARI.
  IF VARI-REPORT(1) EQ 'Z'
  OR VARI-REPORT EQ 'RFYTXM00'
  OR VARI-REPORT EQ 'RMMMPERI'.
    MOVE VARI TO TVARI.
    MOVE MANDT TO TVARI-MANDT.
    APPEND TVARI.
  ENDIF.
ENDSELECT.

SELECT * FROM VARIT.
  IF VARIT-REPORT(1) EQ 'Z'
  OR VARIT-REPORT EQ 'RFYTXM00'
  OR VARIT-REPORT EQ 'RMMMPERI'.
    MOVE VARIT TO TVARIT.
    MOVE MANDT TO TVARIT-MANDT.
    APPEND TVARIT.
  ENDIF.
ENDSELECT.

SELECT * FROM VARID.
  IF VARID-REPORT(1) EQ 'Z'
  OR VARID-REPORT EQ 'RFYTXM00'
  OR VARID-REPORT EQ 'RMMMPERI'.
    MOVE VARID TO TVARID.
    MOVE MANDT TO TVARID-MANDT.
    APPEND TVARID.
  ENDIF.
ENDSELECT.
COMMIT WORK.

SELECT * FROM ZPGM.
  MOVE ZPGM TO TZPGM.
  MOVE MANDT TO TZPGM-MANDT.
  APPEND TZPGM.
ENDSELECT.
COMMIT WORK.

*   Update Specified Client - from Tables loaded from this Client
LOOP AT TVARI.
  SELECT SINGLE FOR UPDATE * FROM VARI CLIENT SPECIFIED
          WHERE MANDT   EQ TVARI-MANDT
            AND RELID   EQ TVARI-RELID
            AND REPORT  EQ TVARI-REPORT
            AND VARIANT EQ TVARI-VARIANT
            AND SRTF2   EQ TVARI-SRTF2.
  MOVE TVARI     TO VARI.
  IF SY-SUBRC EQ 0.
    MODIFY VARI CLIENT SPECIFIED.
  ELSE.
    INSERT VARI CLIENT SPECIFIED.
  ENDIF.
ENDLOOP.
COMMIT WORK.

LOOP AT TVARIT.
  SELECT SINGLE FOR UPDATE * FROM VARIT CLIENT SPECIFIED
          WHERE MANDT   EQ TVARIT-MANDT
            AND LANGU   EQ TVARIT-LANGU
            AND REPORT  EQ TVARIT-REPORT
            AND VARIANT EQ TVARIT-VARIANT.
  MOVE TVARIT    TO VARIT.
  IF SY-SUBRC EQ 0.
    MODIFY VARIT CLIENT SPECIFIED.
  ELSE.
    INSERT VARIT CLIENT SPECIFIED.
  ENDIF.
ENDLOOP.
COMMIT WORK.

LOOP AT TVARID.
  SELECT SINGLE FOR UPDATE * FROM VARID CLIENT SPECIFIED
          WHERE MANDT   EQ TVARID-MANDT
            AND REPORT  EQ TVARID-REPORT
            AND VARIANT EQ TVARID-VARIANT
            AND FLAG1   EQ TVARID-FLAG1
            AND FLAG2   EQ TVARID-FLAG2.
  MOVE TVARID    TO VARID.
  IF SY-SUBRC EQ 0.
    MODIFY VARID CLIENT SPECIFIED.
  ELSE.
    INSERT VARID CLIENT SPECIFIED.
  ENDIF.
ENDLOOP.
COMMIT WORK.

LOOP AT TZPGM.
  SELECT SINGLE FOR UPDATE * FROM ZPGM CLIENT SPECIFIED
          WHERE MANDT   EQ TVARID-MANDT
            AND PGM  EQ TZPGM-PGM.
  MOVE TZPGM     TO ZPGM.
  IF SY-SUBRC EQ 0.
    MODIFY ZPGM CLIENT SPECIFIED.
  ELSE.
    INSERT ZPGM CLIENT SPECIFIED.
  ENDIF.
ENDLOOP.
COMMIT WORK.
INCLUDE ZCONINC3.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP Dictionary All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.