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

Number Conversion

Former Member
0 Likes
620

Hi Friends,

I have defined a varialbe

data: l_amount type wrbtr

I want to pass the value of l_amount to another variable l_pay which is defined as

data: l_pay(15) type c

Now, I want to add zero's before the value of l_pay.

Example:

if

l_amount = 600.50

after passing the value l_pay will contain

l_pay = 600.50

But, I want

l_pay = '000000000600.50'

.

I have tried to use CONVERSION_EXIT_ALPHA_INPUT, but it is not working.

Regards,

Praveen

5 REPLIES 5
Read only

Former Member
0 Likes
601

Calulate the no of digits in l_pay and concatenate 0s in the rest of the places in l_pay to make it 15 digits.

Read only

Former Member
0 Likes
601

CONVERSION_EXIT_ALPHA_INPUT


*
DATA: c1(10) value '100'.
DATA: c2(10).
*
write: / c1.
*
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = C1
IMPORTING
OUTPUT = C2.
*
write: / c2.

Output will be 000000100

If you want to remove zeros then use Fm CONVERSION_EXIT_ALPHA_OUTPUT.

Regards,

Chandru

Read only

0 Likes
601

Hi Prakash,

Thanks for your reply...

But please use the function module CONVERSION_EXIT_ALPHA_INPUT with values with decimals like 100.20. It will not add zero's befor 100.20.

I want output like '000000000100.20'

Regards,

Praveen

Read only

0 Likes
601

Hi,

Use below logic:

DATA: l_amount TYPE wrbtr,

l_pay(15) TYPE c.

l_amount = '600.50'.

l_pay = l_amount.

TRANSLATE l_pay USING ' 0'.

WRITE : / l_pay.

Read only

Former Member
0 Likes
601

Hi

try this.

DATA : I_P(15) TYPE C,

I_AM(15) TYPE C.

I_AM = 600.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = I_AM

IMPORTING

OUTPUT = I_AM.

I_P = I_AM. .

WRITE : I_P.

Thanks&Regards,

Chaithanya.