2005 Sep 16 9:55 AM
Hi sap gurus. I was just wondering if it is possible to concatenate two variables without SAP changing the total length. For example, if I have two variables declared as:
DATA: temp1(10) type c,
temp2(10) type c.
temp1 = 'hello'.
temp2 = 'jerry'.
if we use:
concatenate temp1 temp2 into temp3.
The result in temp3 would be "hellojerry".
Is there a way for me to concatenate this variables with the result in temp3 as "hello jerry " since the maximum allocated space for both variables is 10.
2005 Sep 16 9:56 AM
Hi
concatenate temp1 temp2 into temp3 separated by space.
Anyway depend on length of temp3, it should be long 20 chars.
Max
Message was edited by: max bianchi
2005 Sep 16 9:57 AM
2005 Sep 16 9:57 AM
Use --
concatenate temp1 temp2 into temp3 separated by space.
Cheers.
2005 Sep 16 9:58 AM
Hi,
DATA: temp1(10) type c,
temp2(10) type c,
temp3(11).
temp1 = 'hello'.
temp2 = 'jerry'.
concatenate temp1 temp2 into temp3 separated by space.
Svetlin
2005 Sep 16 10:11 AM
The length of variables <i>temp1</i> and <i>temp2</i> is not relevant here. But you should give <i>temp3</i> a sufficient length : 10 would be sufficient in your example.
Please, note also that there won't be any space at the end of 'hello jerry ' (you write a trailing space in your example). The only space added is between <i>temp1</i> and <i>temp2</i>.
You could declare <i>temp3</i> on 11 characters in that particular case.
2005 Sep 16 10:50 AM
hi
the simple way is to use concatenate statement with seprated by space.and for more calrity u use f1 help on concatenate.
if this has solved ur prblm plz gave rewards
thanks
2005 Sep 17 8:38 AM
if you really want to have the white spaced preserved,
use the following
concatenate `hello ` `jerry. ` into temp3 .
please note that i have not used single quote.
Regards
Raja
2006 Jan 06 9:52 PM
hey catabs. it's raymond from xavier. Where are you now? Anyway, email me at friedpapaya@hotmail.com
2006 Jan 07 8:50 AM
Hi Ferdinand,
I can understand your query.
<b>Your Problem:</b>
You are having a 3 strings 'temp1', 'temp2' and 'temp3'.
'temp1' & 'temp2' are of length 10 and 'temp3' is of length 20.
In 'temp1' and 'temp2' you are having strings of 5 charecters and remaining 5 charecters are empty.
You are asking whether can we join the 2 strings (temp1,temp2) into a string(result).
So that you should have the 5 charecters which are empty also should be in the 'temp3' string.
<b>Solution:</b>
When you concatenate 2 strings it will removes the unassigned charecters from the source strings starting from the end of string.
If you want to display the spaces also then you have to assign the spaces to the string during initialization.
DATA: temp1(10) type c,
temp2(10) type c,
temp3(20) type c.
temp1 = 'hello '.
*12345 - blank spaces added in both strings
temp2 = 'jerry '.
concatenate temp1 temp2 into temp3.
* Here you assign blanks to the string.
* Now it will display 'hello jerry '
* 12345 12345
If you decrease the length of temp3 as 10 it will display only the 'hello ' remaining is ignored.
Hope it helps.
Regards,
Maheswaran.B