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: 

Function Module for adding Leading Zero's to a specific field

Former Member
0 Kudos

Hi,

Can anyone please provide a Function that will do the following:

1. Take the value of the field

2. Take the field type

3. Output the value of the field with leading zero's.

Anything similar would be very helpful.

Thank You & Best Regards,

John

4 REPLIES 4

RichHeilman
Developer Advocate
Developer Advocate

Sure use the function CONVERSION_EXIT_ALPHA_INPUT, this will add leading zeros to a character based field of any length.



data: lv_c(10) type c value '123'.

call function 'CONVERSION_EXIT_ALPHA_INPUT'
          exporting 
                  input = lv_c
          importing
                 output = lv_c.
write:/ lv_c.

Regards,

Rich Heilman

0 Kudos

Great, that helped a lot! Thanks

former_member156446
Active Contributor
0 Kudos

CONVERSION_EXIT_ALPHA_INPUT will serve ur purpose..

data:

f1 type char10.

f1 = 789.

passing f1 to CONVERSION_EXIT_ALPHA_INPUT will give you output as 0000000789.

sandro2022
Explorer
0 Kudos
data: lv_c(10) type c value '123'.
unpack lv_c TO lv_c.