Application Development 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: 

adding leading zeroes

Former Member
0 Kudos

Hi i have a variable of type packed decimal whose value is 1.1. I move this value into a variable of type char length 6 and when i display, it displays 1.1, i want it to be displayed as 0001.1 How can i do that?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

Pass the decimal value to variable quant type char6

quan1 type char4

quan2 type char2.

split quan at '.' into quan1 quan2.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = quan1

IMPORTING

OUTPUT = quan1.

concatenate quan1 quan2 into quant separated by '.'.

This should solve it

Message was edited by: Dominic Pappaly

6 REPLIES 6

Former Member
0 Kudos

Hi Kantheri,

<b>Use TYPE N variable and assign packed decimals value to this.</b>

DATA V_PDEC TYPE P DECIMALS 1 VALUE '1.1'.

DATA V_LNUM(4) TYPE N.

V_LNUM = V_PDEC.

WRITE:/ V_LNUM. <b>--->0001</b>

Thanks,

Vinay

0 Kudos

Hi ,

you can use his FM

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = lv_var

IMPORTING

OUTPUT = lv_var

.

Regards,

Sumit.

Simha_
Employee
Employee
0 Kudos

Hi,

Use the F.M <b>CONVERSION_EXIT_ALPHA_INPUT</b>

cheers,

Simha.

Former Member
0 Kudos

use <b> type n</b> instead of char.

Former Member
0 Kudos

Hi

Pass the decimal value to variable quant type char6

quan1 type char4

quan2 type char2.

split quan at '.' into quan1 quan2.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = quan1

IMPORTING

OUTPUT = quan1.

concatenate quan1 quan2 into quant separated by '.'.

This should solve it

Message was edited by: Dominic Pappaly

former_member502730
Participant
0 Kudos

HI,

USE THE FUNCTION MODULE 'CONVERSION_EXIT_ALPHA_INPUT'

DHARMESH