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.

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

Dig deeper on SAP application integration

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

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:

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close