2012 May 18 12:29 PM
Hi all,
CSV download report in which an output file produced in Shared server directory using OPEN DATASET OUTPUT in CSV file format and this file was readable but the File save as type in "Unicode *.txt" instead of *.CSV. File content contains Chinese character I have tried below two methods please advice me to correct it.
p_path = *.CSV
1. OPEN DATASET p_path FOR OUTPUT IN BINARY MODE.
IF sy-subrc EQ 0.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = w_string
MIMETYPE = 'APPLICATION/MSEXCEL; charset=utf-16le'
ENCODING = '8400'"'4103'
IMPORTING
BUFFER = w_xstring
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
IF sy-subrc <> 0.
ENDIF.
concatenate cl_abap_char_utilities=>byte_order_mark_little
w_xstring
into w_xstring in byte mode.
TRANSFER w_xstring TO p_path.
CLOSE DATASET p_path.
endif
2. OPEN DATASET p_path FOR OUTPUT IN BINARY MODE.
IF sy-subrc EQ 0.
TRY.
cl_bcs_convert=>string_to_solix(
EXPORTING
iv_string = w_string
iv_codepage = '4103'
iv_add_bom = 'X'
IMPORTING
et_solix = i_binary
ev_size = size ).
CATCH cx_bcs.
MESSAGE e445(so).
ENDTRY.
TRANSFER i_binary TO p_path.
CLOSE DATASET p_path.
endif.
Thanks,
Thiru.
Hi all,
CSV download report in which an output file produced in Shared server directory using OPEN DATASET OUTPUT in CSV file format and this file was readable but the File save as type in "Unicode *.txt" instead of *.CSV. File content contains Chinese character I have tried below two methods please advice me to correct it.
p_path = *.CSV
1. OPEN DATASET p_path FOR OUTPUT IN BINARY MODE.
IF sy-subrc EQ 0.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = w_string
MIMETYPE = 'APPLICATION/MSEXCEL; charset=utf-16le'
ENCODING = '8400'"'4103'
IMPORTING
BUFFER = w_xstring
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
IF sy-subrc <> 0.
ENDIF.
concatenate cl_abap_char_utilities=>byte_order_mark_little
w_xstring
into w_xstring in byte mode.
TRANSFER w_xstring TO p_path.
CLOSE DATASET p_path.
endif
2. OPEN DATASET p_path FOR OUTPUT IN BINARY MODE.
IF sy-subrc EQ 0.
TRY.
cl_bcs_convert=>string_to_solix(
EXPORTING
iv_string = w_string
iv_codepage = '4103'
iv_add_bom = 'X'
IMPORTING
et_solix = i_binary
ev_size = size ).
CATCH cx_bcs.
MESSAGE e445(so).
ENDTRY.
TRANSFER i_binary TO p_path.
CLOSE DATASET p_path.
endif.
Thanks,
Thiru.
2012 May 18 2:56 PM
2012 May 19 5:14 AM
Hi Shambu,
Thanks for you help. I have checked the above mentioned like already in this link they given only for GUI download but in my case it's application server path download ( windows server path) meaning report batch job not foreground even I tried the given below FM to covert text to CSV format but it vain.
SAP_CONVERT_TO_TEX_FORMAT
Thanks,
Thiru
2012 May 19 9:30 AM
Hi,
Try using SAP_CONVERT_TO_CSV_FORMAT for converting to CSV format and for downloading to application server use OPEN DATASET.
Thanks,
Shambu
2012 May 21 5:27 AM
Hi,
SAP_CONVERT_TO_CSV_FORMAT not supporting double byte (chinese text).
Thanks and Regards,
Thiru.
2012 May 21 7:44 AM
2012 May 21 5:27 PM
Hi Thirumurugan Durai,
a .CSV file will be pure character file, columns separated by tab or ";" or ',' separator.
Thus you should not use any X type data. Lines should be separated by cl_abap_char_utilities=>NEWLINE for the server, CR_LF for the client.
Then just
OPEN DATASET p_path FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .
and transfer your STRING to dataset.
No conversion, no function call.
I suppose you are on Unicode.
-> simplicity rules
If trouble not resolved: How do you create w_string?
Regards
Clemens
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |