‎2009 Dec 31 1:13 AM
Hello Experts,
I want to create a datafile in UTF-16 format.
OPEN DATASET does not support a UTF-16 format.
How can i create a file in such a format.
Thanks in advance.....
fract
‎2009 Dec 31 4:09 AM
OPEN DATASET will support but a UTF-16 file can only be opened as a binary file.
Check this
http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_MODE.htm#!ABAP_ALTERNATIVE_3@3@
a®
‎2009 Dec 31 1:47 AM
you can convert the data with these objects
CL_ABAP_CONV_OUT_CE Code Page and Endian Conversion (System Format -> External
TRY.
CALL METHOD cl_abap_conv_out_ce=>create
EXPORTING
encoding = 'UTF-16'
RECEIVING
conv = yourstring_sap.
* get result
CALL METHOD l_convout->get_buffer
RECEIVING
buffer = yourbinarystring_utf16
CATCH cx_root.
* Your error handling
* Check if you have an error and UTF-16 realy works
ENDTRY.
and then write the data binary in a file the same way only as binary
Rene
Code Formatted by: Alvaro Tejada Galindo on Jan 4, 2010 5:38 PM
‎2009 Dec 31 4:09 AM
OPEN DATASET will support but a UTF-16 file can only be opened as a binary file.
Check this
http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_MODE.htm#!ABAP_ALTERNATIVE_3@3@
a®
‎2009 Dec 31 5:53 AM
I am extracting data from Japanese system and i want to write that data into a file in UTF-16 LITTLE ENDIAN format .
Do i need to use Code Page with LITTLE ENDIAN or LITTLE ENDIAN is enough or both?
OPEN DATASET V_FILE FOR OUTPUT IN LEGACY BINARY MODE LITTLE ENDIAN CODE PAGE '4103'.
Thanks,
fract
‎2009 Dec 31 6:02 AM
Only CODEPAGE is necessary
OPEN DATASET V_FILE FOR OUTPUT IN LEGACY BINARY MODE CODE PAGE '4103'.
a®
‎2009 Dec 31 6:54 AM
I am getting this short dump. Where is the problem?
Runtime Errors CONVT_CODEPAGE_INIT
Except. CX_SY_CODEPAGE_CONVERTER_INIT
Short text
The conversion of certain code pages is not supported.
What happened?
The conversion of texts in code page '4103' to code page '4103' is not
supported here.
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_CODEPAGE_CONVERTER_INIT', was
not caught in procedure "DOWNLOAD_DATA" "(FORM)", nor was it propagated by a
RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
Possibly, one of the codepages '4103' or '4103' - needed for the
conversion - is unknown to the system. Another option is, that a Unicode
codepage was specified for a file in LEGACY MODE, which is not allowed.
Additional parameters for the codepage conversion (as , for example, the
replacement character) might have invalid values. You can find further
information under 'Inernal notes'.
If the problem occurred at opening, reading, or writing of a file, then
the file name was '
SAPT01\DATA\DEV\t001-20091231.dat'. (Further
information about this file: " 쬞")
>>>>> OPEN DATASET V_FILE FOR OUTPUT IN LEGACY BINARY MODE CODE PAGE '4103'.
IF SY-SUBRC NE 0.
CONCATENATE 'File open error' V_FILE INTO WA_ERR_LOG.
ENDIF.
CLEAR WA_DATA.
LOOP AT ITAB INTO WA_DATA.
TRANSFER WA_DATA TO V_FILE.
ENDLOOP.
CLOSE DATASET V_FILE.
‎2009 Dec 31 7:27 AM
Hi,
Try with the addition IGNORING CONVERSION ERRORS with the OPEN DATASET statement
OPEN DATASET V_FILE FOR OUTPUT IN LEGACY BINARY MODE CODE PAGE '4103' IGNORING CONVERSION ERRORS.
IF SY-SUBRC NE 0.
CONCATENATE 'File open error' V_FILE INTO WA_ERR_LOG.
ENDIF.
CLEAR WA_DATA.
LOOP AT ITAB INTO WA_DATA.
TRANSFER WA_DATA TO V_FILE.
ENDLOOP.
CLOSE DATASET V_FILE.
Vikranth
‎2009 Dec 31 7:34 AM
Hi,
I tried with the following statement but same short dump.
OPEN DATASET V_FILE FOR OUTPUT IN LEGACY BINARY MODE CODE PAGE '4103' IGNORING CONVERSION ERRORS.
‎2009 Dec 31 6:00 PM
Hi
Your shortdump looks to me as your system uses 4103 code page and therefor a conversion is not needed.
If you write directly in text mode this should be fine. If this is not what you want; try:
open DATASET vfile for OUTPUT in LEGACY TEXT MODE BIG ENDIAN CODE PAGE '4103'.
Happy new year.
‎2010 Jan 05 7:53 PM
I tried but still short dump. Is there any other solutions....
‎2010 Jan 06 12:02 AM
So if the short dump is the same, this emans you are in a 4103 encoded system?
What is your default codepage?
‎2010 Jan 06 12:04 AM
You can also check if 4103 is even an option in your system.
Use transaction SCP to see what is there.
Rene