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 '##' into table ........ not working

Former Member
0 Likes
2,837

hi experts,

i have a problem with a split, im trying to split a string into a substring with this '##' as break.

i have this data for example:

msg = 'abcdefg hijk##lmn opq'

and i do this

split msg at '##' into table msg_table.

and in msg_table i have one row with 'abcdefg hijk##lmn opq' when i should have 2 rows.

but if i use

split msg at space into table msg_table.

i have 3 rows as a result.

i tried using a single '#' but it doesnt work neither. Is there a problem using #s as breaks???????

thx in advance.

1 ACCEPTED SOLUTION
Read only

former_member188827
Active Contributor
1,834

try:

data message TYPE string VALUE 'abcdefg hijk##lmn opq'.

data msg_table TYPE TABLE OF string.

SPLIT message AT '##' INTO TABLE msg_table.

it works!

6 REPLIES 6
Read only

Former Member
0 Likes
1,834

Hi,

It should work try like this

TYPES : BEGIN OF ty_test,

text(20),

END OF ty_test.

DATA : t_test TYPE TABLE OF ty_test WITH HEADER LINE,

str(1000).

str = 'abcdefg hijk##lmn opq' .

SPLIT str AT '##' INTO TABLE t_test.

LOOP AT t_test.

WRITE : /10 t_test-text.

ENDLOOP.

I got output

abcdefg hijk

lmn opq

Regards

Krishna

Read only

Former Member
0 Likes
1,834

HI,

Try this way...

DATA : tab TYPE C value CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

split msg at tab into table msg_table.

Read only

former_member188827
Active Contributor
1,835

try:

data message TYPE string VALUE 'abcdefg hijk##lmn opq'.

data msg_table TYPE TABLE OF string.

SPLIT message AT '##' INTO TABLE msg_table.

it works!

Read only

0 Likes
1,834

i think wat the problem is....

im getting the string from a function SO_OBJECT_READ that returns a table OBJCONT that is type table of SOLI...

the thing is that this function returns lines of strings but in each string could be '##' that represent line jump... but it looks like it isnt the actuals. ## ...

heres the code...

data: msg_tabla TYPE TABLE OF string.

data: msg_tabla_aux TYPE TABLE OF string.

data: msg_aux type string.

.

.

.

LOOP

CALL FUNCTION 'SO_OBJECT_READ'

EXPORTING

  • FILTER =

folder_id = fold_id

  • FORWARDER =

object_id = obj_id

TABLES

OBJCONT = it_OBJCONT

.

.

.

clear msg_aux.

clear msg_tabla_aux.

clear str.

                                            • in case it has more than 1 line i concatenate

loop at it_OBJCONT into gwa_IT_OBJCONT .

WRITE: 'mensaje: ', gwa_IT_OBJCONT-LINE.

CONCATENATE msg_aux gwa_IT_OBJCONT-LINE into msg_aux.

ENDLOOP.

SPLIT msg_aux_aux AT '##' INTO TABLE msg_tabla_aux.

append msg_tabla_aux to msg_tabla.

ENDLOOP

        • in the table msg_tabla should appear all the messages

-


if anyone can help me out .. ill really apreciate it.

thx in advance.

Read only

1,834

it migth be CR/LF.

try

SPLIT msg_aux_aux AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE msg_tabla_aux

Read only

0 Likes
1,834

thank you so much MxG

that solves the problem