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

Padding Zeros

Former Member
0 Likes
558

I know there are a lot of threads that talk about padding zeros, but I could not find the solution to my prolem by seraching threads.

Here it is ... how do convert below ...

123.99 to 0123.99

23.99 to 0023.99

2.99 to 0002.99

I want that single statement to dynamically pad zeros before the numbers, can MASK EDIT do it? or CONVERSION_EXIT_ALPHA_INPUT, or do I need to use SHIFT statement or something else?

Please suggest, a small code snippet would be greatly appreciated!

Thanks,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
485

Hi,

You can use function module 'HRPBSNO_FORMAT_ZERO' for adding zeros to left.

Data: pfield1 TYPE p DECIMALS 2 VALUE '123.99',

cfield1(20) type c.

cfield1 = pfield1.

CALL FUNCTION 'HRPBSNO_FORMAT_ZERO'

EXPORTING

left = '4'

right = '2'

in_separator = ' '

out_separator = '.'

CHANGING

str = cfield1.

Hope this helps,

2 REPLIES 2
Read only

Former Member
0 Likes
486

Hi,

You can use function module 'HRPBSNO_FORMAT_ZERO' for adding zeros to left.

Data: pfield1 TYPE p DECIMALS 2 VALUE '123.99',

cfield1(20) type c.

cfield1 = pfield1.

CALL FUNCTION 'HRPBSNO_FORMAT_ZERO'

EXPORTING

left = '4'

right = '2'

in_separator = ' '

out_separator = '.'

CHANGING

str = cfield1.

Hope this helps,

Read only

Clemenss
Active Contributor
0 Likes
485

Hi Frozen Monkey,

use WRITE, press F1m check USING EDIT MASK option.

Regards,

Clemens