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: 

count number of digits..........in a number

anupam_srivastava2
Participant
0 Kudos

Hi all

is there any function which outputs the number of digits.

I have a validation to do, where if user enters any figure, I have to make it to four.

say if he enters 1, then it should be 0001, if he enters 10 then it should be 0010

cheers

AJ

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

Use this funtion module

CONVERSION_EXIT_ALPHA_INPUT

depending upon the length of your output variable it will give you number of zeros infornt of the number you entered

Regards

Kiran.

4 REPLIES 4

Former Member
0 Kudos

Hi

If your input/output field is type N, u'll have what you need automatically.

PARAMETER: P_NUM(4) TYPE N.

Max

Former Member
0 Kudos

Hi

Use this funtion module

CONVERSION_EXIT_ALPHA_INPUT

depending upon the length of your output variable it will give you number of zeros infornt of the number you entered

Regards

Kiran.

Former Member
0 Kudos

U can use FMs

CONVESRION_EXIT_ALPHA-INPUT

CONVESRION_EXIT_ALPHA-OUTPUT

for standard SAP fields.

Else u can use

STRLEN to count and then CONCATENATE to add leading zeros

Narendra

vinod_vemuru2
Active Contributor
0 Kudos

Hi Do like this.

PARAMETERS: po_data(4) TYPE c.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = po_data

IMPORTING

OUTPUT = po_data

.

WRITE po_data.

Thanks,

Vinod.