07-04-2007 11:25 AM
Hi,
I am trying to combinee 2 strings.
I am getting the error that w_str1 is not defined.
W_STR1='THIS IS'.
W_STR2='A BOOK'.
CONCATENATE W_STR1, W_STR2 INTO W_STR3.
WRITE:/ W_STR3.
07-04-2007 11:27 AM
Hi,
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, SYSUBRC
is set to 4.
DATA: C1(10) VALUE 'Sum',
C2(3) VALUE 'mer',
C3(5) VALUE 'holi ',
C4(10) VALUE 'day',
C5(30),
SEP(3) VALUE ' - '.
CONCATENATE C1 C2 C3 C4 INTO C5.
WRITE C5.
CONCATENATE C1 C2 C3 C4 INTO C5 SEPARATED BY SEP.
WRITE / C5.
Output:
Summerholiday
Sum - mer - holi - day
In C1 to C5, the trailing blanks are ignored. The separator SEP retains them.
REgards,
Bhaskar
07-04-2007 11:27 AM
Hi,
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, SYSUBRC
is set to 4.
DATA: C1(10) VALUE 'Sum',
C2(3) VALUE 'mer',
C3(5) VALUE 'holi ',
C4(10) VALUE 'day',
C5(30),
SEP(3) VALUE ' - '.
CONCATENATE C1 C2 C3 C4 INTO C5.
WRITE C5.
CONCATENATE C1 C2 C3 C4 INTO C5 SEPARATED BY SEP.
WRITE / C5.
Output:
Summerholiday
Sum - mer - holi - day
In C1 to C5, the trailing blanks are ignored. The separator SEP retains them.
REgards,
Bhaskar
07-04-2007 11:31 AM
HI
Please use the following code.
data: W_STR1 type string.
data: W_STR2 type string.
data: W_STR3 type string.
W_STR1 = 'THIS IS'.
W_STR2 = 'A BOOK'.
CONCATENATE W_STR1 W_STR2 INTO W_STR3.
WRITE:/ W_STR3.
Infact some spacing is required between "=".
Regards
Geogy
Please reward usefull answer!!!
07-04-2007 11:28 AM
Hello,
Change the code like this.
W_STR1='THIS IS'.
W_STR2='A BOOK'.
CONCATENATE W_STR1 W_STR2 INTO W_STR3. " Remove the comma
WRITE:/ W_STR3.
Vasanth
07-04-2007 11:29 AM
Hi,
remove the comma between W_STR1 and W_STR2.
write like this.
W_STR1='THIS IS'.
W_STR2='A BOOK'.
CONCATENATE W_STR1 W_STR2 INTO W_STR3.
WRITE:/ W_STR3.
Regards,
Nagaraj
07-04-2007 11:29 AM
u have to declare all the three datas.
data :w_str1(7),w_str2(6),w_str3(14).
W_STR1='THIS IS'.
W_STR2='A BOOK'.
CONCATENATE W_STR1 W_STR2 INTO W_STR3.
WRITE:/ W_STR3.
or
data : w_str1 type string,
w_str2 like w_str1,
w_str3 like w_str1.
W_STR1='THIS IS'.
W_STR2='A BOOK'.
CONCATENATE W_STR1 W_STR2 INTO W_STR3.
WRITE:/ W_STR3.
07-04-2007 11:31 AM
Hi Rams,
Use this code your problem will clear,
DATA: W_STR1 TYPE STRING,
W_STR2 TYPE STRING,
W_STR3 TYPE STRING.
W_STR1 = 'THIS IS'.
W_STR2 = 'A BOOK'.
CONCATENATE W_STR1 W_STR2 INTO W_STR3.
WRITE:/ W_STR3.
IF USEFULL REWARD
07-04-2007 11:34 AM
h i rams,
CONCATENATE
Combines a series of strings into a single string.
Syntax
CONCATENATE <c1>... <cn> INTO <c> [ SEPARATED BY <s> ].
The strings <c1> to <cn> are concatenated, and the result placed in <c>. The SEPARATED BY addition allows you to specify a string <s> to be placed between the strings
If useful reward POINTS.
07-04-2007 11:36 AM
Hi , here is your result
report zrdez .
data : W_STR1 type string value 'THIS IS',
W_STR2 type string value 'A BOOK',
W_STR3 type string .
CONCATENATE W_STR1 W_STR2 INTO W_STR3.
WRITE:/ W_STR3.
O/p
<b>THIS ISA BOOK</b>
reward points if it is usefull ...
Girish
07-04-2007 11:40 AM
HI,
see this.
data:W_STR1(10),W_STR2(10),W_STR3(20).
W_STR1 = 'THIS IS'.
W_STR2 = 'A BOOK'.
CONCATENATE W_STR1 W_STR2 INTO W_STR3 SEPARATED BY space.
WRITE:/ W_STR3.
rgds,
bharat.
07-04-2007 11:42 AM
data:
w_str1(10) type c,
w_str2(10) type c,
w_str3(20) type c.
W_STR1='THIS IS'.
W_STR2='A BOOK'.
CONCATENATE W_STR1 W_STR2 INTO W_STR3.
WRITE:/ W_STR3.
Remove comma in your code.
This works.
Regards,
Pavan P.