2008 Apr 12 7:54 AM
Hi everybody
can any body can give me the use of concatenate with examples
Thanks in advance
regards
srinivas
2008 Apr 12 7:56 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, sy-subrc is set to 4.
DATA: c1(10) TYPE c VALUE 'Sum',
c2(3) TYPE c VALUE 'mer',
c3(5) TYPE c VALUE 'holi ',
c4(10) TYPE c VALUE 'day',
c1 (30) TYPE c,
sep(3) TYPE c VALUE ' - '.
CONCATENATE c1 c2 c3 c4 INTO c5.
WRITE c5.
CONCATENATE c1 c2 c3 c4 INTO c5 SEPARATED BY sep.
WRITE / c5.The output looks like this:
Summerholiday
Sum - mer - holi - day
In c1 to c5, the trailing blanks are ignored. The separator sep retains them.
reward if helpful
raam
Hi everybody
can any body can give me the use of concatenate with examples
Thanks in advance
regards
srinivas
2008 Apr 12 7:56 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, sy-subrc is set to 4.
DATA: c1(10) TYPE c VALUE 'Sum',
c2(3) TYPE c VALUE 'mer',
c3(5) TYPE c VALUE 'holi ',
c4(10) TYPE c VALUE 'day',
c1 (30) TYPE c,
sep(3) TYPE c VALUE ' - '.
CONCATENATE c1 c2 c3 c4 INTO c5.
WRITE c5.
CONCATENATE c1 c2 c3 c4 INTO c5 SEPARATED BY sep.
WRITE / c5.The output looks like this:
Summerholiday
Sum - mer - holi - day
In c1 to c5, the trailing blanks are ignored. The separator sep retains them.
reward if helpful
raam
2008 Apr 12 7:57 AM
Hi Srinivas,
Here is the syntax.
concatenate f1 f1 into f3 separated by <separator>
Here f1...fn are fields and separator can be ',', space etc.
For More details make a F1 on concatenate statement.
Thanks,
Arun
2008 Apr 12 7:57 AM
Hi,
Suppose say in LFA1 table Name1 contains vendor name and NAME2 contains his surname...
then u can do something like this
data:var type string.
concatenate lfa1-name1 lfa1-name2 into var separed by space
suppose name1 has rahul
name2 has bhat
now var will have rahul bhat
if u dont write separted by space var will have rahulbhat
2008 Apr 12 8:27 PM
Hi,
Please refer code below :
data : str1(5) type c value 'SAP',
str2(5) type c value 'SDN',
result(10) type c.
concatenate str1 str2 into result separated by space.
write : result.
O/P
SAP SDN
Thanks,
Sriram Ponna.
2008 Apr 13 2:58 AM
Hi Srini,
this may seem really obvious, but...
In the ABAP editor type "concatenate" then press F1 to get the help documentation.
Cheers
Graham Robbo