Application Development 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: 

How to download itab values in CSV format

Former Member
0 Kudos

Hi All,

I need to transfer internal table values as CSV format

Data:

Startdate,SSN #,DOB -


<b>HEADER</b>

01012006,25252552,01012006--- <b>DATA</b>

01012006,25252553,01012006--- <b>DATA</b>

01012006,25252555,01012006--- <b>DATA</b>

I used SAP_CONVERT_TO_CSV_FORMAT this FM still i am not getting CSV method. If i use this FM ourput is giving with separtor ; if change this seperator then also it is giving same.

Kindly help on this.

Sathvik

7 REPLIES 7

Former Member
0 Kudos

Hi,

use the FM SAP_CONVERT_TO_TEX_FORMAT to separate it with ',' comma.

Thanks,

Naren

Former Member
0 Kudos

Hi

Use the FM SAP_CONVERT_TO_TEX_FORMAT

and give parameter FIELD_SEPERATOR = ','

e.g

CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'

EXPORTING

i_field_seperator = ','

  • I_LINE_HEADER =

  • I_FILENAME = ld_filename

  • I_APPL_KEEP = ' '

TABLES

i_tab_sap_data = li_offcont_tab

CHANGING

i_tab_converted_data = li_offcont_tab1

EXCEPTIONS

conversion_failed = 1

OTHERS = 2

0 Kudos

now header data is not coming

Former Member
0 Kudos

Hi,

I am not clear with your question..Please explain..

Also are you passing I_LINE_HEADER as 'X' to the function module..

Thanks,

Naren

0 Kudos

ys i am passing

My code is like this

CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'

EXPORTING

i_field_seperator = ','

I_LINE_HEADER = 'X'

  • I_FILENAME =

  • I_APPL_KEEP = ' '

tables

i_tab_sap_data = itab_outfile

CHANGING

I_TAB_CONVERTED_DATA = itab_outfile2

  • 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 = p_file1

filetype = 'ASC'

write_field_separator = ','

write_lf = 'X'

dat_mode = 'X'

TABLES

data_tab = itab_outfile2

FIELDNAMES = itab_field1.

0 Kudos

Hey Naren,

Just by passing I_line_header = 'X' woudl the purpose be sufficed. As in my case looking after your suggestion i am using the SAP_CONVERT FM same as surendra and then i am using WS_DOWNLOAD wher i ma passing file name and the output table to be downloaded. But no header gets downloaded. Kindly let me know am i wrong or need to do soem thing else.

Former Member
0 Kudos

If we want in CSV first header data should append with headrer description. then you can append item level data.