SAP Database - The Unofficial SAP Knowledge Base

Free Business and Tech Magazines and eBooks

ABAP Program:Transferring data to a file (presentation server)

Print This Post Email This Post Written by admin on Feb 4th, 2008 | Filed under: ABAP Programs
REPORT ZSOURCE2603.
* Data declarations for later use
PARAMETERS FILENAME(128) DEFAULT 'c:\users\default\testfile.dat'
                         LOWER CASE.
TABLES CUSTOMERS.
DATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100
                   WITH HEADER LINE.
* Get data for file transfer
SELECT * FROM CUSTOMERS INTO TABLE ALL_CUSTOMERS.

SORT ALL_CUSTOMERS BY CITY.
LOOP AT ALL_CUSTOMERS.
  WRITE: / ALL_CUSTOMERS-CITY,
           ALL_CUSTOMERS-NAME.
ENDLOOP.
* Transferring Data
CALL FUNCTION 'WS_DOWNLOAD'
     EXPORTING
          FILENAME            = FILENAME
     TABLES
          DATA_TAB            = ALL_CUSTOMERS
     EXCEPTIONS
          FILE_OPEN_ERROR     = 1
          OTHERS              = 2.
CASE SY-SUBRC.
  WHEN 1.
    WRITE 'Error when file opened'.
    EXIT.
  WHEN 2.
    WRITE 'Error during data transfer'.
    EXIT.
ENDCASE.

If you like this post, you may as well like these too:

  1. ABAP Programs:Reading data from a file (presentation server) REPORT ZSOURCE2604. * Data declarations for later use PARAMETERS FILENAME(128) DEFAULT 'c:\users\default\testfile.dat' LOWER CASE. TABLES CUSTOMERS. DATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100 [...]...
  2. ABAP Programs: Transferring data to a file Here is a little program, which will teach you to transfer the data to a file. REPORT ZSOURCE2601. * Data declarations for later use PARAMETERS FILENAME(128) DEFAULT '/usr/tmp/testfile.dat' LOWER CASE....
  3. ABAP Program:Reading data from a file REPORT ZSOURCE2602. * Data declarations for later use TABLES CUSTOMERS. PARAMETERS FILENAME(128) DEFAULT '/usr/tmp/testfile.dat' LOWER CASE. DATA: MSG_TEXT(50), ALL_CUSTOMER_NAMES LIKE CUSTOMERS-NAME OCCURS 100 [...]...
  4. ABAP Program: Sample program for OLE Automation REPORT ZSOURCE2801. * Including OLE types INCLUDE OLE2INCL. * Tables and variables for later use TABLES: CUSTOMERS. DATA: APPLICATION TYPE OLE2_OBJECT, WORKBOOK TYPE OLE2_OBJECT, SHEET TYPE OLE2_OBJECT, CELLS TYPE...
  5. Internet Transaction Server (ITS) Internet Transaction Server (ITS) is the transaction processing system that connects the web HTTP server and the standard R/3 system. ITS is available since SAP release 3.1G. All the Internet...



This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Leave a Reply

  • Subscribe to RSS

  • Free Ebooks