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: 

convert character type to p type

Former Member
0 Kudos

hello,

I'm trying to convert character(32) to type p decimals 3, unfortunately I don't get it good . for example 16.5 i get 1.65.

thanks,

Michal

4 REPLIES 4

Former Member
0 Kudos

Hi,

data: bqty type p decimals 3

w_bqty like cowb_comp-erfmg.

if bqty value = '100.5'.

or

data: bqty(10) value '101.1',

w_bqty(10) type p decimals 1.

w_bqty = bqty.

write: w_bqty.

Regards

Former Member
0 Kudos

Hi..

check it plz..

<b>data: w_pack type p decimals 3.

data: w_char(32) type c.

w_char = '16.5'.

move w_char to w_pack.

write:/ w_char.

write:/ w_pack.</b>

Output is :

<b><i>16.5

16,500</i></b>

Reward if useful

Regards

Prax

Former Member
0 Kudos

<b>Decimal</b> ->This addition defines the number of displayed decimal places for the output of data objects of data types i, p, or f. For all other data types, the addition is ignored.For dec, a data object of type i is expected that contains the number of required decimal places. If the content of dec is less than 0, it is treated as 0, whereby the content of data objects of data types i or p is previously multiplied by 10 to the power of dec. For the individual numeric data types, the following applies.....


Example  : 1
The output for the WRITE statement is "1234,57". 

DATA pack TYPE p LENGTH 8 DECIMALS 4 VALUE '1234.5678'. 
WRITE pack NO-GROUPING DECIMALS 2. 

Example  : 2
The output of the WRITE statement is "123456,7800". 

DATA pack TYPE p VALUE '12345678'. 
WRITE pack NO-GROUPING ROUND 2 DECIMALS 4. 


Example  : 3
If no decimal places are specified for the number "PC" in T006, the output of the WRITE statement is "1234". 

DATA pack TYPE p DECIMALS 4 VALUE '1234.0000'. 
WRITE pack NO-GROUPING UNIT 'PC'. 


reward points if it is usefull....

Girish

former_member235056
Active Contributor
0 Kudos

Hi,

Its damp easy,

Since by default packed numbers take decimals upto two u need to specify the character formatted number 16.5 as 16.50.

In short,

C -


P

16.5------1.65

16.50----16.50

Pls check it and let me know.

pls reward points if it works.

Regards,

Ameet