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

CONVERSION_EXIT_ALPHA_INPUT problem

Former Member
0 Likes
955

Hi,

I am adding leading zeros to a number using the CONVERSION_EXIT_ALPHA_INPUT Function module.

But i am not getting what i require in case of a negative number.

Eg:

I am getting perfectly correct result in case of postive numbers.

input = 1500

output = 00000000001500.

but in case of negative number i am not getting leading zeros appended.

input = 1500-

output = 1500-.

Kindly help me out.

Thanks

5 REPLIES 5
Read only

Former Member
0 Likes
759

This message was moderated.

Read only

vinod_vemuru2
Active Contributor
0 Likes
759

Hi,

Try in this way.


DATA: l_data(8) TYPE c VALUE '-20'

IF l_data LT 0.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    INPUT         = l_data+1
 IMPORTING
   OUTPUT        = l_data+1
          .
ELSE.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    INPUT         = l_data
 IMPORTING
   OUTPUT        = l_data
          .
ENDIF.

This logic assumes u have negative sign as first character when the number is negative

Thanks,

Vinod.

Read only

Former Member
0 Likes
759

Hi,

For which field conversion function module you are using.

I mean whether you are using for material number, vbeln..like for which field you are searching converision ?

I searched so many function modules .buit nothing padding zero's infront og negative number..

Thanks

Parvathi

Read only

Former Member
0 Likes
759

Hi MANPREET,

that's the normal behavior of ALPHA conversion. The minus sign is considered a character.

This function is used to convert characteristics, not numbers. You can define a new conversion rule or you can do something like:


  output = input.
  SHIFT output RIGHT DELETING TRAILING space.
  OVERLAY output WITH '00000000000000000000000000000000000000000000000000000000'.

Read only

former_member156446
Active Contributor
0 Likes
759

Messy

DATA: l_data(8) TYPE c VALUE '20-',
value TYPE char2 VALUE '-1'.

l_data =  l_data * value.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
  EXPORTING
    input  = l_data
  IMPORTING
    output = l_data.

CONCATENATE value+0(1) l_data+1(7) INTO l_data.

WRITE: l_data.