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

concatenate

Former Member
0 Likes
746

Hi everybody

can any body can give me the use of concatenate with examples

Thanks in advance

regards

srinivas

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
723

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

5 REPLIES 5
Read only

Former Member
0 Likes
724

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

Read only

Former Member
0 Likes
723

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

Read only

rahul2000
Contributor
0 Likes
723

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

Read only

Former Member
0 Likes
723

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.

Read only

GrahamRobbo
SAP Mentor
SAP Mentor
0 Likes
723

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