Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to create .csv file

Former Member
0 Likes
3,828

Hi experts,

an internal table contains some data.

how to create .csv file in presentation server.

any function module is available to create excel file in presentation server.

Advanced thanks,

Prerna.

Hi experts,

an internal table contains some data.

how to create .csv file in presentation server.

any function module is available to create excel file in presentation server.

Advanced thanks,

Prerna.

3 REPLIES 3
Read only

Former Member
0 Likes
1,157

just copy and paste and run.

ype-pools:TRUXS.
data: begin of itab occurs 0,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
end of itab.
data: itab1 type TRUXS_T_TEXT_DATA.
select vbeln
posnr
up to 10 rows
from vbap
into table itab.

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = ','
TABLES
I_TAB_SAP_DATA = itab
CHANGING
I_TAB_CONVERTED_DATA = itab1
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:TEMPtest.TXT'
TABLES
data_tab = itab1
EXCEPTIONS
OTHERS = 1.

Read only

Former Member
0 Likes
1,157

Hi

MS_EXCEL_OLE_STANDARD_OLE

will build a file, and automatically start Excel

Hope it will work

Read only

Former Member
0 Likes
1,157

hi

good

try this

Use the Function Module SAP_CONVERT_TO_CSV_FORMAT to convert the internal table into Comma seperated format then download this internal table using the Function Module GUI_DOWNLOAD.

See a sample program below:

TYPE-POOLS: truxs.

TYPES:

BEGIN OF ty_Line,

vbeln LIKE vbap-vbeln,

posnr LIKE vbap-posnr,

END OF ty_Line.

ty_Lines TYPE STANDARD TABLE of ty_Line WITH DEFAULT KEY.

DATA: itab TYPE ty_Lines.

DATA: itab1 TYPE truxs_t_text_data.

SELECT

vbeln

posnr

UP TO 10 ROWS

FROM vbap

INTO TABLE itab.

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'

EXPORTING

i_field_seperator = ';'

TABLES

i_tab_sap_data = itab

CHANGING

i_tab_converted_data = itab1

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = 'C:\TEMP\test.txt'

TABLES

data_tab = itab1

EXCEPTIONS

OTHERS = 1.

thanks

mrutyun^