2009 Jan 16 6:54 AM
Hi All,
i need to split a string, then need to concatenate the strings in to another string.
how can i do it.
For example: ABCDEFGHIKWXYZPQRS. in this i need to split ABCDEFGHIK, WXYZ and
PQRS. then i need to merge PQRS-ABCDEFGHIK. how can i do it???
please help me
2009 Jan 16 7:00 AM
Hi,
try this,
ata var(28) type c.
data: var1(28) type c,
var2(28) type c,
var3(28) type c.
var = 'ABCDEFGHIKWXYZPQRS'.
split var at 'W' into var1 var2.
concatenate 'W' var2 into var2.
split var2 at 'P' into var2 var3.
concatenate 'P' var3 into var3.
write:/ var2, var3.
concatenate var3 '-' var1 into var.
write:/ var.
Regards,
Venkatesh
Hi All,
i need to split a string, then need to concatenate the strings in to another string.
how can i do it.
For example: ABCDEFGHIKWXYZPQRS. in this i need to split ABCDEFGHIK, WXYZ and
PQRS. then i need to merge PQRS-ABCDEFGHIK. how can i do it???
please help me
2009 Jan 16 6:58 AM
Hi,
Try using the offset of the variable to split it to another variable and then concatenate as you want.
Thanks,
Srilakshmi.
2009 Jan 16 6:59 AM
hi ,
using offset logic, try this one..
data: v_1(26) type c,
v_2(26) type c,
v_3(26) type c,
v_4(26) type c.
v_1 = 'ABCDEFGHIJ....YZ'.
now ,
v_2 = v_1+0(15).
v_3 = v_1+15(21)
v_4 = v_1+21(26).
hope this will help you..
regards
vijay
2009 Jan 16 7:00 AM
hi,
hi ,
using offset logic, try this one..
data: v_1(26) type c,
v_2(26) type c,
v_3(26) type c,
v_4(26) type c.
v_1 = 'ABCDEFGHIJ....YZ'.
now ,
v_2 = v_1+0(15).
v_3 = v_1+15(21)
v_4 = v_1+21(26).
clear v_1.
then concatenate v_2 v_3 v_4 to v_1." use the concatenate syntax...
regards
vijay
2009 Jan 16 6:59 AM
can u explain me how do you want to split the string
is it that u want to split the string based on length???
2009 Jan 16 6:59 AM
Hi Hema,
You can use offset for your requirement.
Using offset save ABCDEFGHIK, WXYZ and PQRS in separate variables.
Then concatenate last and first variable having values of PQRS and ABCDEFGHIK into a separate variables.
Hope this will help.
Regards,
Nitin.
2009 Jan 16 7:00 AM
Hi,
try this,
ata var(28) type c.
data: var1(28) type c,
var2(28) type c,
var3(28) type c.
var = 'ABCDEFGHIKWXYZPQRS'.
split var at 'W' into var1 var2.
concatenate 'W' var2 into var2.
split var2 at 'P' into var2 var3.
concatenate 'P' var3 into var3.
write:/ var2, var3.
concatenate var3 '-' var1 into var.
write:/ var.
Regards,
Venkatesh
2009 Jan 16 7:02 AM
Hi,
If this is fixed length string , you can directly split this and assign to new variables like:
if string = ABCDEFGHIKWXYZPQRS.
var_a = string+0(10)
var_b = string+14(4).
concatente var_b '-' var_a into var_c.
Rgds,
Sandeep
2009 Jan 16 7:03 AM
hi,
DATA : wa_text(20) VALUE 'ABCDEFGHIKWXYZPQRS'.
CONCATENATE wa_text+14(4) wa_text+0(10) INTO wa_text SEPARATED BY '-'.
WRITE wa_text.
"Output : PQRS-ABCDEFGHIKThanks & Regards
2009 Jan 16 7:04 AM
Hi,
You Can try using the REPLACE statement..for more details you can type replace and press F1 help.
Regards,
Rahul
2009 Jan 16 7:05 AM
Hi Hema,
Try it this way:
DATA:
w_string type string,
w_string1 type string,
w_string2 type string,
w_string3 type string,
f_string type string.
w_string = 'ABCDE FGHIKWX YZPQRS'.
Split w_string at SPACE into w_string1 w_string2 w_string3 .
concatenate w_string3 '-' w_string1 into f_string.
write:/
f_string.With luck,
Pritam.
2009 Jan 16 7:22 AM
Try this code
DATA : w_1 TYPE string,
w_2 TYPE string,
w_3 TYPE string,
w_4 TYPE string.
w_1 = 'ABCDEFGHIKWXYZPQRS'.
w_3 = w_1+14(4).
w_2 = w_1+0(10).
CONCATENATE w_3 w_2 INTO w_4 SEPARATED BY '-'.
2009 Jan 16 7:49 AM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |