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

problem in Concatenate

Former Member
0 Likes
1,821

Hi Abaper's

I have one problem in concatenation.While concatenation the spaces in the variable are getting removed.Is there any other way so that I can get the concatenated value with spaces.

For eg:

matnr = '100300 '

maktx = 'description '

CONCATENATE matnr maktx INTO Temp.

After concatenation the temp should contain 100300$$$$$$$ description$$$$$$$$$$$$

<b>

Where $ indicates a space.</b>

How to achieve this,kindly suggest

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,729

You can do something like this, notice that the length of the output field is 58.

[code]

report zrich_0001.

data: matnr type mara-matnr.

data: maktx type makt-maktx.

data: tmp type string.

data: len type i.

matnr = 'ABCDE'.

maktx = 'description'.

translate matnr using ' $'.

translate maktx using ' $'.

concatenate matnr maktx into tmp.

translate tmp using '$ '.

len = strlen( tmp ).

write:/ len, tmp.

[/code]

Regards,

RIch Heilman

13 REPLIES 13
Read only

Former Member
0 Likes
1,729

hi Sapient,

Pass spaces here..

[code]matnr = '100300$$$$$$$$ '

maktx = 'description$$$$$ '[/code]

or

[code]CONCATENATE matnr maktx INTO Temp separated by SPACE.[/code]

Regards,

Santosh

Message was edited by: Santosh Kumar P

Read only

Former Member
0 Likes
1,729

Try:

MOVE: matnr TO temp,

maktx TO temp+18.

Read only

Former Member
0 Likes
1,729

hi,

Instead of concatenate, make use of <b>offset</b>. It retains the spaces.

as you already know the length of matnr and maktx..

temp+0(10) = 100300.

temp+10(40) = 'description'.

write:/ temp.

regards,

Sailaja.

Read only

Former Member
0 Likes
1,729

There are two ways to resolve it...

translate matnr using ' $'.

translate maktx using ' $'.

concatenate matnr maktx into temp separated by '$'.

translate temp using '$ '.

Second option is to write the value into Temp variable using offset and length.

offset = 0.

describe field matnr length llen in character mode.

write matnr to temp+offset(llen).

offset = offset + llen + 1.

describe field maktxr length llen in character mode.

write maktx to temp+offset(llen).

Message was edited by: Anurag Bankley

Read only

Former Member
0 Likes
1,729

sorry,I missed to mention one thing

In the above eg

matnr = '100300 '

maktx = 'description '

CONCATENATE matnr maktx INTO Temp.

<b>In the above matnr and maktx value has some space after 100300$$$$$$ and description$$$$$$,</b>

<b>

Where $ indicates a space</b>

so after concatenation these spaces should not be supressed.

Read only

Former Member
0 Likes
1,729

then you can use OFFSET.

data : temp(60) type c.

temp+0(13) = matnr.

temp+14(23)= maktx.

now if you check the value it will have blank spaces betwen the 2.

Regards

srikanth

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,730

You can do something like this, notice that the length of the output field is 58.

[code]

report zrich_0001.

data: matnr type mara-matnr.

data: maktx type makt-maktx.

data: tmp type string.

data: len type i.

matnr = 'ABCDE'.

maktx = 'description'.

translate matnr using ' $'.

translate maktx using ' $'.

concatenate matnr maktx into tmp.

translate tmp using '$ '.

len = strlen( tmp ).

write:/ len, tmp.

[/code]

Regards,

RIch Heilman

Read only

Former Member
0 Likes
1,729

Hi,

Do like this,you will surely get

data:matnr like mara-matnr,maktx like makt-maktx,temp(50) type n,sp(10) type c.

<b>sp = ' '.</b> <b><<declare a variable with 5 spaces in single quotes>></b>

matnr = '100300'.

maktx = 'description'.

<b>concatenate matnr maktx into temp separated by sp.

concatenate temp sp into temp.</b>

write:/ temp.

Regards,

Sowjanya.

Read only

Former Member
0 Likes
1,729

Try: CONCATENATE .... INTO ... RESPECTING BLANKS.

Read only

hermanoclaro
Participant
0 Likes
1,729

Hi there,

Try this:

CONCATENATE matnr maktx INTO Temp SEPARATED BY SPACE.

Hope this helps.

Read only

Former Member
0 Likes
1,729

Hi,

use

<b>CONCATENATE matnr maktx INTO Temp SEPARATED BY SPACE.</b>

reward if useful.

Read only

Former Member
0 Likes
1,729

try this

data : text1(240),

matnr(18) type c value '1234',

maktx(40) type c value'material',

len type i,

pos1 type i,

spaces(18).

len = strlen( matnr ).

do len times.

spaces+pos1(1) = ' '.

pos1 = pos1 + 1.

enddo.

concatenate matnr(18) maktx(40) into text1 separated by spaces.

regards

shiba dutta

Read only

Former Member
0 Likes
1,729
data : text1(240),
       matnr(18) type c value '1234',
       maktx(40) type c value'material',
       len type i,
       pos1 type i,
       spaces(18).

len = strlen( matnr ).

do len times.
spaces+pos1(1) = '  '.
pos1 = pos1 + 1.
enddo.

concatenate matnr(18) maktx(40) into text1 separated by spaces.

regards

shiba dutta