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

write CSV file on application server using OPEN DATASET.

Former Member
0 Likes
5,719

how to write an internal table to a .csv file on application server using OPEN DATASET output?

5 REPLIES 5
Read only

Former Member
0 Likes
1,883

U can't write data of internal table as .csv format in an application server. U can just dump the data line by line in application server and then may be u can write another program to read this data and do changes and download to .csv format file.

Read only

Former Member
0 Likes
1,883

HI Suhas,

Try the follwoing way.

loop at itab.

concatenate itab-field1 itab-field2....into itab_new-data separated by ','.

append itab_new.

clear itab_new.

endloop.

open dataset <filename> for output in text mode.

loop at itab_new.

transfer itab_new to <filename>.

endloop.

close dataset <filename>.

Regards,

Ravi Kanth Talagana

Read only

Former Member
0 Likes
1,883

Hi Suhas,

You can use like this:

DATA: e_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.

open dataset e_file for output in text mode.

lOOP AT it_datatab......

transfer it_datatab to e_file.

ENDLOOP.

close dataset e_file.

Reagrds

Sourabh Verma

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,883

Hello Suhas

I think if you do not provide a file name for function module SAP_CONVERT_TO_CSV_FORMAT (using cl_abap_char_utilities=>horizontal_tab as delimiter) then the fm convert a structured itab into an unstructured itab (holding TAB separated data).

Then you can use this unstructured itab as input for the OPEN DATASET statement.

Regards,

Uwe

Read only

Former Member
0 Likes
1,883

thanks