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 two fields into single field

Former Member
0 Likes
15,201

Hi,

I have a requirement to retrieve two fields from different tables of same type and pass them to a single field in alv grid.

Kindly help me in this issue.

Thanks ,

silpa.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
5,488

use like this-->

CONCATENATE ITAB1-FIELD1 ITAB2-FIELD2 INTO <REQUIRED FIELD>

But be sure that field type should be character.

otherwise you have to move other value into some character type field.

Regds,

Anil

Hi,

I have a requirement to retrieve two fields from different tables of same type and pass them to a single field in alv grid.

Kindly help me in this issue.

Thanks ,

silpa.

12 REPLIES 12
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
5,488

check f1 help of concatenate statement

Read only

Former Member
0 Likes
5,488

Suppose there are two fields of length 5 retrieved from different tables. Declare a new field in internal table with length 10, then concatenate field1 field2 into internal table-field. Then pass the internal table to FM REUSE_ALV_GRID_DISPLAY.

Read only

0 Likes
5,488

Hi Arjun,

I have tried this and iam getting the two field values in the same row.

But my requirement is to show them in different rows.

eg:1st field: goods recieipt.

2nd field : invoice receipt.

LOOP AT IT_FINAL INTO WA_FINAL.

concatenate WA_FINAL-btext WA_FINAL-beWtl into WA_FINAL-bte separated by space.

MODIFY IT_FINAL FROM WA_FINAL TRANSPORTING BTE.

ENDLOOP.

I have tried this

and o/p is : goods recieipt invoice receipt.

and my requirement is :

goods recieipt.

invoice receipt.

Thanks,

Silpa.

Read only

0 Likes
5,488

Hi,

If you want the 2nd field to be concatenated in a new line, try the following


CONSTANTS: c_new_line(1) TYPE c VALUE cl_abap_char_utilities=>newline

LOOP AT IT_FINAL INTO WA_FINAL.
CONCATENATE WA_FINAL-btext WA_FINAL-beWtl into WA_FINAL-bte separated by c_new_line.
MODIFY IT_FINAL FROM WA_FINAL TRANSPORTING BTE.
ENDLOOP.

Regards,

Vik

Edited by: vikred on Jul 23, 2009 3:15 PM

Edited by: vikred on Jul 23, 2009 3:16 PM

Read only

0 Likes
5,488

Hi Silpa -

U can try the below code, which is suggested by Vikred. This will separate the concatenated text by a line.


CONSTANTS: c_new_line(1) TYPE c VALUE cl_abap_char_utilities=>newline
 
LOOP AT IT_FINAL INTO WA_FINAL.
CONCATENATE WA_FINAL-btext WA_FINAL-beWtl into WA_FINAL-bte separated by c_new_line.
MODIFY IT_FINAL FROM WA_FINAL TRANSPORTING BTE.
ENDLOOP.

Read only

0 Likes
5,488

Hi Arjun & Vikred,

Thanks for your suggestion

But it is not working fine there is just a rectangle box coming between this two fields.

Thanks,

Silpa.

Read only

0 Likes
5,488

Hi Silpa,

Try this one.

LOOP AT IT_FINAL INTO WA_FINAL.

concatenate WA_FINAL-btext ',' WA_FINAL-beWtl into WA_FINAL-bte separated by space.

split wa_final-bte at , into wa_final-btext wa_final-bewti.

MODIFY IT_FINAL FROM WA_FINAL TRANSPORTING BTE.

ENDLOOP

Thanks & Regards,

John Victor

Read only

0 Likes
5,488

Hi Jhon,

Thanks a lot.

Am getting just a comma between the fields.

But not in the next line.

Thanks,

Silpa.

Read only

0 Likes
5,488

You mean you are getting a blank field inbetween the 2 values in the ALV grid?

Read only

0 Likes
5,488

Hi,

Its not blank field but one small box between goods receipt & invoice receipt.

my requirement is: goods receipt

invoice receipt.

Thanks,

Silpa.

Read only

Former Member
0 Likes
5,489

use like this-->

CONCATENATE ITAB1-FIELD1 ITAB2-FIELD2 INTO <REQUIRED FIELD>

But be sure that field type should be character.

otherwise you have to move other value into some character type field.

Regds,

Anil

Read only

Former Member
0 Likes
5,488

Hi,

Try following

Loop at it_final into wa_final.

1) read value from table1 into var1.

2) read value from table2 into var2.

3) Concatenate var1 var2 into wa_final-field.

4) Append wa_final to it_final.

Endloop.

Regards

Milan Shah

Edited by: Milan Shah on Jul 23, 2009 6:45 PM