Application Development 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: 

String Modifications

Former Member
0 Kudos

I a storing a value of size 10 in a char variable.

But i need to insert thr "_" in the middle of that valuewhile display.

EX:

data:ch(10) value '0123456789'.

Now my requirement is when display this

It as to display as

01234_56789.

Plz Tell me any one how to do this

Thanks & Regards

Vamsin

6 REPLIES 6

Former Member
0 Kudos

first use FM STRING_SPLIT_AT_POSITION , with inputs as the string and the position

then you get the data in 2 variables , then concatenate them

concatenate string1 string2 into v_string separated by '-'.

0 Kudos

Hi,

DATA: str type string.

data:ch(10) value '0123456789'.

concatenate ch0(5) '_' ch5(5) into str.

Regards,

Sesh

Former Member
0 Kudos

Hi Vamsi,

Check this code.

DATA CH(10) VALUE '0123456789'.

DATA V_CH(11).

<b>CONCATENATE CH0(5) CH5(5) INTO V_CH SEPARATED BY '_'.</b>

WRITE:/ V_CH.

Thanks,

Vinay

Former Member
0 Kudos

Take another character field of size 11

data:

ch1(11) type c.

move ch0(5) to ch10(5).

concatenate ch1 '_' into ch1.

move ch5(5) to ch16(5).

regards,

Pavan P.

former_member208856
Active Contributor
0 Kudos

Hi,

use code as below :

data: ch(10) value '0123456789'.

data : ch1(11).

data : part1(5), part2(5).

part1 = ch+0(5).

part2 = ch+5(5).

concatenate part1 '_' part2 into ch1.

write : / ch.

write : / ch1.

Reward points, if helpful,

Sandeep Kaushik

Former Member
0 Kudos

Hi,

You can do this by using another variable of type C of length 11.

Here you can d the follwoing:

DATA: Char2(11) type c.

Char20(5) = ch0(5).

Char2+5(1) = '_'.

Char26(5) = ch5(5).

Now display the variable Char2.

Ashvender