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: 

How to add leading zeros ?

Former Member
0 Kudos

Hi Friends,

I have a shipment no say 10 char long . Now the thing is in my program I need to add leading zeros if the shipment no is not 10 char long .

For eg : if the tknum is 99919 . I need to make use of a command to make it 10 char long lke 0000099919.

Also I need to be able to add zeros if tkum is 5 or 7 or 8 char long .

How do i add these leading zeros to fill up the remaining positions ?

Thanks,

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Use the function.


data: tknum type vttk-tknum value '99156'.

call function 'CONVERSION_EXIT_ALPHA_INPUT'
     exporting
          input  = tknum
     importing
          output = tknum.

Regards,

Rich Heilman

5 REPLIES 5

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try FM CONVERSION_EXIT_ALPHA_INPUT.

Regards,

Ferry Lianto

Former Member
0 Kudos

hi ,

use the following code.

data : lv_vbeln(10) type c.

lv_sonumber like vbak-vbeln.

<b>This function module will convert the data into the required format based on the data type of the variable that you are passing in import paramter of the funcation module.</b>

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = lv_vbeln

IMPORTING

OUTPUT = lv_sonumber

Thanks

mahesh

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Use the function.


data: tknum type vttk-tknum value '99156'.

call function 'CONVERSION_EXIT_ALPHA_INPUT'
     exporting
          input  = tknum
     importing
          output = tknum.

Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Or.....




data: tknum type vttk-tknum value '99156'.


unpack tknum to tknum.

Regards

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Or.....




data: tknum type vttk-tknum value '99156'.
data: n(10) type n.

n = tknum.
tknum = n.


Regards,

Rich Heilman