‎2007 Nov 02 12:42 PM
Hi All,
I have a a char variable with a length of 18. As soon as this variable is populated, i want to fill the remaining lengths with spaces.
Does any1 have an idea how i can accomplish this?
Tks,
Danny
‎2007 Nov 02 12:45 PM
If it is char type...it will automatically fill rest length with space...
u dont need to code for it explicitely..
Reward useful answers,
Regards,
Tejas
‎2007 Nov 02 12:45 PM
If it is char type...it will automatically fill rest length with space...
u dont need to code for it explicitely..
Reward useful answers,
Regards,
Tejas
‎2007 Nov 02 12:55 PM
Hi Tejas,
Let me explain futher what i am trying to do. I am trying make up a key for to read the lock table using FM ENQUEUE_READ. The key is made up of mandt, matnr (18 char), and plant.
Now i can do the above, except when the material number is made up of character. i:e
mandt = 100; matnr=testmaterial; plant=9090; When i concatenated it the result wil be 100testmaterial9090. But on sm12 the key is 100testmaterial 9090. The spaces in between is the remaining character of the length 18.
Tks,
Danny
‎2007 Nov 02 1:02 PM
You can try something like this :
concatenate mandt matnr to lv_key.
length = strlen( matnr ).
length = 18 - length.
do length times.
concatenate lv_key space to lv_key.
enddo.
concatenate lv_key plant to lv_key.
Regards
Nishant
‎2007 Nov 02 1:37 PM
Hi,
Thankx for the response. But the code still does not work correctly. I am getting this result : 050TestMat3091, instead of 050TestMat 3091.
Below is the code that i am using:
data: matnr(18) type c value 'TestMat',
plant type werks_d value '3091',
length type i,
lv_key(22) type c.
CONCATENATE sy-mandt matnr into lv_key.
length = strlen( matnr ).
length = 18 - length.
do length times.
concatenate lv_key space INTO lv_key.
enddo.
concatenate lv_key plant INTO lv_key.
WRITE: lv_key
tks,
D
‎2007 Nov 02 1:53 PM
Hi Danny,
Try this,
data: matnr(18) type c value 'TestMat',
plant type werks_d value '3091',
lv_key type string.
<b>CONCATENATE</b> mandt matnr plat <b>INTO</b> lv_key <b>RESPECTING BLANKS</b>.
Regards,
Amit
Message was edited by:
Amit Kumar
‎2007 Nov 02 2:02 PM
Hi Danny ,
Seems I found solution...check this code..
DATA: matnr(18) TYPE c VALUE 'TestMat',
plant TYPE werks_d VALUE '3091',
length TYPE i.
DATA : pv_key TYPE char22,
lv_key TYPE char26.
DATA : spc TYPE char18.
length = STRLEN( matnr ).
length = 18 - length.
CONCATENATE matnr plant INTO pv_key SEPARATED BY spc+0(length).
CONCATENATE sy-mandt pv_key INTO lv_key.
WRITE: lv_key.
‎2007 Nov 02 2:12 PM
Excellent Perez. It works like a charm.
Thank you all for the response.
D
‎2007 Nov 02 12:48 PM
Hi,
It will be populated automatically and if you need to remove you can use the CONDENSE statement.....
Thanks
Yogesh