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: 

concatenation problem

Former Member
0 Kudos

Hello,

I have three fields (for example matnr,werks , lgort) to be concatenated.

While concatenating i have to take care of any spaces in werks.

If there were any spaces after concatenatig i am not able to find the spaces.

for exameple : matnr = 1234

werks = ab

lgort = lg

then by concatenating i should get '1234ab lg' but i am getting '1234ablg'.

Can any body suggest me some solution

Thanks and Regards,

Soumya.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Concatenate the fields until WERKS using RESPECTING BLANKS in one variable and the remaining fields in another variable.. and then concatenate the two fields.

Reward if helpful.

Regards.

11 REPLIES 11

Former Member
0 Kudos

Hi,

Check the below code...

CONCATENATE <fld1> <fld2> ..... INTO <target field>

SEPARATED BY SPACE.

Cheers,

Bujji

0 Kudos

I want the field length for werks as it is.

If werks value is 2 fields length then the remaining two spaces should be there.

I dont want the fields seperated by space

SantoshKallem
Active Contributor
0 Kudos

first concatenate matnr werks into some variable with out space.

then concatenate variable and lgort into target field with space.

regards.

santhosh reddy

Former Member
0 Kudos

Hi,

Use the Respecting blanks addition with concatenate statement............


data : l_matnr type matnr_d VALUE '000000000000123456',
       l_werks TYPE werks_d VALUE ' 20 ',
       l_lgort type lgort_d VALUE 'fg',
       l_word  TYPE string.

CONCATENATE l_matnr l_werks l_lgort into l_word RESPECTING BLANKS .
write l_word.

Cheers,

jose

Former Member
0 Kudos

Hi,

Try this

DATA: l_value(50) TYPE c.

CONCATENATE itab-matnr itab-werks itab-lgort INTO l_value SEPERATED BY SPACE.

This will solve ur problem.

0 Kudos

Respecting blanks will give spaces to all three fields, but i want only for werks.

Former Member
0 Kudos

hi use the fm STRING_CONCATENATE for this,

reward points if useful,

venkat.

Former Member
0 Kudos

Hi,

Concatenate the fields until WERKS using RESPECTING BLANKS in one variable and the remaining fields in another variable.. and then concatenate the two fields.

Reward if helpful.

Regards.

Former Member
0 Kudos

Hi

concatenate matnr werks into result .

concatenate result lgort into finalresult separated by space.

write:/ finalresult.

Former Member
0 Kudos

HI,

TYPES: BEGIN OF ITAB,

MATNR LIKE MARA-MATNR,

MEINS LIKE MARA-MEINS,

MTART LIKE MARA-MTART,

END OF ITAB.

DATA: C1(40),

C2(40),

IT TYPE ITAB.

SELECT MATNR MEINS MTART FROM MARA INTO IT UP TO 1 ROWS.

WRITE: IT-MATNR, IT-MEINS, IT-MTART.

CONCATENATE IT-MATNR IT-MEINS INTO C1 RESPECTING BLANKS.

CONCATENATE C1 IT-MTART INTO C2.

WRITE:/ C1.

WRITE:/ C2.

ENDSELECT.

REWARD POINTS IF USEFUL.

THANKS.

ARUNPRASAD.P

Edited by: arunprasad palaniswamy on Mar 4, 2008 9:44 AM

Former Member
0 Kudos

Hi,

CONCATENATE

Concatenates (chains) several strings to a string.

Syntax

CONCATENATE <c1>... <cn> INTO <c> [ SEPARATED BY <s> ]

[IN BYTE MODE|IN CHARACTER MODE].

This statement concatenates the strings <c1> to <cn> and assigns the result to <c>. The addition SEPARATED BY <s> allows you to specify a character field <s> which is placed in its defined length between the individual fields. In Unicode programs, you must specify whether the statement is a character or byte operation, using the IN BYTE MODE or IN CHARACTER MODE (default) additions

Regards,

Priya.