‎2005 Nov 10 5:40 AM
Hi,
I want to split a large string into smaller equal-length strings and store these in an internal table.
Is there a keyword available for this? I know about SPLIT, however, this uses a character delimiter. I need to delimit the selection using an integer value.
Please do let me know.
Thanks,
Biju
‎2005 Nov 10 5:49 AM
hi,
try with this
data : l_char(200) type c,
l_char1(20) type c,
l_char2(20) type c,
l_char3(20) type c,
l_char1 = l_char+0(20)
l_char2 = l_char+20(20)
l_char3 = l_char+40(20)
or data l_val type i value 10.
l_char1 = l_char+l_val(20).
like that
cheers,
sasi
Message was edited by: sasikumar palanichamy
‎2005 Nov 10 5:45 AM
Biju,
How about SEARCH? You will have to use it within a LOOP construct. Can you provide more info on the integer value as the delimiter?
Thanks,
Chaps.
‎2005 Nov 10 5:48 AM
DATA: string10(60) TYPE c ,
p1(20) TYPE c VALUE '++++++++++++++++++++',
p2(20) TYPE c VALUE '++++++++++++++++++++',
p3(20) TYPE c VALUE '++++++++++++++++++++',
p4(20) TYPE c VALUE '++++++++++++++++++++',
del10(3) TYPE c VALUE '***'.
string10 = ' Part 1 *** Part 2 *** Part 3 *** Part 4 *** Part 5'.
WRITE string10.
<b>SPLIT string10 AT del10 INTO p1 p2 p3 p4.</b>
WRITE / p1.
WRITE / p2.
WRITE / p3.
WRITE / p4.
SKIP.
ULINE.Try this one.
‎2005 Nov 10 5:49 AM
hi,
try with this
data : l_char(200) type c,
l_char1(20) type c,
l_char2(20) type c,
l_char3(20) type c,
l_char1 = l_char+0(20)
l_char2 = l_char+20(20)
l_char3 = l_char+40(20)
or data l_val type i value 10.
l_char1 = l_char+l_val(20).
like that
cheers,
sasi
Message was edited by: sasikumar palanichamy
‎2005 Nov 10 6:06 AM
Hi Sasi,
Thanks, this works. But I was also hoping for some keyword that could do the same.
All the same ... thank you for the hint.
Regards,
Biju
‎2005 Nov 10 6:11 AM
Hi,
Store the delimiter in a char variable and then you can use SPLIT.
Regards.
Lavanya.
‎2005 Nov 10 6:45 AM
Hi. Biju.
Another keyword is nothing, But another way...
data : begin of it_input occurs 0,
text(200) type c,
end of it_input.
data : begon of it_split occurs 0,
c1(20) type c,
c2(20) type c,
c3(20) type c,
end of it_split.
data : l_index like sy-tabix,
l_offset type i,
l_length type i.
data : w_c1(20) type c.
field-symbols <fs> type any.
clear : l_index, l_offset, l_length.
l_length = 20.
Loop at it_input.
clear : l_offset, it_split.
Do 3 times.
w_c1 = it_input-text+l_offset(l_length).
IF NOT w_c1 is initial.
add 1 to l_index.
ASSIGN COMPONENT l_index OF STRUCTURE it_split TO <fs>.
MOVE w_c1 TO <fs>.
ENDIF.
l_offset = l_offset + l_length.
enddo.
APPEND it_split.
Endloop.
I hope you help.
Regards. MSLee