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

Inserting a Character in between a String

Former Member
0 Kudos
12,073

Dear All.

I have a string of around 60-80 characters and its length depends at run time. Now I would like to insert a character value between the 3rd and the 4th character of the string.

E.g : Str1 = '020BUPATEXAS...'

Now I would like to insert a value 'E' between a 3rd charactre and 4th character as below:

Str1 = '020EBUPATEXAS....'

Can anyone throw some light on this.

Regards, Vinay

5 REPLIES 5
Read only

Former Member
0 Kudos
3,717

Hi,

You need a new variable, and then fill this piece by piece.


move: str1(3) to new_text(3),
      'E'      to new_text+3(1),
      str1+3 to new_text+4.

Regards,

Nick

Read only

Former Member
0 Kudos
3,717

Hi,

Try this

REPORT  ZTEST_CHA.


data : V_char type string,
       v_len type i.

v_char = '020string'.

V_len = strlen( v_char ).

v_len = v_len - 3.

concatenate v_char+0(3) 'E' v_char+3(v_len) into v_char.

write : v_char.

Read only

3,717

Hi,

Another solution witout new variable:


  DATA:
    str1                          TYPE           string
                                  VALUE          '020BUPATEXASxxxxxxx'.

  CONCATENATE str1(3) 'E' str1+3 INTO str1.

Regards,

Daniel

Read only

0 Kudos
3,717
thank you mr. daniel.
Read only

3,717

priyahydee77

the new statement propose now

result = str1+0(3) && 'E' && str1+3.

or better

result = |{ str1+0(3)} E {str1+3}|