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

packed decimal auto conversion

Former Member
0 Likes
844

Hi

I have an input field that is of type P , with decimals 3.

so if I enter 3000 , then it will take 3.000 .

I want it to be so ,, when user enters 3 , it automatically converts it to 3.000 and if the user enters 3.2 , then it converts it to 3.200 , .

How can I achieve this.

Thankyou

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
762

Krish,

do like this

parameters: P1(10) type P decimals 3.

but its better to go with

parameters: p1(10) type c. it will take care of everything.

5 REPLIES 5
Read only

Former Member
0 Likes
762

hi Krish,

I use it at a program here like u said:

parameters: P1 type P decimals 3.

write p1.

when we enter a value, for example 3000, it automatically converts to "3.000,000", if enter a value 3 it converts to "3,000" and if enter a value "3,2" it converts to "3,200".

Can you tell me how do u are declaring this input field?

Do you need a "," or a "."?

Regards

Allan Cristian

Read only

0 Likes
762

Hi Allan

I am declaring the field as xyz type P decimals 3 .

It is actualyl an input field for an ALV.

I just want it to be eay for the user , so if he intends to pick 3 , then he only has to give 3 ,, hit enter and the value that automatically converted to 3,000 .

Thankyou

Read only

Former Member
0 Likes
762

Hi,

If you have defined your input field as follows

parameters: text1 type p decimals 3.

then it should work as desired.

Thanks & Regards,

Vanita M.

Read only

Former Member
0 Likes
763

Krish,

do like this

parameters: P1(10) type P decimals 3.

but its better to go with

parameters: p1(10) type c. it will take care of everything.

Read only

Former Member
0 Likes
762

Hi Krish,

I understand what you need, please look this code:

DATA: lenght(2), cont(2), contv(1), teste(1), lenghtv(1).

PARAMETERS: p1(10).

lenght = strlen( p1 ).

cont = 0.

contv = 0.

DO lenght TIMES.

teste = p1+cont(1).

cont = cont + 1.

IF teste = ',' OR teste = '.'.

contv = 1.

lenghtv = lenght - cont.

IF lenghtv = '0'.

CONCATENATE p1 '000' INTO p1.

ELSEIF lenghtv = '1'.

CONCATENATE p1 '00' INTO p1.

ELSEIF lenghtv = '2'.

CONCATENATE p1 '0' INTO p1.

ENDIF.

endif.

ENDDO.

if contv = 0.

CONCATENATE p1 ',000' INTO p1.

endif.

WRITE p1.

Regads

Allan Cristian