In my BSP application, I am downloading the contents of internal table to a CSV file format. For this, i initially convert the data line to XSTRING using 'SCMS_STRING_TO_XSTRING' function module with the mimetype being 'APPLICATION/MSEXCEL; charset=utf-16le'. As can be seen in the below code, i then use the standard code to write the contents as an attachment. Please note that at this point, the file is stored as a CSV file, but the file type seems to be unicode text. I make some changes to the file and save it. And, i try to load the same file, i am getting a file open error. However, when i open the file in Excel and save as type 'CSV', i am able to successfully load it. How do i change so that the BSP save as File type "Comma Separated". Any help is greatly appreciated. Thanks,Raj
Below is the code:
Download File -
app_type = 'APPLICATION/MSEXCEL; charset=utf-16le'.
call function 'SCMS_STRING_TO_XSTRING'
text = lv_line_item
mimetype = app_type
buffer = l_xstring
failed = 1
others = 2.
mresponse->delete_header_field( name =
mresponse->delete_header_field( name = if_http_header_fields=>expires
mresponse->delete_header_field( name = if_http_header_fields=>pragma
start Excel viewer either in the Browser or as a separate window
mresponse->set_header_field( name = 'content-disposition'
value = 'attachment; filename = test.csv' ).
data l_len type i.
l_len = xstrlen( lt_xstring ).
mresponse->set_data( data = lt_xstring
length = l_len ).
Upload File -
lcl_data ?= cl_htmlb_manager=>get_data(
request = runtime->server->request
name = 'fileUpload'
id = 'SalesFile').
cl_abap_conv_in_ce=>create( input = lcl_data->file_content ).
lv_str->read( importing data = v_filedata ).