Hier mal ein kleiner Programm dazu:
REPORT ZBC_FAVORITEN_COPY
NO STANDARD PAGE HEADING
LINE-SIZE 80
MESSAGE-ID ZV. " Eigene ID eintragen
* ----- Tabellen -----
TABLES: USR02, " Logon-Daten
SMEN_BUFFC, " Tabelle für die Ablage der Favoriten
SMEN_BUFFI, " Links für Favoriten
SMENFAVDAT, " Datum der letzten Favoritenänderung
T000. " Mandanten
* ----- Variablen -----
DATA: X_ANTWORT(1) TYPE C,
X_DO TYPE I VALUE 0,
X_FILELENGTH TYPE I VALUE 0,
X_OPT(1) TYPE C,
X_RC LIKE SY-SUBRC,
X_TEXT1(50) TYPE C,
X_TEXT2(50) TYPE C,
X_TITEL(50) TYPE C.
* ----- Interne Tabellen -----
DATA: BEGIN OF SMEN_TAB OCCURS 0,
TYPE(1) TYPE C,
MANDT LIKE SMEN_BUFFC-MANDT,
UNAME LIKE SMEN_BUFFC-UNAME,
REPORTTYPE LIKE SMEN_BUFFC-REPORTTYPE,
REPORT LIKE SMEN_BUFFC-REPORT,
PARENT_ID LIKE SMEN_BUFFC-PARENT_ID,
OBJECT_ID LIKE SMEN_BUFFC-OBJECT_ID,
MENU_LEVEL LIKE SMEN_BUFFC-MENU_LEVEL,
BOOK_INFO LIKE SMEN_BUFFC-BOOK_INFO,
ATTRIBUTES LIKE SMEN_BUFFC-ATTRIBUTES,
SORT_ORDER LIKE SMEN_BUFFC-SORT_ORDER,
X_POS LIKE SMEN_BUFFC-X_POS,
Y_POS LIKE SMEN_BUFFC-Y_POS,
SAP_GUID LIKE SMEN_BUFFC-SAP_GUID,
TEXT LIKE SMEN_BUFFC-TEXT,
TARGET_SYS LIKE SMEN_BUFFC-TARGET_SYS,
LINK_TYPE LIKE SMEN_BUFFI-LINK_TYPE,
URL LIKE SMEN_BUFFI-URL,
FLAG_TYPE LIKE SMENFAVDAT-FLAG_TYPE,
CHANGE_DAT LIKE SMENFAVDAT-CHANGE_DAT,
CHANGE_TIM LIKE SMENFAVDAT-CHANGE_TIM,
TIMESTMP(15) TYPE C,
* TIMESTMP like smenfavdat-timestmp,
END OF SMEN_TAB.
*---------------------------------------------*
* Parameter *
*---------------------------------------------*
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN SKIP 1.
PARAMETERS: X_ARTC RADIOBUTTON GROUP ART.
SELECTION-SCREEN COMMENT 36(60) TEXT-015.
SELECTION-SCREEN SKIP 1.
PARAMETERS: X_SOURCE LIKE USR02-BNAME,
X_MDTSRC LIKE T000-MANDT.
SELECTION-SCREEN SKIP 1.
PARAMETERS: X_TARGET LIKE USR02-BNAME,
X_MDTTRG LIKE T000-MANDT.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN SKIP 1.
PARAMETERS: X_ARTD RADIOBUTTON GROUP ART.
SELECTION-SCREEN SKIP 1.
PARAMETERS: X_ARTE RADIOBUTTON GROUP ART DEFAULT 'X',
X_ARTI RADIOBUTTON GROUP ART.
SELECTION-SCREEN COMMENT 36(60) TEXT-015.
SELECTION-SCREEN SKIP 1.
PARAMETERS: X_USREXP LIKE USR02-BNAME,
X_MDTEXP LIKE T000-MANDT.
SELECTION-SCREEN SKIP 1.
PARAMETERS: X_FILEP(128) DEFAULT 'C:\Temp\Favoriten.txt'.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK A.
* ----- F4-Hilfe zur Dateisuche (PC-File) -----
AT SELECTION-SCREEN ON VALUE-REQUEST FOR X_FILEP.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = ' '
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' ' "'PATH'
IMPORTING
FILE_NAME = X_FILEP.
* ---------------------------------------------
* ----- Initialisieren ------------
INITIALIZATION.
* -----------------------------------
AT SELECTION-SCREEN.
* ----- Eingabewerte prüfen -----
AUTHORITY-CHECK OBJECT 'S_TCODE'
ID 'TCD' FIELD 'XXXXX'. " Trans. eintragen
IF SY-SUBRC NE 0.
MESSAGE E002 WITH SY-TCODE. " Keine Berechtigung
ENDIF.
IF X_ARTC = 'X'. " Copy
IF X_SOURCE IS INITIAL
OR X_MDTSRC IS INITIAL
OR X_TARGET IS INITIAL
OR X_MDTTRG IS INITIAL.
IF X_SOURCE IS INITIAL.
SET CURSOR FIELD 'X_SOURCE'.
ELSEIF X_MDTSRC IS INITIAL.
SET CURSOR FIELD 'X_MDTSRC'.
ELSEIF X_TARGET IS INITIAL.
SET CURSOR FIELD 'X_TARGET'.
ELSEIF X_MDTTRG IS INITIAL.
SET CURSOR FIELD 'X_MDTTRG'.
ENDIF.
MESSAGE E068.
ENDIF.
IF X_SOURCE = X_TARGET
AND X_MDTSRC = X_MDTTRG.
MESSAGE E081.
ENDIF.
SELECT SINGLE * FROM T000
WHERE MANDT = X_MDTSRC.
IF SY-SUBRC NE 0.
SET CURSOR FIELD 'X_MDTSRC'.
MESSAGE E083 WITH X_MDTSRC.
ENDIF.
SELECT SINGLE * FROM T000
WHERE MANDT = X_MDTTRG.
IF SY-SUBRC NE 0.
SET CURSOR FIELD 'X_MDTTRG'.
MESSAGE E083 WITH X_MDTTRG.
ENDIF.
SELECT SINGLE * FROM USR02 CLIENT SPECIFIED " Quelle
WHERE MANDT EQ X_MDTSRC
AND BNAME EQ X_SOURCE.
IF SY-SUBRC NE 0.
SET CURSOR FIELD 'X_SOURCE'.
MESSAGE E082 WITH X_SOURCE X_MDTSRC.
ENDIF.
SELECT SINGLE * FROM USR02 CLIENT SPECIFIED " Ziel
WHERE MANDT EQ X_MDTTRG
AND BNAME EQ X_TARGET.
IF SY-SUBRC NE 0.
SET CURSOR FIELD 'X_TARGET'.
MESSAGE E082 WITH X_TARGET X_MDTTRG.
ENDIF.
ELSE. " Löschen / Export / Import
IF X_USREXP IS INITIAL
OR X_MDTEXP IS INITIAL
OR X_FILEP IS INITIAL.
IF X_USREXP IS INITIAL.
SET CURSOR FIELD 'X_USREXP'.
ELSEIF X_MDTEXP IS INITIAL.
SET CURSOR FIELD 'X_MDTEXP'.
ELSEIF X_FILEP IS INITIAL.
SET CURSOR FIELD 'X_FILEP'.
ENDIF.
MESSAGE E068.
ENDIF.
SELECT SINGLE * FROM T000
WHERE MANDT = X_MDTEXP.
IF SY-SUBRC NE 0.
SET CURSOR FIELD 'X_MDTEXP'.
MESSAGE E083 WITH X_MDTEXP.
ENDIF.
SELECT SINGLE * FROM USR02 CLIENT SPECIFIED
WHERE MANDT EQ X_MDTEXP
AND BNAME EQ X_USREXP.
IF SY-SUBRC NE 0.
SET CURSOR FIELD 'X_USREXP'.
MESSAGE E082 WITH X_USREXP X_MDTEXP.
ENDIF.
ENDIF.
* -----------------------------------
START-OF-SELECTION.
* -----------------------------------
X_TITEL = TEXT-005.
IF X_ARTC = 'X'. " Copy
CONCATENATE TEXT-006 X_SOURCE TEXT-007 X_MDTSRC
INTO X_TEXT1 SEPARATED BY SPACE.
CONCATENATE TEXT-008 X_TARGET TEXT-007 X_MDTTRG TEXT-009
INTO X_TEXT2 SEPARATED BY SPACE.
ELSEIF X_ARTD = 'X'. " Löschen
CONCATENATE TEXT-006 X_USREXP TEXT-007 X_MDTEXP
INTO X_TEXT1 SEPARATED BY SPACE.
X_TEXT2 = TEXT-014.
ELSEIF X_ARTE = 'X'. " Export
CONCATENATE TEXT-006 X_USREXP TEXT-007 X_MDTEXP
INTO X_TEXT1 SEPARATED BY SPACE.
X_TEXT2 = TEXT-010.
ELSEIF X_ARTI = 'X'. " Import
CONCATENATE TEXT-012 X_USREXP TEXT-007 X_MDTEXP
INTO X_TEXT1 SEPARATED BY SPACE.
X_TEXT2 = TEXT-011.
ENDIF.
PERFORM POPUP_JN.
IF X_ANTWORT = 'J'. " Ja
IF X_ARTC = 'X'. " Copy
PERFORM FA_COPY.
ELSEIF X_ARTD = 'X'. " Löschen
PERFORM FA_DELETE.
MESSAGE S084 WITH X_USREXP X_MDTEXP.
ELSEIF X_ARTE = 'X'. " Export
PERFORM FA_EXPORT.
ELSEIF X_ARTI = 'X'. " Import
PERFORM FA_IMPORT.
ENDIF.
ENDIF.
END-OF-SELECTION.
* -----------------------------------
*******************************************************************
* Unterprogramme *
*******************************************************************
* ----------------------------------------------------------------*
* Copy *
* ----------------------------------------------------------------*
FORM FA_COPY.
MOVE X_TARGET TO X_USREXP. " User Ziel
MOVE X_MDTTRG TO X_MDTEXP. " Mandant Ziel
PERFORM FA_DELETE. " Ziel löschen
SELECT * FROM SMEN_BUFFC CLIENT SPECIFIED
WHERE MANDT EQ X_MDTSRC " Quelle
AND UNAME EQ X_SOURCE.
SMEN_BUFFC-MANDT = X_MDTTRG. " Ziel
SMEN_BUFFC-UNAME = X_TARGET.
INSERT SMEN_BUFFC CLIENT SPECIFIED.
ENDSELECT.
SELECT * FROM SMEN_BUFFI CLIENT SPECIFIED
WHERE MANDT EQ X_MDTSRC
AND UNAME EQ X_SOURCE.
SMEN_BUFFI-MANDT = X_MDTTRG.
SMEN_BUFFI-UNAME = X_TARGET.
INSERT SMEN_BUFFI CLIENT SPECIFIED.
ENDSELECT.
SELECT * FROM SMENFAVDAT CLIENT SPECIFIED
WHERE MANDT EQ X_MDTSRC
AND UNAME EQ X_SOURCE.
SMENFAVDAT-MANDT = X_MDTTRG.
SMENFAVDAT-UNAME = X_TARGET.
INSERT SMENFAVDAT CLIENT SPECIFIED.
ENDSELECT.
IF SY-SUBRC = 0.
MESSAGE S085 WITH X_SOURCE X_MDTSRC X_TARGET X_MDTTRG.
ENDIF.
ENDFORM.
* ----------------------------------------------------------------*
* Löschen *
* ----------------------------------------------------------------*
FORM FA_DELETE.
DELETE FROM SMEN_BUFFC CLIENT SPECIFIED
WHERE MANDT EQ X_MDTEXP
AND UNAME EQ X_USREXP.
DELETE FROM SMEN_BUFFI CLIENT SPECIFIED
WHERE MANDT EQ X_MDTEXP
AND UNAME EQ X_USREXP.
DELETE FROM SMENFAVDAT CLIENT SPECIFIED
WHERE MANDT EQ X_MDTEXP
AND UNAME EQ X_USREXP.
ENDFORM.
* ----------------------------------------------------------------*
* Export *
* ----------------------------------------------------------------*
FORM FA_EXPORT.
PERFORM CHECK_FILE.
IF X_DO = 1.
REFRESH: SMEN_TAB.
SELECT * FROM SMEN_BUFFC CLIENT SPECIFIED
WHERE MANDT EQ X_MDTEXP
AND UNAME EQ X_USREXP.
IF SY-SUBRC = 0.
CLEAR: SMEN_TAB.
MOVE-CORRESPONDING SMEN_BUFFC TO SMEN_TAB.
CLEAR SMEN_TAB-TIMESTMP.
MOVE 'C' TO SMEN_TAB-TYPE.
APPEND SMEN_TAB.
ENDIF.
ENDSELECT.
SELECT * FROM SMEN_BUFFI CLIENT SPECIFIED
WHERE MANDT EQ X_MDTEXP
AND UNAME EQ X_USREXP.
IF SY-SUBRC = 0.
CLEAR: SMEN_TAB.
MOVE-CORRESPONDING SMEN_BUFFI TO SMEN_TAB.
CLEAR SMEN_TAB-TIMESTMP.
MOVE 'I' TO SMEN_TAB-TYPE.
APPEND SMEN_TAB.
ENDIF.
ENDSELECT.
SELECT * FROM SMENFAVDAT CLIENT SPECIFIED
WHERE MANDT EQ X_MDTEXP
AND UNAME EQ X_USREXP.
IF SY-SUBRC = 0.
CLEAR: SMEN_TAB.
MOVE-CORRESPONDING SMENFAVDAT TO SMEN_TAB.
CLEAR SMEN_TAB-TIMESTMP.
MOVE 'F' TO SMEN_TAB-TYPE.
APPEND SMEN_TAB.
ENDIF.
ENDSELECT.
PERFORM WRITE_PC.
ELSE.
MESSAGE S089.
ENDIF.
ENDFORM.
* ----------------------------------------------------------------*
* Import *
* ----------------------------------------------------------------*
FORM FA_IMPORT.
PERFORM FA_DELETE. " Ziel löschen
PERFORM READ_PC.
LOOP AT SMEN_TAB WHERE TYPE = 'C'.
MOVE-CORRESPONDING SMEN_TAB TO SMEN_BUFFC.
SMEN_BUFFC-MANDT = X_MDTEXP. " Ziel
SMEN_BUFFC-UNAME = X_USREXP.
INSERT SMEN_BUFFC CLIENT SPECIFIED.
ENDLOOP.
LOOP AT SMEN_TAB WHERE TYPE = 'I'.
MOVE-CORRESPONDING SMEN_TAB TO SMEN_BUFFI.
SMEN_BUFFI-MANDT = X_MDTEXP. " Ziel
SMEN_BUFFI-UNAME = X_USREXP.
INSERT SMEN_BUFFI CLIENT SPECIFIED.
ENDLOOP.
LOOP AT SMEN_TAB WHERE TYPE = 'F'.
MOVE-CORRESPONDING SMEN_TAB TO SMENFAVDAT.
SMENFAVDAT-MANDT = X_MDTEXP. " Ziel
SMENFAVDAT-UNAME = X_USREXP.
INSERT SMENFAVDAT CLIENT SPECIFIED.
ENDLOOP.
IF SY-SUBRC = 0.
MESSAGE S088 WITH X_USREXP X_MDTEXP.
ENDIF.
ENDFORM.
* ----------------------------------------------------------------*
* Prüfen ob PC-Datei existiert *
* ----------------------------------------------------------------*
FORM CHECK_FILE.
X_DO = 0.
CALL FUNCTION 'WS_QUERY'
EXPORTING
FILENAME = X_FILEP
QUERY = 'FE'
IMPORTING
RETURN = X_RC.
IF X_RC = 1. " File vorhanden
CONCATENATE TEXT-016 X_FILEP TEXT-017
INTO X_TEXT1 SEPARATED BY SPACE.
MOVE TEXT-018 TO X_TEXT2.
PERFORM POPUP_JN.
IF X_ANTWORT = 'J'. " Ja
X_DO = 1.
ENDIF.
ELSE.
X_DO = 1.
ENDIF.
ENDFORM.
* ----------------------------------------------------------------*
* PC-Datei schreiben *
* ----------------------------------------------------------------*
FORM WRITE_PC.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = X_FILEP
FILETYPE = 'ASC'
MODE = ' '
IMPORTING
FILELENGTH = X_FILELENGTH
TABLES
DATA_TAB = SMEN_TAB
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
GUI_REFUSE_FILETRANSFER = 8
OTHERS = 9.
IF SY-SUBRC = 0.
MESSAGE S086 WITH X_FILEP.
ELSE.
MESSAGE I023 WITH X_FILEP.
ENDIF.
ENDFORM.
* ----------------------------------------------------------------*
* PC-Datei laden *
* ----------------------------------------------------------------*
FORM READ_PC.
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = X_FILEP
TABLES
DATA_TAB = SMEN_TAB
EXCEPTIONS
CONVERSION_ERROR = 1
FILE_OPEN_ERROR = 2
FILE_READ_ERROR = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7
GUI_REFUSE_FILETRANSFER = 8
OTHERS = 9.
IF SY-SUBRC NE 0.
MESSAGE I087 WITH X_FILEP.
ENDIF.
ENDFORM.
* ----------------------------------------------------------------*
* Popup Sicherheitsabfrage *
* ----------------------------------------------------------------*
FORM POPUP_JN.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
* DEFAULTOPTION = X_OPT
TEXTLINE1 = X_TEXT1
TEXTLINE2 = X_TEXT2
TITEL = X_TITEL
IMPORTING
ANSWER = X_ANTWORT
EXCEPTIONS
OTHERS = 0.
ENDFORM.
* *************************************************
*Text elements
*-------------
* I002 Aktion
* I004 PC-File
* I006 Favoriten von
* I008 nach
* I010 exportieren ?
* I012 Favoriten nach
* I014 löschen ?
* I016 Datei
* I018 Überschreiben ?
*Selection texts
*---------------
*SX_ARTC Kopieren
*SX_ARTD Löschen
*SX_ARTE Export
*SX_ARTI Import
*SX_FILEP PC-File
*SX_MDTEXP Mandant
*SX_MDTSRC Mandant
*SX_MDTTRG Mandant
*SX_SOURCE Quelle User
*SX_TARGET Ziel User
*SX_USREXP User
*Messages
*-------------
* Message class: XXXX
* 002 Keine Berechtigung für die Transaktion &1 !
* 023 Datei &1 kann nicht geschrieben werden.
* 068 Bitte einen Wert eingeben !
* 081 Quelle und Ziel müßen unterschiedlich sein
* 082 Benutzer &1 in Mandant &2 nicht vorhanden !
* 083 Mandant &1 ist nicht vorhanden !
* 084 Favoriten von &1 in Mandant &2 wurden gelöscht !
* 085 Favoriten von &1 Mandant &2 nach &3 Mandant &4 kopiert !
* 086 Daten wurden nach &1 übertragen.
* 087 Datei &1 kann nicht gelesen werden.
* 088 Favoriten wurden nach &1 Mandant &2 importiert.
* 089 Export / Import wurde abgebrochen.