Добрый день, уважаемые коллеги!
Данная тема есть продолжение темы 'Выгрузить файл с кодировкой UTF-8'. Итак, необходимо было выгрузить файл в кодировке UTF-8. Для этого мне было предложено конвертировать в UTF-8, а потом выгружать как бинарник. В UTF конвертировать классом cl_abap_conv_in_ce. Для этого был написан код, который, к сожалению, падает в дамп(но дамп происходит в определённой системе! В других системах код работает корректно! Само описание дампа после кода):
TYPE-POOLS: abap. TYPES: BEGIN OF ty_string, data TYPE string, END OF ty_string. DATA : it_string TYPE STANDARD TABLE OF ty_string, wa_string TYPE ty_string. DATA: v_string TYPE string, v_xsrting TYPE xstring, v_len TYPE i, rc TYPE i VALUE 0, v_encoding TYPE abap_encoding. * Get the LOGON Encoding for the particular user CALL METHOD cl_gui_frontend_services=>get_saplogon_encoding CHANGING rc = rc file_encoding = v_encoding EXCEPTIONS cntl_error = 1 error_no_gui = 2 not_supported_by_gui = 3 cannot_initialize_globalstate = 4 OTHERS = 5. IF sy-subrc <> 0 OR v_encoding = 0. CLEAR v_encoding. ENDIF. CHECK v_encoding IS NOT INITIAL. * Attribute for UTF-8 format v_xsrting = cl_abap_char_utilities=>byte_order_mark_utf8.
DATA: v_conv TYPE REF TO cl_abap_conv_in_ce. * Create a Conversion Instance v_conv = cl_abap_conv_in_ce=>create( encoding = v_encoding input = v_xsrting ).
v_conv->read( IMPORTING data = v_string ). <------------ непосредственно тут происходит дамп
LOOP AT lt_data INTO ls_data. IF sy-tabix = 1. * To download a file in UTF-8 add the contents of BOM * UTF8 infront of the first record. CONCATENATE v_string ls_data INTO wa_string-data. APPEND wa_string TO it_string. ELSE. MOVE ls_data TO wa_string-data. APPEND wa_string TO it_string. ENDIF. ENDLOOP.
* Download the file CALL METHOD cl_gui_frontend_services=>gui_download EXPORTING filename = 'C:\Documents and Settings\...' codepage = v_encoding CHANGING data_tab = it_string EXCEPTIONS file_write_error = 1 no_batch = 2 gui_refuse_filetransfer = 3 ....... OTHERS = 24.
ОПИСАНИЕ ДАМПА: Short text A character set conversion is not possible.
What happened? At the conversion of a text from codepage '1504' to codepage '1500':
- a character was found that cannot be displayed in one of the two codepages; - or it was detected that this conversion is not supported
The running ABAP program 'CL_ABAP_CONV_IN_CE============CP' had to be terminated as the conversion would have produced incorrect data.
The number of characters that could not be displayed (and therefore not be converted), is 1. If this number is 0, the second error case, as mentioned above, has occurred.
Error analysis An exception occurred that is explained in detail below. The exception, which is assigned to class 'CX_SY_CONVERSION_CODEPAGE', was not caught in procedure "STORE" "(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: Characters are always displayed in only a certain codepage. Many codepages only define a limited set of characters. If a text from a codepage should be converted into another codepage, and if this text contains characters that are not defined in one of the two codepages, a conversion error occurs.
Moreover, a conversion error can occur if one of the needed codepages '1504' or '1500' is not known to the system.
If the conversion error occurred at read or write of screen, the file name was ' '. (further information about the file: " ")
P.s. кодировка 1504 в таблице TCP00A есть, если указать кодировку 1500, то дампа нет. В чём возможная проблема? Мне кажется, что это проблема настройки, но как её описать, чтобы базис её исправил?
|
|