2006 Oct 06 4:56 PM
Hi,
I have an issue in which there is a decimal like suppose 17.34
I get this from a file .. when i have to get it into an internal table it should look like
000000017340000.
Which means it should be divided into 9 and 6
Currently am taking
pamt1(9) TYPE p DECIMALS 6 ,
but this will not fill it up with zeros.
Can some one suggest something
Thanks in advance,
Prince
2006 Oct 06 5:04 PM
If you need to fill with zeros, then you can not use a type P field. You must use a character field. So you can do something like this.
data: c9(9) type c,
c6(6) type c,
c15(15) type c.
data: input type string.
input = '17.34'.
split input at '.' into c9 c6.
shift c9 right deleting trailing space.
translate c9 using ' 0'.
shift c6 left deleting leading space.
translate c6 using ' 0'.
concatenate c9 c6 into c15.
write:/ c15.
Welcome to SDN!.
Regards,
Rich Heilman
Hi Price,
Welcome to SDN................
Move your character values into numeric values. As numeric values will have 0s by default but for characters this will be spaces.
Try as folllows.
DATA p_pamt1(15).
DATA pn_numeric(9) TYPE n.
DATA pn_decimal(6) TYPE n.
DATA pc_numeric(9) TYPE c.
DATA pc_decimal(6) TYPE c.
START-OF-SELECTION.
p_pamt1 = '17.34'.
SPLIT p_pamt1 AT '.' INTO pc_numeric pc_decimal.
pn_numeric = pc_numeric.
pn_decimal = pc_decimal.
CONCATENATE pn_numeric pn_decimal INTO p_pamt1.
Thanks,
Vinay
2006 Oct 06 5:02 PM
Hi Price,
Welcome to SDN................
Move your character values into numeric values. As numeric values will have 0s by default but for characters this will be spaces.
Try as folllows.
DATA p_pamt1(15).
DATA pn_numeric(9) TYPE n.
DATA pn_decimal(6) TYPE n.
DATA pc_numeric(9) TYPE c.
DATA pc_decimal(6) TYPE c.
START-OF-SELECTION.
p_pamt1 = '17.34'.
SPLIT p_pamt1 AT '.' INTO pc_numeric pc_decimal.
pn_numeric = pc_numeric.
pn_decimal = pc_decimal.
CONCATENATE pn_numeric pn_decimal INTO p_pamt1.
Thanks,
Vinay
2006 Oct 06 5:03 PM
HI,
follow below logic
data v_data(15) type n.
v_data = 17.34 * 100*10000.
Regards
amole
2006 Oct 06 5:04 PM
If you need to fill with zeros, then you can not use a type P field. You must use a character field. So you can do something like this.
data: c9(9) type c,
c6(6) type c,
c15(15) type c.
data: input type string.
input = '17.34'.
split input at '.' into c9 c6.
shift c9 right deleting trailing space.
translate c9 using ' 0'.
shift c6 left deleting leading space.
translate c6 using ' 0'.
concatenate c9 c6 into c15.
write:/ c15.
Welcome to SDN!.
Regards,
Rich Heilman
2006 Oct 06 5:14 PM
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |