SAP Database

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 WITH HEADER LINE. CALL FUNCTION 'WS_UPLOAD' EXPORTING...
  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...
  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 WITH HEADER LINE. * Opening the...
  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. ABAP Programs:Sample dialog program (flight reservation) * This program source contains all modules and subroutines of the * flight reservation program, but screen and GUI status definitions * are not included. *&———————————————————————* *&———————————————————————* *& Include...



Leave a Reply

  • Help Support CRY