Shared Top Border

Enterprise Resource
Planning Portal

 

Advertise | Founder BLOG

ERPGenie.COM ABAP Tips and Tricks Database

THE ultimate
ERP website

 

Forums | Vote for us |

Google    Other Search Options

Login

Login to view more content!!!





Lost Password?
No account yet? Register

Registered Access

Poll

What area of ABAP are you interested in?
 
Home arrow Utilities arrow ABAP Utilities arrow Transfer files to/from server
Transfer files to/from server PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Ken Greenwood   
Saturday, 20 January 2007
File Transfer Utility ( pc<->app server )
This transfers sequential files from the application server to your hard drive, or from your hard drive to the application server. REPORT ZAPC0015.
   * File Transfer Utility ( pc<->app server )
   * Evaluation Version - Copyright ¸1998 Ken Greenwood
   *
   * This transfers sequential files from the application server
   * to your hard drive, or from your hard drive to the application server.
   *
   * View the readme on the installation CD for instructions on how to
   * use this program.
   *
   * This is the evaluation version. The registered version is avaliable
   * in Single-User License or Corporate Licenses.
   * Visit http://www.abap.net to purchase this product.
   * Note: The registered version transfers multiple files at a time.
   *
   *          This program is Copyright ¸1998 Ken Greenwood
   *                     http://www.abap.net
   *______________________________________________________________________


   tables:


       SSCRFIELDS. "

Campos

 en las imagenes de seleccion



 

   data:


       IT(5000) OCCURS 100 WITH HEADER LINE.



 

   *-parameters----------------------------------------------------------*


   selection-screen:


       begin of block b1 with frame title text-004.



 

   parameters:


       sfn(128) obligatory lower case memory id z0s   " server file name


                default '/usr/sap/tmp/?',


       pfn(128) obligatory lower case memory id z0p   " pc file name


                default 'c:\temp\temp.txt',


       efn(128) obligatory lower case                 " editor file name


                DEFAULT 'notepad.exe'.


   selection-screen:


       skip,


       PUSHBUTTON /05(23) TEXT-001 USER-COMMAND ZGET, "Serv -> PC


       PUSHBUTTON  30(23) TEXT-002 USER-COMMAND ZPUT, "PC -> Serv


       PUSHBUTTON  55(23) TEXT-003 USER-COMMAND ZPAD, "Ver fichero


       end of block b1.


   *-mainline------------------------------------------------------------*



 

   *-events--------------------------------------------------------------*


   at selection-screen.


       case sscrfields-ucomm.


       when 'ZGET'.  perform getfrsrv.


       when 'ZPUT'.  perform puttosrv.


       when 'ZPAD'.  perform editfile.


       endcase.



 

   AT

SELECTION-SCREEN
 
