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

add leading zeros

mark_fryu
Participant
0 Likes
1,438

I need to add zeros based on the length of the field, this I have to do for all the fields in the table,

I am using the CONVERSION_EXIT_ALPHA_INPUT fm but I have to pass one field at a time and call the fm multiple times.

there is a better way and faster?

I need to add zeros based on the length of the field, this I have to do for all the fields in the table,

I am using the CONVERSION_EXIT_ALPHA_INPUT fm but I have to pass one field at a time and call the fm multiple times.

there is a better way and faster?

3 REPLIES 3
Read only

Sandra_Rossi
Active Contributor
1,248

Simple: no.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,248

Maybe you can use the ALPHA addition. Check the SAP documentation

Read only

joltdx
Active Contributor
0 Likes
1,248

Sorry, the data is what the data is.

I don't think there's any way to magically convert from external to internal format, or add leading zeros, to all fields in a table or even a structure.

That old FM works or a string template with the ALPHA = IN addition works as Suhas mentioned.

Maybe through some kind of transformation/conversion and back through either XML or JSON, and using different tables type, but then we're adding unnecessary complexity just for this. I'm happy to be proven wrong but I wouldn't go that way...

If you can control the way you get the data in the first place that might offer some options? Like are you reading it from tables yourself in ABAP then using the right data types would help...

It of course also depends on why you need the data to be in internal format with leading zeros. You don't say so there may be alternative options where it's not needed. Or at least not for all fields. Or at least not all fields at once, but instead when needed. But that depends heavily on the use case.