‎2006 Jan 10 1:55 AM
How can I concatenate two string, but yet preserved the space at the back?
e.g.
DATA: A1 TYPE STRING,
A2 TYPE STRING.
A1 = 'AA '
A2 = 'BB '
If I use
CONCATENATE A1 A2 TO A2
it gives 'AABB'.
How can I concatenate the string and get 'AA BB '?
‎2006 Jan 10 2:06 AM
DATA: A1 TYPE STRING,
A2 TYPE STRING.
A1 = 'AA '.
A2 = 'BB '.
CONCATENATE A1 A2 ' ' inTO A2 "add 2 blanks in quotes
separated by space.
write: / a2.
Reward points accordingly.
‎2006 Jan 10 2:06 AM
CONCATENATE a1 a2 INTO a2 SEPARATED BY space. This will put a space between the two.
Rob
‎2006 Jan 10 2:06 AM
DATA: A1 TYPE STRING,
A2 TYPE STRING.
A1 = 'AA '.
A2 = 'BB '.
CONCATENATE A1 A2 ' ' inTO A2 "add 2 blanks in quotes
separated by space.
write: / a2.
Reward points accordingly.
‎2006 Jan 10 2:17 AM
Sorry.. the content has been somehow modified after posting to the forum.
A1 = 'AA' followed by 4 space
A2 = 'BB' followed by 2 space
The desired output should be
AA + 4 space + BB + 2 space.
Thanks!
‎2006 Jan 10 2:21 AM
‎2006 Jan 10 2:27 AM
From F1 (4.6C) on 'STRING':
Working with Strings
In the current release it has not been possible to fully
complete the implementation of strings. Especially the
handling of blank characters at the end of a string has
not been finalized for a number of ABAP statements.
For the highlighted argument positions of the following
ABAP statements, blank characters at the end of strings
are not taken into account. This may change in the next
release. Therefore strings with blank characters at the
end should not be used in these positions.Rob
‎2006 Jan 10 2:30 AM
I am using 4.7 Ext 200.
So space char at the back is always truncated using string functions? Is It?
Thanks!
‎2006 Jan 10 2:36 AM
So I think you are stuck with someting like:
REPORT ztest LINE-SIZE 80 LINE-COUNT 64 MESSAGE-ID zc.
DATA: a1 TYPE string,
a2 TYPE string,
a3 TYPE string.
a1 = 'AA '.
a2 = 'BB '.
a3 = '****'.
CONCATENATE a1 a3 a2 INTO a2.
DO 4 TIMES.
REPLACE '*' WITH space INTO a2.
ENDDO.
WRITE /001 a2.
Rob
‎2006 Jan 10 2:37 AM
Hi,
try the following..
data: a1 type string,
a2 type string,
a3(3) value ' ',
a4(1) value ' '.
a1 = 'AA'.
a2 = 'BB'.
concatenate a1 space into a1 separated by a3.
concatenate a2 space into a2 separated by a4.
a3 = '123'.
write:/ a1,a2,a3.
I put the third variable just see whether there are two spaces after BB.
Regards,
Suresh Datti
‎2006 Jan 10 2:38 AM
In 4.6C, yes. You should do F1 yourself on 'STRING' in your 4.7 ssytem and see what turns up. Maybe there's a workaround.
Rob
‎2006 Jan 10 3:13 AM
Seeing your diff req, use this:
Re: Concatenate string problem
Posted: Jan 9, 2006 8:06 PM Reply E-mail this post
DATA: A1 TYPE STRING,
A2 TYPE STRING.
data: Filler4(4) value ' '. " four blanks
data: Filler2(2) value ' '. two blanks
A1 = 'AA '.
A2 = 'BB '.
CONCATENATE A1 Filler4 A2 Filler2 inTO A2 separated by space.
‎2006 Jan 10 3:33 AM
Thanks for your reply.
But how can it handle if the no. of space char is different each time?
four space followed by AA is only just an example... it varies case by case in my situation.
Thanks!
‎2006 Jan 10 4:05 AM
Hi u can try this one
data: a1 type string,
a2 type string,
a3(1) value ' '.
a1 = 'AA'.
a2 = 'BB'.
concatenate a1 a3 a3 a3 a3 a3 a2 a3 a3 into a1 .
write:/ a1.
This will do for ur scenario.
<i>>But how can it handle if the no. of space char is different each time?
>four space followed by AA is only just an example... it varies case by case in my situation.</i>