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

Using WS_DOWNLOAD



 
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: 1639

PostPosted: Mon Sep 10, 2007 7:33 pm    Post subject: Using WS_DOWNLOAD Reply with quote

Code:
*** Internal table to be downloaded
data: begin of z_sales occurs 10000,                     
          kunnr like kna1-kunnr,       "Customer number   
          name1 like kna1-name1,       "Name             
         end of z_sales.
data: begin of t_colnames occurs 10,                               
       name(15),                       "Column names for download   
       end of t_colnames.                                           

selection-screen begin of block g2 with frame title text-001.
parameters: p_print radiobutton group l1,         “View
            p_down  radiobutton group l1,              “Download
            p_file like rlgrap-filename default 'C:\'.
selection-screen end of block g2.                             

*----------------------------------------------------------------------*
* Selection Screen processing                                          *
*----------------------------------------------------------------------*
at selection-screen on p_file.                                           
* If download is checked, but no file name is entered, error             
  if p_down eq 'X' and p_file eq space.                                 
    message e000 with                                                   
          'Please enter file name for download.'.                       
  endif.                                                                 

*** Populate Itabs for download
* Column names
move  'Sold-to'           to t_colnames-name.
append t_colnames.                           
move  'Name'              to t_colnames-name.
append t_colnames.                           

* Data
move vbak-kunnr to zsales-kunnr.
move kna1-name1 to zsales-name1.
append zsales.

* Call function module to download file
call function 'WS_DOWNLOAD'                               
       exporting                                           
            filename                = p_file               
            filetype                = 'DAT'                 
*           col_select              = 'X'                   
       tables                                               
            data_tab                = z_sales               
            fieldnames              = t_colnames           
*    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 id sy-msgid type sy-msgty number sy-msgno       
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.       
  endif.                                                   
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.