‎2007 Mar 23 4:00 PM
hi all:
i try to split the string 'asd #bve#fdsf # sfdsdf#' into an internal table,does it have any ways to respect the Blank Spaces in the internal table?
Ex:split str at '#' into table i_tab
result;i_tab[1] = 'asd '
i_tab[2] = 'bve'
i_tab[3] = 'dsf '
i_tab[4] = ' sfdsd'
it would be grateful for any king answer.
BTW:i can't use the method which to replace the spaces with a "filler" and then split them up.
‎2007 Mar 23 4:31 PM
hi all
i think i gave a bad sample to all of you,my questions was "how can i keep the blank space in the each table lines ".
‎2007 Mar 23 4:04 PM
play around with
split str at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into i_tab
‎2007 Mar 23 4:14 PM
hi Sam,
do this way
split str at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into i_tab.
result;i_tab[1] = 'asd '
i_tab[2] = 'bve'
i_tab[3] = 'dsf '
i_tab[4] = ' sfdsd'Regards,
Santosh
‎2007 Mar 23 4:24 PM
Hi,
i am giving the sample code here, like wise do it.
DATA: STRING(60),
P1(20) VALUE '++++++++++++++++++++',
P2(20) VALUE '++++++++++++++++++++',
P3(20) VALUE '++++++++++++++++++++',
P4(20) VALUE '++++++++++++++++++++',
DEL(3) VALUE '***'.
STRING = ' Part 1 *** Part 2 *** Part 3 *** Part 4 *** Part 5'.
WRITE STRING.
SPLIT STRING AT DEL INTO P1 P2 P3 P4.
WRITE / P1.
WRITE / P2.
WRITE / P3.
WRITE / P4.
The output appears as follows:
Part 1 *** Part 2 *** Part 3 *** Part 4 *** Part 5
Part 1
Part 2
Part 3
Part 4 *** Part 5
Regards,
Bhaskar
‎2007 Mar 23 4:31 PM
hi all
i think i gave a bad sample to all of you,my questions was "how can i keep the blank space in the each table lines ".
‎2007 Mar 23 5:31 PM
Just replace the blank space with an "exotic" character before split, and then replace ther other way in the table.
Define you "exotic" char via a constant of type X with a value in hexa or use a character never used.
REPLACE ALL OCCURRENCES OF ' ' IN i<your field> WITH char_x. Then split, ad loop at result tab and reverse the REPLACE.
Regards
‎2007 Mar 23 6:15 PM
Hi Raymond
because i do not know which "exotic" will not be used in the string,the any data would be used in the string which i want to split,so i can't use the ways you suggest althought it was a good way to work around it.any ideas?
Message was edited by:
sam feng
‎2007 Mar 24 8:18 AM
I fear that you have to manually split the string
REFRESH itab. CLEAR itab. CLEAR pos.
DO.
if string(1) eq '#'.
append itab to itab.
clear: itab, pos.
ELSE.
itab+pos(1) = string(1).
add 1 to pos.
ENDIF.
SHIFT string.
IF string is intial.
if pos > 0. " save last text
append itab to itab.
endif.
exit.
endif.
ENDDO. Regards
‎2007 Mar 24 1:35 PM
Hi Raymond:
thanks you so much,i have solved this issue according your suggest.points has been award to you.
‎2007 Mar 23 5:24 PM
Trailing spaces in a record will not be retained. Can you please let us know the reason why you need those trailing spaces?
‎2007 Mar 23 6:11 PM
Hi Adavi:
in actually,this string was imported by the other function,and i have no any idea to change the format of data,my function must keep anything from it and exported it as an internal table.do you have any ideas?
‎2007 Mar 24 4:34 AM
‎2007 Mar 24 4:39 AM
Hi,
This is the functionality and use of split statement in abap.
I know of an abap statement SPLIT but no SPLIT ROW.
SPLIT will split a string at a specified location.
split str at ',' into v_str v_str2.
do u want to split a row
DATA: str1 TYPE string,
str2 TYPE string,
str3 TYPE string,
itab TYPE TABLE OF string,
text TYPE string.
text = `What a drag it is getting old`.
SPLIT text AT space INTO: str1 str2 str3,
TABLE itab.
data: x(35) value 'Gangadharayya,Hiremath',
y(15),z(15).
split x at ',' into y z.
write: y,/ z.
output: Gangadharayya
Hiremath
Thanks,
Sankar M
‎2007 Mar 24 4:49 AM
Hi,Sankar
thanks for your answer,but it can't solve my issues.
‎2007 Mar 24 5:02 AM
hi,all
is there any ideas to solve it?points will reward to the helpful answer.
‎2007 Mar 24 1:36 PM