‎2008 Mar 05 6:43 AM
hi ,
i want to split text like below
Canada41890-01 into Canada 41890-01 how to do that ?
tanks
‎2008 Mar 05 6:59 AM
jim,
If text has constant value like first 6 chars next intergers then we can use directly
DATA : v_char(100) TYPE C VALUE
'Canada41890-01 into Canada 41890-01',
v_char1(10) ,
v_char2(20) .
v_char1 = v_char+0(6).
v_char2 = v_char+6(8).
CONCATENATE v_char1 v_char2 INTO v_char SEPERATED BY
space.
‎2008 Mar 05 6:46 AM
Hi,
SPLIT
Splits a string.
Syntax
SPLIT <c> AT <del> INTO <c1>... <cn> INTO TABLE <itab>
[IN BYTE MODE|IN CHARACTER MODE].
This statement searches the character field <c> for delimiter strings <del> and the parts before and after the delimiters are placed in the target fields <c1> ...> <cn>, or into a new line of the internal table <itab>. In Unicode programs, you must specify whether the statement is a character or byte operation, using the IN BYTE MODE or IN CHARACTER MODE (default) additions
Regards,
Priya.
‎2008 Mar 05 6:49 AM
‎2008 Mar 05 6:49 AM
1. SPLIT Canada41890-01 AT a INTO h1 ... hn.
here you can split the string Canada41890-01 in to 2 parts h1 and h2 at delimeter a.
2. SPLIT f AT g INTO TABLE itab.
you can even add it as directly into internal table.
syntax:
SPLIT c AT <del> INTO c1 ... cn.
or
SPLIT c AT <del> INTO table <internal table>.
where, del = delimeter
data: begin of wa,
text type string,
end of wa.
data: itab like table of wa.
data: st type string value 'I am new to ABAP'.
data: st1 type string,
st2 type string,
st3 type string,
st4 type string,
st5 type string.
split st at space into st1 st2 st3 st4 st5.
split st at space into table itab.
Regards,
Chandru
Edited by: Chandra Prakash on Mar 5, 2008 12:30 PM
‎2008 Mar 05 6:54 AM
use the function module 'G_SPLIT_LINE'
Example code
CLEAR str_len .
str_len = strlen( w_string ) .
IF str_len GT split_len .
CALL FUNCTION 'G_SPLIT_LINE'
EXPORTING
input_line = w_string
TABLES
export_lines = split_tab.
Updating the internal table of structure TLINE
LOOP AT split_tab .
MOVE split_tab-txt_line TO txt_tab-tdline .
APPEND txt_tab .
ENDLOOP .
ELSE.
.........
ENDIF.
do reward if useful
‎2008 Mar 05 6:59 AM
jim,
If text has constant value like first 6 chars next intergers then we can use directly
DATA : v_char(100) TYPE C VALUE
'Canada41890-01 into Canada 41890-01',
v_char1(10) ,
v_char2(20) .
v_char1 = v_char+0(6).
v_char2 = v_char+6(8).
CONCATENATE v_char1 v_char2 INTO v_char SEPERATED BY
space.
‎2008 Mar 05 7:02 AM
v_str = 'Canada41890-01'.
v_str1 = v_str+0(6).
v_str2 = v_str+6(8).
‎2008 Mar 05 7:13 AM
Hi JIM,
Try the following code.
DATA:
v_char(32) TYPE c,
v_char1(16) TYPE c,
v_char2(16) TYPE c.
v_char = 'Canada41890-01'.
v_char1 = v_char+0(6).
v_char2 = v_char+6(8).
CLEAR v_char.
CONCATENATE v_char1 v_char2 INTO v_char
SEPARATED BY space.
Reward if helpful.