Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

convert string from UTF8 to CP1256

Former Member
0 Likes
4,831

dear all

I want to convert String from UTF8 to CP1256 encoding technique before inserting them in the data base is there a function module or other thing to make this conversion.

1 ACCEPTED SOLUTION
Read only

marcin_cholewczuk
Active Contributor
0 Likes
2,430

Hi,

In FM GUI_UPLOAD SAP use class cl_abap_conv_out_ce (you can find it in include LSFESF03).

1. cl_abap_conv_out_ce=>create

2. cl_abap_conv_out_ce->write

3. cl_abap_conv_out_ce->get_buffer

I didn't try it, but maybe it will cover your case.

Best Regards

Marcin Cholewczuk

Hi,

In FM GUI_UPLOAD SAP use class cl_abap_conv_out_ce (you can find it in include LSFESF03).

1. cl_abap_conv_out_ce=>create

2. cl_abap_conv_out_ce->write

3. cl_abap_conv_out_ce->get_buffer

I didn't try it, but maybe it will cover your case.

Best Regards

Marcin Cholewczuk

9 REPLIES 9
Read only

marcin_cholewczuk
Active Contributor
0 Likes
2,431

Hi,

In FM GUI_UPLOAD SAP use class cl_abap_conv_out_ce (you can find it in include LSFESF03).

1. cl_abap_conv_out_ce=>create

2. cl_abap_conv_out_ce->write

3. cl_abap_conv_out_ce->get_buffer

I didn't try it, but maybe it will cover your case.

Best Regards

Marcin Cholewczuk

Read only

Former Member
0 Likes
2,430

could you please write sample code to me which i can create object and access the method

because i didn't work with object oriented .

i write :

data: conv type REF TO cl_abap_conv_in_ce.

CREATE OBJECT conv.

conv = cl_abap_conv_in_ce=>create(

encoding = 'UTF-8' ).

conv->convert(

EXPORTING input = lxs_content

IMPORTING data = l_contline ).

itreturn error

Read only

Former Member
0 Likes
2,430

i would like to convert for example

Arabic text "بسم الله " to the flowing text ---> ط¨ط³ظu2026 ط§ظu201Eظu201Eظu2021 i think this encoding is CP1256

please i want a sample code to do this .

thank you

Read only

Former Member
0 Likes
2,430

Hi,

Can it be used - TRANSLATE string FROM CODE PAGE cp1 TO CODE PAGE cp2 ?

Cheers,

Thomas

Read only

Former Member
0 Likes
2,430

Hi,

Please find the bellow link for your solution.

http://wiki.sdn.sap.com/wiki/display/ABAP/Characterencodingconversion

http://tcltk.co.kr/files/tdom3.pdf

And check the bellow code which give some idea about your requirement.

Convert XString to String

data: loc_conv type ref to CL_ABAP_CONV_IN_CE,

loc_xstring type xstring,

loc_string type string.

CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE

EXPORTING

INPUT = loc_xstring

ENCODING = 'UTF-8'

REPLACEMENT = '?'

IGNORE_CERR = ABAP_TRUE

RECEIVING

CONV = loc_CONV.

TRY.

CALL METHOD loc_CONV->READ

IMPORTING

DATA = loc_string.

CATCH CX_SY_CONVERSION_CODEPAGE.

*-- Should ignore errors in code conversions

CATCH CX_SY_CODEPAGE_CONVERTER_INIT.

*-- Should ignore errors in code conversions

CATCH CX_PARAMETER_INVALID_TYPE.

CATCH CX_PARAMETER_INVALID_RANGE.

ENDTRY.

Regards,

Goutam Kolluru.

Read only

former_member214857
Contributor
0 Likes
2,430

Hi

You can open a file using OPEN DATASET encoding with code page 1401

Best regards

Read only

Former Member
0 Likes
2,430

i use this function ( SCP_TRANSLATE_CHARS ) to make convertion from

Arabic text "بسم الله " to the flowing text ---> ط¨ط³ظu2026 ط§ظu201Eظu201Eظu2021

i use it as

CALL FUNCTION 'SCP_TRANSLATE_CHARS'

EXPORTING

INBUFF = 'بسم الله'

  • INBUFFLG = 0

INCODE = '4110'

  • OUTBUFFLG = 0

OUTCODE = '8704'

  • CSUBST = 'X'

  • SUBSTC_HASH = ' '

  • SUBSTC_DOT = ' '

  • SUBSTC_SPACE = ' '

  • SUBSTC = '00035'

IMPORTING

  • INUSED =

OUTBUFF = text

  • OUTOVERFLOW =

  • OUTUSED =

  • SUBSTED =

  • INPUT_ENDS_IN_CHAR =

  • ERRMSG =

  • EXCEPTIONS

  • INVALID_CODEPAGE = 1

  • INTERNAL_ERROR = 2

  • CANNOT_CONVERT = 3

  • FIELDS_BAD_TYPE = 4

  • OTHERS = 5

write : text.

but it doesn't return the output that i need as mentioned above can any one tell me how to get my need output .

Read only

0 Likes
2,430

Hi,

It won't work because when you pass value like this SAP treats it as Unicode (little endian). Prepare file in notepad and choose UTF-8 and use its inside as input for this function.

Best Regards

Marcin Cholewczuk

Read only

Former Member
0 Likes
2,430

thanks resolved