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

Finding out numeric values and adding zeroes

Former Member
0 Likes
683

hi guys,

I have the following requirement, i have a file which has account numbers which can be numeric as well as char. I have to find out the ones that are numeric only and then since the length should be 10 i need to add zeroes infront to make the length 10. Does anyone have any idea how this can be done??.

Thanks in advance,

David.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
657

Please use CONVERSION_EXIT_ALPHA_INPUT, this will convert your values to internal format, if numeric, it will put the leading zeros, if not numeric, it will not put the zeros.

Regards,

Rich Heilman

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
658

Please use CONVERSION_EXIT_ALPHA_INPUT, this will convert your values to internal format, if numeric, it will put the leading zeros, if not numeric, it will not put the zeros.

Regards,

Rich Heilman

Read only

0 Likes
657

Hi Rich,

I saw that function module the problem is it is adding 100's of zeroes infront, but i need only the total length to be just 10. Neidea what else can be done.

Thanks,

David.

Read only

0 Likes
657

You need to pass your data in a variable which has a length of 10.

data: v_char(10) type c.

v_char = '1234'.

Then pass v_char to the function module. You will then get a value like '0000001234'.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
657

Hi David,

take for instance the len is 8

IF strlen(field) < 10.

MOVE '00' TO field(8).

ELSE.

MOVE field to field.

ENDIF.

Hope this gives you a idea...

Please reward if its helpful...

Leo

Read only

Former Member
0 Likes
657

if ws_num co '0123456789 '.
   condense ws_num.
   shift ws_num right deleting trailing space.
   overlay ws_num with '0000000000'.
endif.