ON

 VALUE-REQUEST FOR EFN.


     CALL FUNCTION 'WS_FILENAME_GET'


          EXPORTING


               DEF_FILENAME     = EFN


               DEF_PATH         = '/'


               MASK             = ',*.*,*.*.'


               MODE             = 'O'


               TITLE            = 'Get filename'


          IMPORTING


               FILENAME         = EFN


   *              rc               =


          EXCEPTIONS


               INV_WINSYS       = 01


               NO_BATCH         = 02


               SELECTION_CANCEL = 03


               SELECTION_ERROR  = 04.


   *-forms---------------------------------------------------------------*


   form editfile.


       data:


           exists value '0'.


       perform fileexists


           changing exists.


       if exists = '0'.


           refresh it.


           perform download.


           endif.


       perform runnotepad.


       endform.



 

   *---------------------------------------------------------------------*


   form fileexists


       changing exists.


       call function 'WS_QUERY'


            exporting


                 filename       = pfn


                 query          = 'FE'     " file exists?


            importing


                 return         = exists


            exceptions


                 inv_query      = 1


                 no_batch       = 2


                 frontend_error = 3


                 others         = 4.


       endform.



 

   *---------------------------------------------------------------------*


   form getfrsrv.


       refresh it.


       perform dsopen_input_text


           using sfn.


       perform xfer2it.


       perform download.


       perform runnotepad.


       endform.



 

   *-forms---------------------------------------------------------------*


   form puttosrv.


       refresh it.


       perform upload.


       perform dsopen_output_text


           using sfn.


       perform xferfromit


           using sfn.


       endform.



 

   *---------------------------------------------------------------------*


   form xferfromit


       using dsn.


       loop at it.


           perform dswrite


               using dsn


                     it.


           endloop.


       endform.



 

   *---------------------------------------------------------------------*


   form xfer2it.


       while sy-subrc = 0.


           perform dsread


               using    sfn


               changing it.


           if sy-subrc <> 0.


               exit.


               endif.


           append it.


           endwhile.


       perform dsclose


           using sfn.


       endform.



 

   *---------------------------------------------------------------------*


   form download.


       call function 'WS_DOWNLOAD'


            exporting


                 filename            = pfn


            tables


                 data_tab            = it


            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


                 others              = 8.


       perform checkrc


           using 'WS_DOWNLOAD'.


       endform.



 

   *---------------------------------------------------------------------*


   form runnotepad.


       data pgm(128).


       concatenate


           efn pfn into pgm


           separated by space.


       call function 'WS_EXECUTE'


            exporting


                 program        = pgm


            exceptions


                 frontend_error = 1


                 no_batch       = 2


                 prog_not_found = 3


                 illegal_option = 4


                 others         = 5.


       perform checkrc


           using 'WS_EXECUTE'.


       endform.



 

   *---------------------------------------------------------------------*


   form upload.


       call function 'WS_UPLOAD'


            exporting


                 filename            = pfn


            tables


                 data_tab            = it


            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


                 others              = 8.


       perform checkrc


           using 'WS_UPLOAD'.


       endform.



 

   *---------------------------------------------------------------------*


   form writetoscrn.


       window starting at 5  3


              ending   at 90 15.


       loop at it.


           write it.


           endloop.


       endform.



 

   *---------------------------------------------------------------------*


   form checkrc using n.


       if sy-subrc <> 0.


           write: / 'rc=', sy-subrc, 'from', n.


           stop.


           endif.


       endform.



 

   *-macro-for-form-definition-------------------------------------------*


   define dsform_open.


       form dsopen_&1_&2 using


               dsn  type c.


           data msg(80).


           open dataset dsn for &1 in &2 mode message msg.


           if sy-subrc <> 0.


               message e001(zk) with 'Error opening' dsn msg.


               endif.


           endform.


       end-of-definition.



 

   *---------------------------------------------------------------------*


   dsform_open input  text.


   dsform_open input  binary.


   dsform_open output text.


   dsform_open output binary.



 

   *--------------------------------------------------------------------


   form dsread


       using    dsn type c


       changing rec.



 

       statics: rctr type i.



 

       read dataset dsn into rec.


       case sy-subrc.


       when 0.


           add 1 to rctr.


       when 4.


           message s001(zk) with rctr 'records read from' dsn.


       when others.


           message e001(zk) with 'Error reading' dsn 'rc=' sy-subrc.


           endcase.


       endform.



 

   *--------------------------------------------------------------------


   form dswrite


       using    dsn type c


                rec.



 

       statics: rctr type i.



 

       transfer rec to dsn.


       case sy-subrc.


       when 0.


           add 1 to rctr.


       when others.


           message e001(zk) with 'Error writing to' dsn 'rc=' sy-subrc.


           endcase.


       endform.



 

   *--------------------------------------------------------------------


   form dsclose


       using dsn type c.


       close dataset dsn.


       if sy-subrc <> 0.


           message e001(zk) with 'Error closing' dsn 'rc=' sy-subrc.


           endif.


       endform.



 
< Prev

Google Search

Statistics

Contribution Activity
Utilities: 38
Tips and Tricks: 333
Sample Code: 164
Total Contributions: 550

Member Activity
Members: 6182 since 2/1/2007!
New: 9 since yesterday!
Visitors: 1010342
We have 1 guest online

Newest Members

Welcome our newest members:

Google Ads

Shared Bottom Border

Contact Us | Polls | Add URL | Contribute | Privacy | Terms | Feedback

Discussion Forum | BLOG | Consultants: Post your resume | Companies: Advertise on ERPGenie.COM | Post Job
Financials Consultant | Consultant Review | Gallia Consulting | Supply Chain Project | SAP Financials Forum
GenieHoldings.COM, Inc. | Genie Press | WorkflowGenie | ESAGenie | ERPTopSites | ABAP Tips and Tricks | SAP Solutions Database

EDIGenie | Searching Survivor