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: 

CONCATENATE

Former Member
0 Kudos

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

Former Member
0 Kudos

concatenate a space space b into c seperated by space.

output - INDIA HELLO i.e 3 blank spaces.

Reward points if helpful

Former Member
0 Kudos

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

0 Kudos

hi,

gud..

SEPARATED not seperated..kindly do the changes

thnaks

jaideep

Former Member
0 Kudos

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

Former Member
0 Kudos

Check if it works

concatenate a ' ' b into c seperated by space.

Regards,

Atish

Former Member
0 Kudos

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.

Former Member
0 Kudos

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>

Former Member
0 Kudos

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.

Former Member
0 Kudos

<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..

Former Member
0 Kudos

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....