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
1,851

I have 3 fields in table p0021 (FAMSA, FANAM and FAVOR). I need concatenate this tree fields ins one string, igual this example

v_string = '   1FERREIRA                               MARCOS', but, when I concatena with comand

CONCATENATE p2001-famsa p2001-fanam p2001-favor INTO v_string, the result is

v_string = '1FERREIRAMARCOS'.

How to solve this problem? I work in version 4.6C of SAP.

Tks,

Marcos Ferreira

Edited by: Marcos Abreu Ferreira on Dec 12, 2008 6:57 PM

I have 3 fields in table p0021 (FAMSA, FANAM and FAVOR). I need concatenate this tree fields ins one string, igual this example

v_string = '   1FERREIRA                               MARCOS', but, when I concatena with comand

CONCATENATE p2001-famsa p2001-fanam p2001-favor INTO v_string, the result is

v_string = '1FERREIRAMARCOS'.

How to solve this problem? I work in version 4.6C of SAP.

Tks,

Marcos Ferreira

Edited by: Marcos Abreu Ferreira on Dec 12, 2008 6:57 PM

15 REPLIES 15
Read only

Former Member
0 Likes
1,680

Use Respective blanks with Concatenate

REPORT test.

data:field1 type char15 VALUE 'Amit',
      field2  type char15 VALUE 'Gujargoud',
result type char30 .
CONCATENATE field1 field2 INTO result RESPECTING BLANKS.
write result.

Read only

0 Likes
1,680

If the below command is not supported :

CONCATENATE field1 field2 INTO result RESPECTING BLANKS.

then you may want to use

CONCATENATE field1 field2 INTO result separated by SPACE .

Here instead of space , you can use a varaible and introduce multiple spaces .

Read only

0 Likes
1,680

RESPECTING BLANKS don´t exists in 4.6C.

Read only

0 Likes
1,680
CONCATENATE field1 field2 INTO result SEPARATED BY space.

This Is SAP help(F1) Example from 4.6

REPORT test.

DATA: ONE(10)   VALUE 'John',
      TWO(3)    VALUE 'F.',
      THREE(10) VALUE 'Kennedy',
      NAME(20).
CONCATENATE ONE TWO THREE INTO NAME SEPARATED BY SPACE.
write name.

Read only

0 Likes
1,680

The field has 40 positions eacch, I need 40-len(field) spaces between fields. This is the correctly result

'   1FERREIRA                               MARCOS                                  '

Edited by: Marcos Abreu Ferreira on Dec 12, 2008 7:21 PM

Read only

0 Likes
1,680
REPORT test.

DATA: ONE(10)   VALUE 'John',
      TWO(3)    VALUE 'F.',
      THREE(10) VALUE 'Kennedy',
      NAME(150),
      blank(40) .
CONCATENATE ONE TWO THREE INTO NAME SEPARATED BY blank.
write name.
Read only

0 Likes
1,680

try to use OFFSETTING, but before that, u need to find out the correct SPACE positions in each field........dont use constant values for offsetting,meaning, it shuld b variable, like offsettest+x(y).

At the same point of secong, me and JAY was posted!! i did not see his reply, bfor am starting to write!!

thanq

Edited by: SAP ABAPer on Dec 12, 2008 7:26 PM

Read only

0 Likes
1,680

DATA: ONE(10) VALUE 'John',

TWO(3) VALUE 'F.',

THREE(10) VALUE 'Kennedy',

NAME(100),

blank(40) .

CONCATENATE ONE TWO THREE INTO NAME SEPARATED BY blank.

write name.

ONE has 4 caracteres, I need 36 spaces. THREE has 7 caracters, I need 33 spaces. That is the problem...

Read only

0 Likes
1,680

Hi,

Before you concatenate the string, fill the empty blanks with a dummy character say * or #. Use replace SPACE with # statment.

Sam########...

Mills############...

Then concatenate the 3 fields into the string.

Sam########...Mills############...

Then again replace the special characte with SPACE. so that you will get the desired result.

Sam ....Mills ....

regards,

Advait

regards,

Advait

Read only

0 Likes
1,680

Okay Than User Coversion Exit Before Concatenating.

Read only

0 Likes
1,680

Hi check the solution I posted.. that should solve ur issue, which will respect the spaces..

use strlen command to find the string length..

data: lv_len(2) type i.

lv_len = strlen( p_wa-field ).

Read only

0 Likes
1,680

Try this way


types : begin of t_string.
data :  famsa like p0021-FAMSA, 
        FANAM like p0021-fanam,
        FAVOR like p0021-favor.
types : end of t_string.

data : wa_string type t_string.
move : p0021-famsa to wa_string-famsa,
       p0021-fanam to wa_string-fanam,
       p0021-favor to wa_string-favor.

move wa_string to v_string.

Read only

0 Likes
1,680

ONE has 4 caracteres, I need 36 spaces. THREE has 7 caracters, I need 33 spaces. That is the problem...

Make a structure having all the fields with the length of 40

types :

begin of name,

fname(40) type c,

mname(40) type c,

lname(40) type c,

end of name.

Now if you move the respective fields to fname, mname and lname, each of the field will have a length of 40 with required blanks.

Then use the above logic of replacing the space with * or # and so on.

regards,

Advait

Edited by: Advait Gode on Dec 12, 2008 7:32 PM

Read only

former_member156446
Active Contributor
0 Likes
1,680

v_string = ' 1FERREIRA MARCOS', but, when I concatena with comand

CONCATENATE p2001-famsa p2001-fanam p2001-favor INTO v_string, the result is

v_string = '1FERREIRAMARCOS'.

you can try this:

V_string+0(12) = p2001-famsa

V_string+13(40) = p2001-fanam   "check the field length and then use 40 or **

v_string+54(40) =  p2001-favor

Read only

0 Likes
1,680

perfect J@Y

tks