Application Development 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: 

How To SPLIT a strin at special char in NON BYTE MODE

Former Member
0 Kudos

Hi there !

Im quite new to ABAP and I'm having a following problem.

I need to parse a Input from a HTML Textarea component which is a ABAP String but can apparantly contain the 0x10, 0x13 line feed special characters. Now, is it possible that I can escape a line feed similar to "\n" in Java/c and use it in a followin way: SPLIT input AT '\n' INTO TABLE tbl. Till now I haven't really found any infos how to handle special chars in ABAP.

thanks a lot

Astrit

3 REPLIES 3

Former Member
0 Kudos

Off the top of my head, try:


DATA:
  BEGIN OF newline,
    hex(2)             TYPE x VALUE '0D0A',
  END OF newline.

* Split content by carriage return (0D) / line-feed (0A)
SPLIT input AT newline INTO TABLE tab.

This is not unicode compatible.

Scott

0 Kudos

You will have to make some more changes as you cannot split on Hexadecimal string so for the same.

Please use this code

DATA: str TYPE string,

t1 TYPE string OCCURS 0 WITH HEADER LINE.

DATA hex(2) TYPE x VALUE '0D0A'.

FIELD-SYMBOLS: <fs> TYPE x,

<fs1> TYPE c.

ASSIGN hex TO <fs>.

ASSIGN <fs> TO <fs1> CASTING.

SPLIT str AT <fs1> INTO TABLE t1.

Here I am presuming that the variable str has the string to be parsed.

Then the split string comes up into table t1.

Hope this code is helpful.

Regards,

Pavan

0 Kudos

I had to change the t1 declaration in "TABLE OF STRING" because of the OO-Context and then it worked perfectly.

Thank's a lot for your support !

Astrit