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

String Manupilation

Former Member
0 Likes
884

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
868

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

8 REPLIES 8
Read only

Former Member
0 Likes
869

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

Read only

0 Likes
868

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

Read only

0 Likes
868

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

Read only

0 Likes
868

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

Read only

0 Likes
868

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

Read only

0 Likes
868

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.

Read only

0 Likes
868

Excellent Perez. It works like a charm.

Thank you all for the response.

D

Read only

Former Member
0 Likes
868

Hi,

It will be populated automatically and if you need to remove you can use the CONDENSE statement.....

Thanks

Yogesh