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: 

How shd i convert 30.00 to 15 char 000000000030.00 ?

Former Member
0 Kudos

Hi guys,

i have a requirement to convert variable packed decimal 30.00 to 15 char 000000000030.00 ?

Is there any std FM or i will have to manually prefix Zero's in variable.

1 ACCEPTED SOLUTION

varma_narayana
Active Contributor
0 Kudos

Hi..

Use this code.

Write v_pack to v_char right-justified.

REPLACE ALL OCCURRENCES OF SPACE WITH '0' INTO V_CHAR.

<b>Reward if Helpful</b>

10 REPLIES 10

Former Member
0 Kudos

Hi,

You can try func. mod.

CONVERSION_EXIT_ALPHA_INPUT

Ashvender

0 Kudos

Not possible using the FM ALPHA_INPUT

0 Kudos

UNPACK v_int to v_char15.

Regards,

Amit

Reward all hepful replies.

Former Member
0 Kudos

Hi

for decimal ponts this fm is not possible (CONVERSION_EXIT_ALPHA_INPUT

)

so do one thing split str at '.' into var1 and var2.

and pass var1 to CONVERSION_EXIT_ALPHA_INPUT

and again concatenate

it will work

reward points to all helpful answers

kiran.M

0 Kudos

UNPACK v_int to v_char15. -- > Removes the decimal point form the string which should not happen.

0 Kudos

If there is are all zeroes after decimal CHAr will remove it. you need to explicitly place it.

Former Member
0 Kudos

Conversion exit ALPHA, external->internal

ALPHA conversion is used especially with account numbers. During conversion from the external to the internal format, the system checks to see if input in the INPUT field is purely numeric, that is, if this input consists only of numbers, possibly with spaces before and after them. If this is the case, then the number string is inserted right- justified in the display field OUTPUT and all spaces to the left of the value are filled with zeroes ('0'). If the input is not purely numeric, it is inserted in the display field from left to right and all extra spaces are filled with blanks.

Example:

(Input field and output field are both eight characters in length)

1. '1234 ' --> '00001234'

2. 'ABCD ' --> 'ABCD '

3. ' 1234 ' --> '00001234'

Conversion from the internal to the external format (function module CONVERSION_EXIT_ALPHA_OUTPUT) is undertaken in exactly the opposite manner.

Usage:

call function 'CONVERSION_EXIT_ALPHA_INPUT'

exporting

input = v_input

importing

output = v_output

exceptions

others = 1.

CONVERSION_EXIT_ALPHA_INPUT - converts any number into a string fill with zeroes-right

example:

input = 30.00

output = 000000000030.00

regards,

srinivas

<b>*reward for useful answers*</b>

varma_narayana
Active Contributor
0 Kudos

Hi..

Use this code.

Write v_pack to v_char right-justified.

REPLACE ALL OCCURRENCES OF SPACE WITH '0' INTO V_CHAR.

<b>Reward if Helpful</b>

Former Member
0 Kudos

Split like Kiran says or use OVERLAY with '000000000000000'

Former Member
0 Kudos

Hi,

Use FM <b>CONVERSION_EXIT_ALPHA_INPUT</b>

Reward if helpful.