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

Concatenate

Former Member
0 Likes
1,583

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,546

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

12 REPLIES 12
Read only

Former Member
0 Likes
1,546

Hi,

Try using the offset of the variable to split it to another variable and then concatenate as you want.

Thanks,

Srilakshmi.

Read only

Former Member
0 Likes
1,546

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

Read only

0 Likes
1,546

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

Read only

Former Member
0 Likes
1,546

can u explain me how do you want to split the string

is it that u want to split the string based on length???

Read only

Former Member
0 Likes
1,546

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.

Read only

Former Member
0 Likes
1,547

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

Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
1,546

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

Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
1,546

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-ABCDEFGHIK

Thanks & Regards

Read only

Former Member
0 Likes
1,546

Hi,

You Can try using the REPLACE statement..for more details you can type replace and press F1 help.

Regards,

Rahul

Read only

Former Member
0 Likes
1,546

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.

Read only

former_member585060
Active Contributor
0 Likes
1,546

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 '-'.

Read only

Former Member
0 Likes
1,546

This message was moderated.