Posted: Sun Nov 04, 2007 1:33 pm Post subject: Copy Variants from one Program to another
Code:
* ------------------------------------------------------
* Copy Variants from one Program to another.
* ------------------------------------------------------
REPORT Z_COPY_VARIANTS_PROG_TO_PROG .
* =====================================================
* Data Declarations Section
* =====================================================
TABLES : VARID , VARIS , VARIT .
* -----------------------------------------------------
DATA : BEGIN OF MYVARID OCCURS 0 .
INCLUDE STRUCTURE VARID .
DATA : END OF MYVARID .
* -----------------------------------------------------
DATA : BEGIN OF MYVARIS OCCURS 0 .
INCLUDE STRUCTURE VARIS .
DATA : END OF MYVARIS .
* -----------------------------------------------------
DATA : BEGIN OF MYVARIT OCCURS 0 .
INCLUDE STRUCTURE VARIT .
DATA : END OF MYVARIT .
* -----------------------------------------------------
DATA : BEGIN OF MYVARI OCCURS 0 .
INCLUDE STRUCTURE VARI .
DATA : END OF MYVARI .
DATA : MANS(1) TYPE C .
DATA : PROGRAMM LIKE RS38M-PROGRAMM .
DATA : BEGIN OF MDYNPFIELDS OCCURS 1 .
INCLUDE STRUCTURE DYNPREAD .
DATA : END OF MDYNPFIELDS .
CONSTANTS BUTTONSELECTED(1) TYPE C VALUE 'X' .
READ TABLE MDYNPFIELDS INDEX 1 .
PROGRAMM = MDYNPFIELDS-FIELDVALUE .
CALL FUNCTION 'REPOSITORY_INFO_SYSTEM_F4'
EXPORTING
OBJECT_TYPE = 'PROG'
OBJECT_NAME = PROGRAMM
IMPORTING
OBJECT_NAME_SELECTED = PROGRAMM
EXCEPTIONS
CANCEL = 1
WRONG_TYPE = 2
OTHERS = 3.
P_TO_P = PROGRAMM .
* ======================================================
* Start of Selection
* ======================================================
START-OF-SELECTION .
CASE BUTTONSELECTED.
WHEN P_SAME_S .
PERFORM COPY_FROM_PROG_TO_PROG .
WHEN P_DOWNLD .
PERFORM VDOWNLOAD .
WHEN P_UPLOAD .
PERFORM VUPLOAD .
ENDCASE .
*&---------------------------------------------------*
*& Form COPY_FROM_PROG_TO_PROG
*&---------------------------------------------------*
* text
*----------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------*
FORM COPY_FROM_PROG_TO_PROG.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
* DEFAULTOPTION = 'Y'
TEXTLINE1 = 'Are you sure you want to copy Variants ? '
* TEXTLINE2 = ' '
TITEL = 'Confirmation '
* START_COLUMN = 25
* START_ROW = 6
* CANCEL_DISPLAY = 'X'
IMPORTING
ANSWER = MANS
EXCEPTIONS
OTHERS = 1.
IF MANS = 'J' .
* ------------------------------------------------------
REFRESH MYVARID . CLEAR MYVARID .
SELECT * FROM VARID INTO TABLE MYVARID
WHERE REPORT = P_FROM_P.
LOOP AT MYVARID .
MYVARID-REPORT = P_TO_P .
MODIFY MYVARID .
ENDLOOP .
IF SY-SUBRC = 0 .
DELETE FROM VARID WHERE REPORT = P_TO_P .
INSERT VARID FROM TABLE MYVARID .
ENDIF .
* ----------------------------------------------------
REFRESH MYVARIS . CLEAR MYVARIS .
SELECT * FROM VARIS INTO TABLE MYVARIS
WHERE REPORT = P_FROM_P.
LOOP AT MYVARIS .
MYVARIS-REPORT = P_TO_P .
MODIFY MYVARIS .
ENDLOOP .
IF SY-SUBRC = 0 .
DELETE FROM VARIS WHERE REPORT = P_TO_P .
INSERT VARIS FROM TABLE MYVARIS .
ENDIF .
* -----------------------------------------------------
REFRESH MYVARIT . CLEAR MYVARIT .
SELECT * FROM VARIT INTO TABLE MYVARIT
WHERE REPORT = P_FROM_P.
LOOP AT MYVARIT .
MYVARIT-REPORT = P_TO_P .
MODIFY MYVARIT .
ENDLOOP .
IF SY-SUBRC = 0 .
DELETE FROM VARIT WHERE REPORT = P_TO_P .
INSERT VARIT FROM TABLE MYVARIT .
ENDIF .
* -----------------------------------------------------
REFRESH MYVARI . CLEAR MYVARI .
SELECT * FROM VARI INTO TABLE MYVARI
WHERE REPORT = P_FROM_P.
LOOP AT MYVARI .
MYVARI-REPORT = P_TO_P .
MODIFY MYVARI .
ENDLOOP .
IF SY-SUBRC = 0 .
DELETE FROM VARI WHERE REPORT = P_TO_P .
INSERT VARI FROM TABLE MYVARI .
ENDIF .
ENDIF .
ENDFORM. " COPY_FROM_PROG_TO_PROG
*&-----------------------------------------------------*
*& Form VDOWNLOAD
*&-----------------------------------------------------*
* text
*------------------------------------------------------*
* --> p1 text
* <-- p2 text
*------------------------------------------------------*
FORM VDOWNLOAD.
REFRESH MYVARID . CLEAR MYVARID .
SELECT * FROM VARID INTO TABLE MYVARID
WHERE REPORT = P_FROM_P.
DOWNLOAD_TO_ASCII P_FILE_D MYVARID .
* -----------------------------------------------------
REFRESH MYVARIS . CLEAR MYVARIS .
SELECT * FROM VARIS INTO TABLE MYVARIS
WHERE REPORT = P_FROM_P.
DOWNLOAD_TO_ASCII P_FILE_S MYVARIS .
* -----------------------------------------------------
REFRESH MYVARIT . CLEAR MYVARIT .
SELECT * FROM VARIT INTO TABLE MYVARIT
WHERE REPORT = P_FROM_P.
DOWNLOAD_TO_ASCII P_FILE_T MYVARIT .
* ----------------------------------------------------
REFRESH MYVARI . CLEAR MYVARI .
SELECT * FROM VARI INTO TABLE MYVARI
WHERE REPORT = P_FROM_P.
DOWNLOAD_TO_ASCII P_FILE MYVARI .
ENDFORM. " VDOWNLOAD
*&-----------------------------------------------------*
*& Form VUPLOAD
*&-----------------------------------------------------*
* text
*------------------------------------------------------*
* --> p1 text
* <-- p2 text
*------------------------------------------------------*
FORM VUPLOAD.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
* DEFAULTOPTION = 'Y'
TEXTLINE1 =
'Are you sure you want to upload Variants ? '
* TEXTLINE2 = ' '
TITEL = 'Confirmation '
* START_COLUMN = 25
* START_ROW = 6
* CANCEL_DISPLAY = 'X'
IMPORTING
ANSWER = MANS
EXCEPTIONS
OTHERS = 1.
IF MANS = 'J' .
* -----------------------------------------------------
REFRESH MYVARID . CLEAR MYVARID .
UPLOAD_FROM_ASCII P_FILE_D MYVARID .
LOOP AT MYVARID .
MYVARID-REPORT = P_TO_P .
MODIFY MYVARID .
ENDLOOP .
IF SY-SUBRC = 0 .
DELETE FROM VARID WHERE REPORT = P_TO_P .
INSERT VARID FROM TABLE MYVARID .
ENDIF .
* -----------------------------------------------------
REFRESH MYVARIS . CLEAR MYVARIS .
UPLOAD_FROM_ASCII P_FILE_S MYVARIS .
LOOP AT MYVARIS .
MYVARIS-REPORT = P_TO_P .
MODIFY MYVARIS .
ENDLOOP .
IF SY-SUBRC = 0 .
DELETE FROM VARIS WHERE REPORT = P_TO_P .
INSERT VARIS FROM TABLE MYVARIS .
ENDIF .
* -----------------------------------------------------
REFRESH MYVARIT . CLEAR MYVARIT .
UPLOAD_FROM_ASCII P_FILE_T MYVARIT .
LOOP AT MYVARIT .
MYVARIT-REPORT = P_TO_P .
MODIFY MYVARIT .
ENDLOOP .
IF SY-SUBRC = 0 .
DELETE FROM VARIT WHERE REPORT = P_TO_P .
INSERT VARIT FROM TABLE MYVARIT .
ENDIF .
* ------------------------------------------------------
REFRESH MYVARI . CLEAR MYVARI .
UPLOAD_FROM_ASCII P_FILE MYVARI .
LOOP AT MYVARI .
MYVARI-REPORT = P_TO_P .
MODIFY MYVARI .
ENDLOOP .
IF SY-SUBRC = 0 .
DELETE FROM VARI WHERE REPORT = P_TO_P .
INSERT VARI FROM TABLE MYVARI .
ENDIF .
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.