2008 Dec 12 5:56 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
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...
2008 Dec 12 6:00 PM
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.
2008 Dec 12 6:13 PM
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 .
2008 Dec 12 6:13 PM
2008 Dec 12 6:19 PM
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.
2008 Dec 12 6:20 PM
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
2008 Dec 12 6:23 PM
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.
2008 Dec 12 6:25 PM
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
2008 Dec 12 6:26 PM
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...
2008 Dec 12 6:27 PM
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
2008 Dec 12 6:28 PM
2008 Dec 12 6:28 PM
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 ).
2008 Dec 12 6:31 PM
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.
a®
2008 Dec 12 6:32 PM
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
2008 Dec 12 6:24 PM
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
2008 Dec 12 7:05 PM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |