Application Development 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: 

concatenate two fields into single field

Former Member
0 Kudos

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

Former Member
0 Kudos

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

12 REPLIES 12

kesavadas_thekkillath
Active Contributor
0 Kudos

check f1 help of concatenate statement

Former Member
0 Kudos

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.

0 Kudos

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.

0 Kudos

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

0 Kudos

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.

0 Kudos

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.

0 Kudos

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

0 Kudos

Hi Jhon,

Thanks a lot.

Am getting just a comma between the fields.

But not in the next line.

Thanks,

Silpa.

0 Kudos

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

0 Kudos

Hi,

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

my requirement is: goods receipt

invoice receipt.

Thanks,

Silpa.

Former Member
0 Kudos

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

Former Member
0 Kudos

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