Tip

Download to another server on the network

This sample program allows you to download text-data in the background to a file anywhere in your network. It works for me at least in a NT4 / ethernet network.
The parameter output filename:
As a default, I suggest local harddisk C: in directory: temp with filename: comp.txt
This will be on the presentation server if executed in forground processing will be on the application server if executed in background processing In case of processing in background you are able to place the outputfile anywhere on the network by simply specifying the machineaddress, sharename and filename in the following format:
hostnamesharenamefilename
examples: Saptestsapmntcomp.txt
10.10.10.10sapmntcomp.txt
The code was written in 3.1I.


REPORT Z_DOWNLOAD LINE-SIZE 123.
*&---------------------------------------------------------------------*
*& Report  Z_DOWNLOAD                                                  *
*&                                                                     *
*&---------------------------------------------------------------------*
*&  Author : R. van der Velden                                         *
*&  Purpose: Example of Foreground/Background downloading data         *
*&           in foreground transfer datafile to PC                     *
*&           in background open datafile on server as textfile         *
*&  Created on SAP R/3 3.1I on Windows NT4                             *
*&---------------------------------------------------------------------*

TABLES:

    Requires Free Membership to View

T001. " Company codes and text DATA: BEGIN OF REC OCCURS 0, "table to download bukrs like t001-bukrs, butxt like t001-butxt, END OF REC. *&---------------------------------------------------------------------* *& Select-options ,parameters SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-B01. SELECTION-SCREEN BEGIN OF LINE. "Ask directory/filename SELECTION-SCREEN COMMENT 1(32) TEXT-S01 FOR FIELD PA_FIL. SELECTION-SCREEN POSITION 34. PARAMETERS PA_FIL LIKE RLGRAP-FILENAME DEFAULT 'c:tempcomp.txt'. SELECTION-SCREEN END OF LINE. SELECTION-SCREEN END OF BLOCK 1. *&---------------------------------------------------------------------* START-OF-SELECTION. SELECT * INTO CORRESPONDING FIELDS OF TABLE REC. * write outputfile to PC or Server. IF NOT SY-BATCH = 'X'. ** " Call Download function to PC CALL FUNCTION 'DOWNLOAD' EXPORTING FILENAME = PA_FIL FILETYPE = 'ASC' TABLES DATA_TAB = REC EXCEPTIONS INVALID_FILESIZE = 1 INVALID_TABLE_WIDTH = 2 INVALID_TYPE = 3 NO_BATCH = 4 UNKNOWN_ERROR = 5 GUI_REFUSE_FILETRANSFER = 6 OTHERS = 7. IF SY-SUBRC <> 0. WRITE: / 'Error in transferring file ', PA_FIL. ENDIF. ELSE. ** " Background Datafile creation OPEN DATASET PA_FIL FOR OUTPUT IN TEXT MODE. IF SY-SUBRC = 0. LOOP AT REC INTO REC. TRANSFER REC TO PA_FIL. ENDLOOP. CLOSE DATASET PA_FIL. ELSE. MESSAGE W010(1) WITH TEXT-E10 HL_FILENAME. ENDIF. ENDIF.

This was first published in January 2003

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.