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 two fields

Former Member
0 Likes
2,905

Hi,

I want to concatenate two fields into a target field. Both are of type character.

Now my Question is I want to concatenate these two fields without loosing trailing spaces.

for example ,first field is of length 20 and the sencond field is of lenth 15 characters.

Data : s1(20) type c,

s2(15) type c.

data : s3(40) type c.

S1 = 'sdn'.

S2 = 'network'.

concatenate s1 s3 into s3.

s3 should contain the contents like 'sdn network '.

after 'sdn' there are 17 spaces (20-3) and after 'network' there are 8 spaces(15-7).

Can u pls anyone suggest me on the same.

I tried using conversion exits, but for character type of fields , there will be no effect.

Regards,

Sujatha.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,084

Hi Sujatha,

do like this

concatenate field1

` `

field2

` `

into v_target.

The Quotes you see are not normal ones. they are escape characters (The key above the TAB key n the keyborad.

Regards,

Ravi

9 REPLIES 9
Read only

Former Member
0 Likes
1,085

Hi Sujatha,

do like this

concatenate field1

` `

field2

` `

into v_target.

The Quotes you see are not normal ones. they are escape characters (The key above the TAB key n the keyborad.

Regards,

Ravi

Read only

rahulkavuri
Active Contributor
0 Likes
1,084

try this way

Data : s1(20) type c,

s2(15) type c.

data : s3(40) type c.

S1 = 'sdn'.

S2 = 'network'.

concatenate s10(20) s20(15) into s3.

Read only

Former Member
0 Likes
1,084

Try this:

s3 = s1.

s3+20 = s2.

Read only

Former Member
0 Likes
1,084

Hi,

You can use ..

Condense field NO-GAPS.

Reward if you find this useful..

Read only

Former Member
0 Likes
1,084

If you know the exact lengths , try this

report y_test1.

data : s1(20) type c,
s2(15) type c.
data : s3(40) type c.

S1 = 'sdn'.
S2 = 'network'.

s3+0(20) = s1.
s3+20(15) = s2.

write : s3.

Read only

Former Member
0 Likes
1,084

Hello,


try like this
Data : s1(20) type c,
s2(15) type c.
data : s3(40) type c.

S1 = 'sdn'.
S2 = 'network'.
concatenate s1 ` `  s2 ` ` into s3.
write: s3

Vasanth

Read only

Former Member
0 Likes
1,084

we have 'separated by' option for this..

concatenate s1 s2 into s3 separated by space.

reward if it helps u...

Read only

Former Member
0 Likes
1,084

Hi Sujatha.

i thnk this will work..

<u><b>Syntax</b></u>

CONCATENATE {dobj1 dobj2 ...}|{LINES OF itab}

INTO result

[IN {BYTE|CHARACTER} MODE]

[SEPARATED BY sep]

<b> [RESPECTING BLANKS].</b>

for ur example

DATA : s1(20) TYPE c,

s2(15) TYPE c.

DATA : s3(40) TYPE c.

s1 = 'sdn'.

s2 = 'network'.

CONCATENATE s1 s2 INTO s3 RESPECTING BLANKS.

WRITE s3.

Regards

Srinivas

*Reward all Useful answers

Read only

Former Member
0 Likes
1,084

Hi,

Concatenate VAR1 VAR2 INTO VAR3 SEPARATED BY SPACE.

Regards,

Irfan