on 07-01-2008 8:10 AM
Hi All,
I have all my data in an internal table.I want to Upload this data to the Application server in the EXCEL sheet with the Column Header.
How can i do this.Is there any standarad function module or class to to write in xls format.
Can anybody help me.
Thanks,
Swapna
Hi
In SAP ABAP you can transfer the contents of the internal table to a file. This is required when you wish to extract data from SAP tables into a flat file. This file can then be used to transfer data to another SAP or NON SAP system. This can also be used for an interfacing when you wish to transfer data on a daily or a weekly basis from R/3 to NON R/3 or SAP. The command used to create a file on the application server is as follows.
OPEN DATASET
Please see example code below.
REPORT ZEX_DATATOFILE .
&----
*& ABAPLOVERS: Data Transfer
&----
Parameters to enter the path
PARAMETERS FILENAME(128) DEFAULT '/usr/tmp/testfile.dat'
LOWER CASE.
Table Declaration
TABLES VBAK.
Data Declaration
DATA D_MSG_TEXT(50).
Get data for file transfer
DATA INT_VBAK LIKE VBAK OCCURS 100
WITH HEADER LINE.
SELECT * FROM VBAK INTO TABLE INT_VBAK.
SORT INT_VBAK BY VBELN.
LOOP AT INT_VBAK.
WRITE: / INT_VBAK-VBELN,
INT_VBAK-KUNNR.
ENDLOOP.
Opening the File
OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE
MESSAGE D_MSG_TEXT.
IF SY-SUBRC NE 0.
WRITE: 'File cannot be opened. Reason:', D_MSG_TEXT.
EXIT.
ENDIF.
Transferring Data
LOOP AT INT_VBAK.
TRANSFER INT_VBAK-VBELN TO FILENAME.
ENDLOOP.
Closing the File
CLOSE DATASET FILENAME.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.