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
801

Hi ,

i need to concatenate 4 fields into a string with space but i can't use separated by space as it creates extra space in between 2 fields .

The statement i am using is

Concatenate str1 str2 ',' str3 into string .

Here i need to have space between str1 and str2 and before str3 . But if i use separated by space it adds space after comma also i tried using the constant SPACE and also ' ' but its not working . Please suggest .

6 REPLIES 6
Read only

Former Member
0 Likes
749

hi,

concatenate str1 str2 into string separated by space.

then concatenate string and ',' into string.

then concatenate str3 and string into string separated by space.

regards,

sakshi

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
749

YOu can do something like this.

REPORT zrich_0001.

data: str1 type string.
data: str2 type string.
data: str3 type string.
data: str4 type string.

str1 = 'This'.
str2 = 'That'.
str3 = 'The other'.


Concatenate str1 str2 into str4 separated by space.
concatenate str4 ',' into str4.
Concatenate str4 str3 into str4 separated by space.

write:/ str4.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
749

Try something like this,


data: str1 type string,
      str2 type string,
      str3 type string.

str1 = 'How'.
str2 = 'are'.
str3 = 'you'.


concatenate str1 str2 into str1 SEPARATED BY space.

CONCATENATE str1 ',' str3 into str1.

write: str1.

Vikranth

Read only

Former Member
0 Likes
749

Use two concatenate statements.

Here your requirement is not to add a space after the comma. Hence use this:

Concatenate str1 str2 ',' into stringextra separated by space.
Concatenate stringextra str3 into New String.

if you need no space before and after comma then use this:

Concatenate str1 str2 into stringextra separated by space.
Concatenate stringextra ',' str3 into New String.

Edited by: Kapil Sharma @ Steria on Feb 10, 2010 6:32 AM

Read only

Former Member
0 Likes
749

Hi,

You can try below option.

Concatenate str1 str2 ',' into str_new separated by space.

Then concatenate this variable into new variable.

Concatenate str_new str3 into string.

This way you will be able to display text like:

str1 str2 ,str3.

Thanks,

Archana

Read only

Former Member
0 Likes
749

Thanks Rich , Using 3 concatenate statement solved the problem.