‎2007 Jan 18 3:30 PM
I need help with concatenating a string. I need to pad a field (material #) to 18 characters.
Here is the code:
No matter what I try, I lose the full length of matnr when I do the concatenation. It drops the trailing spaces.
data: v_tabkey like cdpos-tabkey.
data: v_matnr(18) type c.
move i_ekpo-matnr to v_matnr.
concatenate '010' v_matnr i_ekpo-werks into v_tabkey.
If i_ekpo-matnr = 'PET'. I get '010PET0010'. I need '010PET 0010'.
Thanks for any help.
Janet
‎2007 Jan 18 3:33 PM
concatenate '010' v_matnr into v_matnr.
concatenate v_matnr i_ekpo-werks into v_tabkey separated by space.
‎2007 Jan 18 3:33 PM
concatenate '010' v_matnr into v_matnr.
concatenate v_matnr i_ekpo-werks into v_tabkey separated by space.
‎2007 Jan 18 3:40 PM
I need the full 15 spaces after PET to have the material number the full 18 characters.
‎2007 Jan 18 3:45 PM
‎2007 Jan 18 3:47 PM
Hi :
Use :
v_tabkey(3) = '010'
v_tabkey+3(18) = v_matnr.
v_tabkey+21(4) = v_werks.
In this situation you should have the 15 spaces !
Hope this helps,
Erwan
‎2007 Jan 18 4:06 PM
Rich,
Thank you, again.
But I am confused. How does this command find the trailing spaces when the string length command doesn't?
‎2007 Jan 18 4:24 PM
The TRANSLATE statement is simply translating the string, character by character, so where there is a SPACE is it replacing with a '%', this fills the rest of the V_MATNR with a character, then when concatenting, it uses all 18 characters, then you are simply transalating it back afterwards.
Regards,
Rich Heilman
‎2007 Jan 18 4:31 PM
Yep, I understood that. It is just strange that that appears to be the only command that is aware of the spaces.
Thanks again.
‎2007 Jan 18 4:33 PM
‎2007 Jan 18 4:56 PM
‎2007 Jan 18 3:38 PM
Hi,
data: v_tabkey like cdpos-tabkey.
data: v_matnr(18) type c.
move i_ekpo-matnr to v_matnr.
<b>
***********************************
Here you need to conver the material no conversion from External to Internal.use the Function module CONVERT_FIELD_TO_INTERN_FORMAT for that matrial field
************************************</b>
concatenate '010' v_matnr i_ekpo-werks into v_tabkey.
If i_ekpo-matnr = 'PET'. I get '010PET0010'. I need '010PET 0010'.
‎2007 Jan 18 3:51 PM
This didn't help. I still got a field back with a length of 3.
‎2007 Jan 18 3:54 PM
‎2007 Jan 18 3:56 PM
Hi Janet,
Please give the result needed ( v_tabkey ) with the actual example plz, because I don't understand...
‎2007 Jan 18 3:57 PM
Hi,
Use this,
concatenate '010' v_matnr space i_ekpo-werks into v_tabkey.
Regards,
Aman