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: 

How to add multiple spaces to the middle of a string?

andrew_jacobs2
Participant
0 Kudos

Hi,

I have two strings:

str1 = 'NAME'

str2 = 'ADDRESS'

I want to create a third string:

str3 = 'NAME ADDRESS'

These do not work:

1) str3 = str1 + ' ' + str2

2) concatenate str1 ' ' str2 into str3

3) concatenate str1 ' ' str2 into str3 separated by space

4) str3 = 'NAME&ADDRESS'

replace '&' in str3 with ' '

5) str3 = 'NAME&ADDRESS'

overlay str3 with ' ' only '&'

Any other ideas?

Thx.

Andy

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Use STRLEN to determine the length of NAME and then put ADDRESS as many spaces over as needed.

Rob

9 REPLIES 9

Former Member
0 Kudos

Use the respecting blanks addtition:

concatenate ................RESPECTING BLANKS.

0 Kudos

concatenate str1 str2 into str3 separated by space

Former Member
0 Kudos

Use STRLEN to determine the length of NAME and then put ADDRESS as many spaces over as needed.

Rob

Former Member
0 Kudos

Hi,

i do this and it works:

DATA: STR0 TYPE STRING VALUE 'Vorname'.

DATA: STR1 TYPE STRING VALUE 'Nachname'.

DATA: STR2 TYPE STRING.

*

CONCATENATE STR0 STR1 INTO STR2 SEPARATED BY SPACE.

*

WRITE: / STR0.

WRITE: / STR1.

WRITE: / STR2.

Any problem with my example?.

regards, Dieter

Former Member
0 Kudos

hi,

You can Try

Concatenate Var1 space Var2 into var3.

Regards

Sumit Agarwal

JozsefSzikszai
Active Contributor
0 Kudos

hi Andrew,

how many spaces do you want? what is not working?

valid examples:

CONCATENATE str1 str2 INTO str3 SEPARATED by space.

==> result will be 1 space between the two words

CONCATENATE str1 ' ' str2 INTO str3 SEPARATED by space RESPECTING BLANKS.

==> result will be 2 spacea between the two words, but this is 6.0 syntax!

+you can also use offset.

hope this helps

ec

Former Member
0 Kudos

Hi,

check this...

concatenate str1 ' ' str2 into str3 separated by space

concatenate str1 str2 into str3 separated by space

regards

padma

rainer_hbenthal
Active Contributor
0 Kudos

>

> str1 = 'NAME'

> str2 = 'ADDRESS'

> Any other ideas?

>

> Thx.

> Andy

These are not strings, strings are enclosed in ` and not in apostrophes like '.

so use this:


  concatenate str1 str2 into str3 in character mode separated by space.

Former Member
0 Kudos

My requirement was to add 5 spaces in betwwen 2 strings and i wrote below code and it worked for me,

REPORT ztestttt.

DATA : kunnr TYPE kunnr,

        vkorg TYPE vkorg,

        text TYPE string.

DATA : lc(5) TYPE c VALUE '     '.

kunnr = 'W8400'.

vkorg = '2500'.

CONCATENATE kunnr vkorg INTO text SEPARATED BY lc.

WRITE : text.