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

abap to xml help

Former Member
0 Likes
629

hallow

i face an issue of sending some XML documents from SAP to a non SAP System. This non SAP System stores XML documents in UTF-8 encoding format. When I create an XML document using CALL TRANSFORMATION in ABAP, the XML code generated has encoding as "ISO-.8..". Could anyone of you please guide me on how to have this changed to UTF-8?

my vendor can use just utf-8

In case of no solution, I would eventually have to pick the XML generated code and replace the "ISO-..." thing with "UTF-8" at runtime within the program. However, I feel that's not a quality method.

So, if anyone of you can suggest/opine of something better, it would be truly appreciated and rewarded.

--

Have a Nice Day!

<b>this is my program i try this soltion but it not working</b>

TYPES: BEGIN OF ttab,

record(65535) TYPE c,

END OF ttab.

DATA: xml_table TYPE TABLE OF ttab,

wa_xml_table LIKE LINE OF xml_table.

DATA: gd_result TYPE string,

go_ixml TYPE REF TO if_ixml,

go_stream_factory TYPE REF TO if_ixml_stream_factory,

go_encoding TYPE REF TO if_ixml_encoding,

go_resstream TYPE REF TO if_ixml_ostream.

DATA:gt_knb1 TYPE STANDARD TABLE OF knb1,

gt_xml TYPE TABLE OF string.

CONSTANTS: gc_encoding TYPE string VALUE 'UTF-8'.

go_ixml = cl_ixml=>create( ).

go_stream_factory = go_ixml->create_stream_factory( ).

go_encoding = go_ixml->create_encoding( character_set = gc_encoding

byte_order = 0 ).

go_resstream = go_stream_factory->create_ostream_cstring( gd_result ).

CALL METHOD go_resstream->set_encoding

EXPORTING

encoding = go_encoding.

CALL TRANSFORMATION ('ID')

SOURCE i_data = person_tab

RESULT XML xml_table.

APPEND gd_result TO gt_xml.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = final_adress

filetype = 'BIN'

codepage = 'UTF-8'

TABLES

data_tab = xml_table

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

hallow

i face an issue of sending some XML documents from SAP to a non SAP System. This non SAP System stores XML documents in UTF-8 encoding format. When I create an XML document using CALL TRANSFORMATION in ABAP, the XML code generated has encoding as "ISO-.8..". Could anyone of you please guide me on how to have this changed to UTF-8?

my vendor can use just utf-8

In case of no solution, I would eventually have to pick the XML generated code and replace the "ISO-..." thing with "UTF-8" at runtime within the program. However, I feel that's not a quality method.

So, if anyone of you can suggest/opine of something better, it would be truly appreciated and rewarded.

--

Have a Nice Day!

<b>this is my program i try this soltion but it not working</b>

TYPES: BEGIN OF ttab,

record(65535) TYPE c,

END OF ttab.

DATA: xml_table TYPE TABLE OF ttab,

wa_xml_table LIKE LINE OF xml_table.

DATA: gd_result TYPE string,

go_ixml TYPE REF TO if_ixml,

go_stream_factory TYPE REF TO if_ixml_stream_factory,

go_encoding TYPE REF TO if_ixml_encoding,

go_resstream TYPE REF TO if_ixml_ostream.

DATA:gt_knb1 TYPE STANDARD TABLE OF knb1,

gt_xml TYPE TABLE OF string.

CONSTANTS: gc_encoding TYPE string VALUE 'UTF-8'.

go_ixml = cl_ixml=>create( ).

go_stream_factory = go_ixml->create_stream_factory( ).

go_encoding = go_ixml->create_encoding( character_set = gc_encoding

byte_order = 0 ).

go_resstream = go_stream_factory->create_ostream_cstring( gd_result ).

CALL METHOD go_resstream->set_encoding

EXPORTING

encoding = go_encoding.

CALL TRANSFORMATION ('ID')

SOURCE i_data = person_tab

RESULT XML xml_table.

APPEND gd_result TO gt_xml.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = final_adress

filetype = 'BIN'

codepage = 'UTF-8'

TABLES

data_tab = xml_table

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

3 REPLIES 3
Read only

Former Member
0 Likes
601

Hi,

If you are working on 6.40 already perhaps the following classes may be helpful for converting between different encodings:

- CL_ABAP_CONV_IN_CE (Code Page and Endian Conversion (System Format -> External))

- CL_ABAP_CONV_OUT_CE (Code Page and Endian Conversion (System Format -> External))

- CL_ABAP_CONV_X2X_CE (Code Page and Endian Conversion Between External Formats)

Regards,

Ferry Lianto

Read only

0 Likes
601

hi ferry

i use ecc6

im new in abap and i wont to now how i can use the classes in my program

please u can give example?

if i use this classes is with my program or i have to change it?

best regards

antonio

Read only

Former Member
0 Likes
601

Hi,

Please check this thread for sample code.

Regards,

Ferry Lianto