Önceki Sayfa

Download/Upload SAP Users Favorites

*
*  This program allows you to transfer the user Favorites from one PC to another.

REPORT ZFAVORITES.

DATA :   G_FILE(128)   TYPE C.
DATA :   G_PATH(80)    TYPE C.
DATA :   G_END(8)      TYPE C.
DATA :   G_SUBRC       LIKE SY-SUBRC.

PARAMETERS: P_UNAME LIKE SY-UNAME DEFAULT SY-UNAME.
PARAMETERS: P_LANGU LIKE SY-LANGU DEFAULT SY-LANGU.

SELECTION-SCREEN SKIP.

PARAMETERS:     P_IMP  RADIOBUTTON GROUP ACT .
PARAMETERS:     P_EXP  RADIOBUTTON GROUP ACT DEFAULT 'X'.

SELECTION-SCREEN ULINE.
SELECTION-SCREEN BEGIN OF BLOCK FIL.
PARAMETERS:     P_TYPE LIKE RLGRAP-FILETYPE DEFAULT 'ASC'.
PARAMETERS:     P_PATH LIKE G_PATH DEFAULT 'C:\TEMP\XXX.MEN'.

SELECTION-SCREEN END   OF BLOCK FIL.

DATA: IT_USER_NODES TYPE TABLE OF BXMNODES1 WITH HEADER LINE.
DATA: IT_FAV_NODES TYPE TABLE OF BXMNODES  WITH HEADER LINE.

DATA: BEGIN OF IT_PCF OCCURS 0,
LINE(4096) TYPE C.
DATA: END OF IT_PCF.

INITIALIZATION.
REPLACE 'XXX' WITH SY-UNAME INTO P_PATH.
CONDENSE P_PATH NO-GAPS.
SY-TITLE = 'UPLOAD/DOWNLOAD FAVORITE'.

START-OF-SELECTION.

CLEAR IT_USER_NODES[].
CLEAR IT_FAV_NODES[].

G_FILE = P_UNAME.

IF P_UNAME <> SY-UNAME.
MESSAGE W398(00) WITH 'CURRENT USER <> USER TO BE MODIFIED!'.
ENDIF.

IF P_IMP  = 'X'.
PERFORM IMPORT_FAV         TABLES IT_FAV_NODES.
PERFORM WRITE_FAV_DB       TABLES IT_FAV_NODES.
ELSEIF P_EXP  = 'X'.
PERFORM EXPORT_FAV         TABLES IT_FAV_NODES.
ENDIF.

FORM DATA_EXPORT TABLES   PIT_PCF
USING    P_FILE.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
FILENAME               = P_FILE
FILETYPE                = P_TYPE
TABLES
DATA_TAB                = PIT_PCF
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 NE 0.
WRITE: / 'FAILURE IN DOWNLOAD' , P_FILE.
ENDIF.
ENDFORM.

FORM DATA_IMPORT TABLES   PIT_PCF
USING    P_FILE P_SUBRC.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME                = P_FILE
FILETYPE                = P_TYPE
TABLES
DATA_TAB                = PIT_PCF
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.
WRITE: / 'UPLOAD FAILED' , P_FILE.
P_SUBRC = SY-SUBRC .
ENDIF.
ENDFORM.

FORM IMPORT_FAV TABLES   PIT_FAV_NODES STRUCTURE IT_FAV_NODES.
G_FILE = P_PATH.
PERFORM DATA_IMPORT  TABLES IT_FAV_NODES USING  G_FILE G_SUBRC .
ENDFORM.

FORM EXPORT_FAV TABLES   PIT_FAV_NODES STRUCTURE IT_FAV_NODES.
CALL FUNCTION 'BX_FAVOS_READ_ALL_NODES'
EXPORTING
USER_NAME              = P_UNAME
LANGUAGE               = P_LANGU
TABLES
OUTPUT_NODES_AND_TEXTS = IT_FAV_NODES.

G_FILE = P_PATH.
PERFORM DATA_EXPORT  TABLES IT_FAV_NODES USING  G_FILE .
ENDFORM.

FORM WRITE_FAV_DB TABLES   PIT_FAV_NODES STRUCTURE IT_FAV_NODES.
CALL FUNCTION 'BX_FAVOS_WRITE_ALL_NODES'
EXPORTING
USER_NAME             = P_UNAME
TARGET_CLIENT         = SY-MANDT
TABLES
INPUT_NODES_AND_TEXTS = PIT_FAV_NODES.

ENDFORM.

<span class=SpellE><span style='font-size:7.5pt;font-family:"Tahoma","sans-serif"; mso-fareast-font-family:"Times New Roman";color:#464646'>Copyright</span></span><span style='font-size:7.5pt;font-family:"Tahoma","sans-serif";mso-fareast-font-family: "Times New Roman";color:#464646'> &copy; 2010. KM <span class=SpellE>Group</span>. <span class=SpellE>All</span> <span class=SpellE>Rights</span> <span class=SpellE>Reserved</span>.</span></p> </td> </tr> </table> <p class=MsoNormal><span style='mso-fareast-font-family:"Times New Roman"'><o:p>&nbsp;</o:p></span></p> </div> </body> </html>