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

Split at # does not work

IanStubbings
Active Participant
0 Likes
6,066

Hi

I am trying to split a string that has the # character within it. I have tried using the # as a string and as the hex value 23, which is what is displayed when I display the string as it's hex value. I have successfully split using other hex values within the string but this one will not work.

My issue is that this is the output from the ostream when I set the pretty print to on - which I require to format the XML document correctly for the spool. It would be perfect if it would just split where it's told to!!

Below is a snippet of the string and the hex values.

<pack_type>EMAIL</pack_type># <customer/># <print_destn>email</print_destn>

3C7061636B5F747970653E454D41494C3C2F7061636B5F747970653E23203C637573746F6D65722F3E23203C7072696E745F646573746E3E656D61696C3C2F707269

If anyone has any experience of the ABAP XML classes, It would be great to hear from you!!

Cheers

Ian

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,216

Hi,

Try using the class

CL_ABAP_CHAR_UTILITIES.

Regards,

Shashank

8 REPLIES 8
Read only

Former Member
0 Likes
3,217

Hi,

Try using the class

CL_ABAP_CHAR_UTILITIES.

Regards,

Shashank

Read only

Former Member
0 Likes
3,216

Hi Ian,

The problem with Strings is that it intenally treats SPACE with # & hence we cannot split at this character. You can use Overlay to transform # to some other character say '.' & then try splitting it at '.'...c if it works.....well dnt have much to say about ABAP XML....

Read only

naimesh_patel
Active Contributor
0 Likes
3,216

Hello,

Do like:

split data at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into itab.

regards,

Naimesh

Read only

Former Member
0 Likes
3,216

hi,

Do this

SPLIT data_string
   AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
   INTO TABLE itab. 


itab is table with the structure

begin ty_itab
   field type char100
end ty_itab.

Read only

0 Likes
3,216

Ah, sorry guys, I forgot to mention that I'm on a 4.6C system and do not have the luxury of CL_ABAP_CHAR_UTILITIES.

None of the search, overlay or translate keywords can see the character either.

I have tried writing the string to a char8000 field but no joy either.

Read only

0 Likes
3,216

Hello,

Do like this,

CONSTANTS: con_tab TYPE x VALUE '09'.

Split data at con_tab into itab.

Regards,

Naimesh

Read only

0 Likes
3,216

Ok. Sorted. I output the XML to my pc using the following:

  • Saving the XML document

l_xml_size = l_ostream->get_num_written_raw( ).

CALL METHOD cl_gui_frontend_services=>gui_download

EXPORTING

bin_filesize = l_xml_size

filename = 'H:\test.xml'

filetype = 'BIN'

CHANGING

data_tab = l_xml_table

EXCEPTIONS

OTHERS = 24.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

and then opend the test.xml file with a hex editor. The character # that the ABAP editor had shown as 23 in the hex display was in fact 0A - a linefeed. Documentation on the method set_pretty_print of the ostream interface says the pretty print using a space or tab. Thanks for that SAP - very misleading and wasted a lot of time!!

Still sorted now.

Thanks to all for their help.

Ian

Read only

manoharmclaren1
Explorer
0 Likes
3,216

This message was moderated.