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

PC file: upload to or download from application server



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

PostPosted: Sat Sep 15, 2007 9:12 pm    Post subject: PC file: upload to or download from application server Reply with quote

Code:
report z.
types:      t_file(255)  type c,
            t_inf(65535) type c,
            t_it         type t_inf occurs 0.
************************************************************************
parameters:
  pcfile  like rlgrap-filename default 'c:\temp\' obligatory lower case,
  unixfile type t_file         default '/tmp/'    obligatory lower case,
  pctounix radiobutton group x,
  unixtopc radiobutton group x.
************************************************************************
data:       it_file     type t_it with header line,
            w_msg(100).

************************************************************************
at selection-screen on value-request for pcfile.
  call function 'WS_FILENAME_GET'
       exporting    mask     = ',*.*,*.*.'
       importing    filename = pcfile
       exceptions   others   = 1.
  if sy-subrc <> 0.
    message id sy-msgid type 'I' number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.


************************************************************************
end-of-selection.
  if pctounix = 'X'.
    perform ws_upload.
    check sy-subrc = 0.
    perform write_file.
  else.
    perform read_file.
    check sy-subrc = 0.
    perform ws_download.
  endif.
  check sy-subrc = 0.
  call function 'WS_MSG'
    exporting msg_type = 'I'
              text     = 'Completed successfully'.

************************************************************************
form read_file.
*--- open UNIX file
  open dataset unixfile for input in text mode message w_msg.
  if sy-subrc ne 0.
    write: / 'Cannot open for reading:', unixfile, w_msg.
    exit.
  endif.
*--- read UNIX file
  do.
    read dataset unixfile into it_file.
    if sy-subrc = 0. append it_file.
    else.            exit.
    endif.
  enddo.
*--- close UNIX file
  close dataset unixfile.
endform.
************************************************************************
form write_file.
*--- open UNIX file
  open dataset unixfile for output in text mode message w_msg.
  if sy-subrc ne 0.
    write: / 'Cannot open for writing:', unixfile, w_msg.
    exit.
  endif.
*--- write UNIX file
  loop at it_file.
    transfer it_file to unixfile.
  endloop.
*--- close UNIX file
  close dataset unixfile.
endform.
************************************************************************
form ws_upload.
  call function 'WS_UPLOAD'
    exporting
      filename                      = pcfile
      filetype                      = 'ASC'
    tables
      data_tab                      = it_file
    exceptions
      others                        = 1.
  if sy-subrc <> 0.
    message id sy-msgid type 'I' number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.
endform.
************************************************************************
form ws_download.
  call function 'WS_DOWNLOAD'
    exporting
      filename                      = pcfile
      filetype                      = 'ASC'
    tables
      data_tab                      = it_file
    exceptions
      others                        = 1.
  if sy-subrc <> 0.
    message id sy-msgid type 'I' number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.
endform.
************************************************************************

Source: http://www.geocities.com/victorav15/sapr3/utilities/files.txt
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.