Skip to Content
0
Oct 24, 2014 at 10:44 AM

uft8 not working in open dataset

856 Views

hi all,

We use OPEN DATASET,,, to export data to excel in background job. Job working fine and exports excel to app server. But utf8 letters coming wrong. We've tried OPEN DATASET with different mode (in binary, text with encoding utf-8 ect), also RSCP_CONVERT_FILE tool (sap note 747615 - Tool for converting files from one code page to another) . No any success result. Additional information could be find below :

1) Data in sap table :

2) Abap code which exports data to excel :

code taken from http://scn.sap.com/docs/DOC-51968

DATA : c_lv_buf TYPE string,

c_lv_line TYPE string,

c_lv_filepath TYPE localfile,

c_lv_query TYPE aqs_quname.

*Field symbols

FIELD-SYMBOLS : <fs_record> TYPE ANY ,

<fs_comp> TYPE ANY.

*Get a Query name from the program

CALL FUNCTION 'RSAQ_DECODE_REPORT_NAME'

EXPORTING

reportname = program

IMPORTING

query = c_lv_query

EXCEPTIONS

no_query_report = 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.

*Select the filepath from ZBSD_T0246 table based

*on the query name and variant.

SELECT SINGLE filepath

FROM zbsd_t0246

INTO c_lv_filepath

WHERE query = c_lv_query

AND qvariant = 'SAVE_FILE'.

IF sy-subrc = 0.

*Open application server file.

OPEN DATASET c_lv_filepath FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc = 0.

CLEAR c_lv_line.

*Create header of the file

LOOP AT listdesc.

CONCATENATE c_lv_line listdesc-fcol '|' INTO c_lv_line.

ENDLOOP.

TRANSFER c_lv_line TO c_lv_filepath.

CLEAR c_lv_line.

*Transfer the data to the file

LOOP AT datatab ASSIGNING <fs_record>.

DO.

ASSIGN COMPONENT sy-index OF STRUCTURE <fs_record> TO <fs_comp>.

IF sy-subrc <> 0.

EXIT.

ENDIF.

c_lv_buf = <fs_comp>.

IF sy-index = 1.

c_lv_line = c_lv_buf.

ELSE.

CONCATENATE c_lv_line c_lv_buf INTO c_lv_line SEPARATED BY '|'.

ENDIF.

CLEAR c_lv_buf.

ENDDO.

TRANSFER c_lv_line TO c_lv_filepath.

CLEAR c_lv_line.

ENDLOOP.

*Close the file once the datas are transfered.

CLOSE DATASET c_lv_filepath.

IF sy-subrc = 0.

*File created in path &1

MESSAGE s483(zbsd_0001) WITH c_lv_filepath.

ENDIF.

ENDIF.

ELSE.

*File path not maintained in table ZBSD_T0246

MESSAGE e484(zbsd_0001).

ENDIF.

3) and excel file in application server :

Please help us to solve this problem.

Thanks in advance,

Shahin

Attachments

ScreenClip.png (52.1 kB)
ScreenClip.png (129.3 kB)