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,295

Hi Friends,

Suppose if i have 2 strings which is concatenate into another variable.

data : a(10) type c value 'INDIA',

b(20) type c value 'HELLO',

c(40) type c.

concatenate a b into c seperated by space.

write c.

result will be = INDIA HELLO.

result will have only single space, if i need to increase the space what should i do.

good answer can be awarded.

Good luck all.

Hi Friends,

Suppose if i have 2 strings which is concatenate into another variable.

data : a(10) type c value 'INDIA',

b(20) type c value 'HELLO',

c(40) type c.

concatenate a b into c seperated by space.

write c.

result will be = INDIA HELLO.

result will have only single space, if i need to increase the space what should i do.

good answer can be awarded.

Good luck all.

10 REPLIES 10
Read only

Former Member
0 Likes
1,265

concatenate a space space b into c seperated by space.

output - INDIA HELLO i.e 3 blank spaces.

Reward points if helpful

Read only

Former Member
0 Likes
1,265

data : a(10) type c value 'INDIA',
b(20) type c value 'HELLO',
c(40) type c,
sp(4) value '    '.

concatenate a b into c seperated by sp.

write c.


regards

shiba dutta

Read only

jaideeps
Product and Topic Expert
Product and Topic Expert
0 Likes
1,265

hi,

gud..

SEPARATED not seperated..kindly do the changes

thnaks

jaideep

Read only

Former Member
0 Likes
1,265

Hello,

Do like this.


data : a(10) type c value 'INDIA',
b(20) type c value 'HELLO',
c(40) type c,
blank(6) value '       '." CHeck here

concatenate a b into c seperated by blank." CHeck here
write c.

Vasanth

Read only

Former Member
0 Likes
1,265

Check if it works

concatenate a ' ' b into c seperated by space.

Regards,

Atish

Read only

Former Member
0 Likes
1,265

The CONCATENATE statement combines two or more separate strings into one.

CONCATENATE c1 ... cn INTO c [SEPARATED BY s].

This statement concatenates the character fields c1 to cn and assigns the result to c. The system ignores spaces at the end of the individual source strings.

The addition SEPARATED BY s allows you to specify a character field s which is placed in its defined length between the individual fields.

If the result fits into c, sy-subrc is set to 0. However, if the result has to be truncated, sy-subrc is set to 4.

DATA: c1(10) TYPE c VALUE 'Sum',

c2(3) TYPE c VALUE 'mer',

c3(5) TYPE c VALUE 'holi ',

c4(10) TYPE c VALUE 'day',

c1 (30) TYPE c,

sep(3) TYPE c VALUE ' - '.

CONCATENATE c1 c2 c3 c4 INTO c5.

WRITE c5.

CONCATENATE c1 c2 c3 c4 INTO c5 SEPARATED BY sep.

WRITE / c5.

The output looks like this:

Summerholiday

Sum - mer - holi - day

In c1 to c5, the trailing blanks are ignored. The separator sep retains them.

Rewards point if helpful.....

Thanks.

Abhay.

Read only

Former Member
0 Likes
1,265

data : a(10) type c value 'INDIA',

b(20) type c value 'HELLO',

c(40),

sep(4) value ' '.

concatenate a b into c sep<b>a</b>rated by sep.

write c.

<b>first declare the seperator and then check the spelling of separated..</b>

Read only

Former Member
0 Likes
1,265

hi

try this.

data : a(10) type c value 'INDIA ',

b(20) type c value ' HELLO',

c(40) type c.

concatenate a b into c separated by space.

write c.

reward if useful.

Read only

Former Member
0 Likes
1,265

<b>Corrected !!</b>

data : a type string,

b type string,

c type string.

a = 'INDIA'.

b = 'HELLO'.

concatenate a ' ' b into c respecting blanks.

write c.

Reward if useful..

Read only

Former Member
0 Likes
1,265

hi purna

Try out the following which will really help out....

<b>data : a(10) type c value 'INDIA',

b(20) type c value 'HELLO',

c(40) type c,

sp(4) value ' '.// make sure that you count the length according to the spaces

concatenate a b into c seperated by sp .

write c.</b>

reward if useful....