Monday, December 20, 2010
  • Convert data to CSV format using SAP_CONVERT_TO_CSV_FORMAT.
  • Download data using GUI_DOWNLOAD.

REPORT ztest_notepad.
"Declarations
TYPE-POOLS :truxs.
DATA : it_download TYPE truxs_t_text_data.
DATA: BEGIN OF it_data OCCURS 0,
arbgb TYPE t100-arbgb,
msgnr TYPE t100-msgnr,
text TYPE t100-text,
END OF it_data.

START-OF-SELECTION.
"Select Data
SELECT * FROM t100
INTO CORRESPONDING FIELDS OF TABLE it_data UP TO 200 ROWS   WHERE sprsl = sy-langu.
"Convert SAP to CSV format
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
i_field_seperator    = ';'
TABLES
i_tab_sap_data       = it_data
CHANGING
i_tab_converted_data = it_download
EXCEPTIONS
conversion_failed    = 1
OTHERS               = 2.
IF sy-subrc = 0.
"Download data using GUI_DOWNLOAD
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\test.txt'
filetype = 'ASC'
TABLES
data_tab = it_download.
ENDIF. 

0 comments:

Post a Comment

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.