cancel
Showing results for 
Search instead for 
Did you mean: 

Upload internal table data to Application server in Excel Sheet

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Answers (0)