2009 Aug 14 9:50 AM
Hi Every one,
I have at present ALV report.In ALV we donot have CSV format option, so my requirement is i need to get the out put file in CSV format.So can any help me on this requirement.
answered
2009 Aug 14 9:53 AM
Hi Krishna ,
When you are downloading to CSV you can use the FM SAP_CONVERT_TO_CSV_FORMAT or SAP_CONVERT_TO_TXT_FORMAT.
Add a new button in the ALV Mneu which will download the data to CSV format.
Regards,
Arun
2009 Aug 14 1:36 PM
2009 Aug 14 10:09 AM
Hi,
To download file in CSV format, first convert internal table data into csv format using function module "SAP_CONVERT_TO_TEX_FORMAT" and then use function module "GUI_DOWNLOAD" as shown below
CALL FUNCTION 'SAP_CONVERT_TO_TEX_FORMAT'
EXPORTING
i_field_seperator = ','
TABLES
i_tab_sap_data = t_output
CHANGING
i_tab_converted_data = t_output_csv
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.
DATA: lv_file TYPE string, lv_sep TYPE c.
lv_file = 'c:\data.csv.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_file
filetype = 'ASC'
write_field_separator = lv_sep
TABLES
data_tab = t_output_csv
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4.
Regards,
Moqeeth.
2009 Aug 14 12:31 PM
What should be the types of internal tables t_output and t_output_csv.
2009 Aug 14 12:41 PM
hi,
t_output <<< Your data any format
t_output_csv declare type truxs_t_text_data
or
you can also try like below:
declare a table like below:
data: begin of t_con occurs 0,
line(255),
end of t_con.
then concatenate all the field values into this line with separator as comma like below:
data: lv_sep value ','.
loop at it_data <-----your data internal table.
concatenate it_data-field1 it_data-field2...into t_con-line
separated by lv_sep.
append t_con.
then call the GUI_DOWNLOAD and download the file.
I hope it helps
regards,
Himanshu
2009 Aug 14 11:54 PM
"how to add a button in alv" : please don't abuse, search forum !
"alv does not save as CSV format" : within ALV, when you export data as excel format, it saves a file which is like CSV, but with tabs instead of commas. Provided that the user saves it with the .csv option (like with commas by the way), when the user opens this file later, Excel opens it as if it had commas.
2009 Aug 20 8:37 AM
2009 Aug 20 9:28 AM
Hi. Could you just give us a feedback, what were the answers to your questions ?
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |