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

Upload and Download of Favorites



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Sun Nov 04, 2007 4:37 pm    Post subject: Upload and Download of Favorites Reply with quote

Upload and Download of Favorites (From Version SAP relases 4.6x)

Parameters:
P_UNAME SAP User
P_LANGU Sprache
P_EXP Export
P_IMP Import
P_TYPE Übertragungsformat der Daten
P_PATH Pfad
P_TEST Testmodus

Code:
REPORT ZFAV.
*
**********************         HEADER                    **************
*
* Copyright (c) 2001 by xxxx xxx, 44318 Anywhere, http://xxxxx
* or: Copyright (c) 2001 by X.X. from X.
*
*     You can use or modify this report for your own work as long
*               as you don't try to sell or republish it.
*      In no event will the author be liable for indirect, special,
*        Incidental, or consequental damages (if any) arising out of
*                       the use of this report.
*//////////////////////////////////////////////////////////////////////*
* Append your coding here ...
*&---------------------------------------------------------------------*
*& Report  ZFAV                                                        *
*& Favoriten Upload/Downl.                                             *
*& Rel. 4.6B                                                           *
*&---------------------------------------------------------------------*
*& Author : Klaus Todebusch                                            *
*&---------------------------------------------------------------------*
*-- Data  ---------------
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 -----------
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'.

PARAMETERS: p_test AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END   OF BLOCK fil.

*-- Data  ---------------
DATA: it_user_nodes TYPE TABLE of bxmnodes1 WITH HEADER LINE.
DATA: it_fav_nodes TYPE TABLE of bxmnodes  WITH HEADER LINE.
*-- DL Itab
DATA: BEGIN OF it_pcf OCCURS 0,
       line(4096) TYPE c.
DATA: END OF it_pcf.

*-----------------------------------------------------------------------
* INITIALIZATION
*-----------------------------------------------------------------------
INITIALIZATION.
  REPLACE 'XXX' WITH sy-uname INTO p_path.
  CONDENSE p_path NO-GAPS.
  sy-title = 'Upload/Download Favoritenliste 4.6B'.
*-----------------------------------------------------------------------
* START-OF-SELECTION
*-----------------------------------------------------------------------
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.
* -- Hauptverarbeitung
  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
*&---------------------------------------------------------------------*
FORM data_export TABLES   pit_pcf
                 USING    p_file.
  IF p_test <> 'X'.
    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: / 'Fehler beim schreiben für Datei' , p_file.
    ENDIF.
  ENDIF.
ENDFORM.                               " DATA_EXPORT
*&---------------------------------------------------------------------*
*&      Form  DATA_IMPORT
*&---------------------------------------------------------------------*
FORM data_import TABLES   pit_pcf
                 USING    p_file p_subrc.
  IF p_test <> 'X'.
    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: / 'Fehler beim lesen der Datei' , p_file.
      p_subrc = sy-subrc .
    ENDIF.
  ENDIF.
ENDFORM.                               " DATA_IMPORT

*&---------------------------------------------------------------------*
*&      Form  IMPORT_FAV
*&---------------------------------------------------------------------*
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.                               " IMPORT_FAV
*&---------------------------------------------------------------------*
*&      Form  EXPORT_FAV
*&---------------------------------------------------------------------*
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
*            SORT_NODES             = ' '
*            GENERATE_URL           = ' '
*            REPLACE_RFC_VARIABLES  = ' '
       TABLES
            output_nodes_and_texts = it_fav_nodes
*            GENERATED_URLS         =
            .

  g_file = p_path.
  PERFORM data_export  TABLES it_fav_nodes USING  g_file .
ENDFORM.                               " EXPORT_FAV

*&---------------------------------------------------------------------*
*&      Form  WRITE_FAV_DB
*&---------------------------------------------------------------------*
FORM write_fav_db TABLES   pit_fav_nodes STRUCTURE it_fav_nodes.
* --> Favoriten wegschreiben
  IF p_test <> 'X'.
    CALL FUNCTION 'BX_FAVOS_WRITE_ALL_NODES'
         EXPORTING
              user_name             = p_uname
              target_client         = sy-mandt
         TABLES
              input_nodes_and_texts = pit_fav_nodes.
  ENDIF.

ENDFORM.                               " WRITE_FAV_DB
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 -> Programming Techniques | Приемы программирования 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.