‎2009 Mar 09 3:34 AM
Hi Experts,
I have variable var1 and I want to insert a decimal at 5 places to the left from the last digit(unit digit) and do calculations on that. How to do that?
Say for example,
var1 = 60000567
I want the result to be 600.00567 and then do calculations with this variable.
Please let me know how to code for it.
Thanks in advance,
Sangeeta.
‎2009 Mar 09 3:42 AM
HI,
Data: Var2 type p decimals 5.
var1 = 60000567
var2 = var1 / 100000.
‎2009 Mar 09 3:40 AM
Hi,
I dont have sap access to tell exactly but you can do as below...
1) Data: Var2 type p decimals 5.
2) Write: var1 (from your code) decimals 5 to var2.
I am not sure,,, check this.
Regards,
~Satya
Edited by: Satya suresh Donepudi on Mar 8, 2009 10:43 PM
‎2009 Mar 09 3:42 AM
HI,
Data: Var2 type p decimals 5.
var1 = 60000567
var2 = var1 / 100000.
‎2009 Mar 09 3:47 AM
Hi Try this way:
data: var2 type p decimal 5.
var1 = 60000567.
var2 = var1.
write:/ var2.
‎2009 Mar 09 4:07 AM
Hi
You can declare the variable as follows:
data:
var1 type p decimals 5.
Regards,
Rajani
‎2009 Mar 09 4:19 AM
Hi,
This is very simple:
1. Just declare the var1 as type 'P'with decimal as 5
DATA: var1 type p decimal 5.
var1 = 60000567.
write:/ var1. "will display as per your requirement.OR
2.Second approach can be var1 as type char and use concatenate the '.' in this and finally stored it into i type variable:
DATA:var2(9) type c.
var1 type i.
concatenate 600 '.' 00567 into var2.
var1 = var2.Hope this might solve your problem.
Pooja
‎2009 Mar 09 4:29 AM
Hi Sangeetha
Try this.
DATA:
VAR2 TYPE P DECIMALS 5.
MOVE VAR1 TO VAR2.Now do the calculations
Regards
Hareesh Menon
‎2009 Mar 09 4:40 AM
Hi Sangeeta,
here is a sample code meeting the requirement.
data: w_p type p decimals 5,
w_i type i value '10002342'.
w_p = w_i.
w_p = w_p / 100000.
write:/ w_i no-grouping.
write:/ w_p.
o/p: 10002342.
100.02342
Regards,
Mdi.Deeba
‎2009 Mar 09 4:46 AM
Hi..,
Try this code
REPORT ZEXAMPLES.
DATA :VAR2(50),
VAR1 TYPE I.
* PARAMETERS : VAR1 TYPE I.
VAR1 = 234567899.
VAR2 = VAR1 / 100000.
WRITE VAR2.....
U will get the Answer..
Regards,
Abaper.
‎2009 Mar 09 4:47 AM
Hi Sangeeta,
Pls see the code below..it is working...
REPORT ztest7.
Data: Var2 type p decimals 5,
var1 type i.
var1 = 60000567.
var2 = var1 / 100000.
write:/ var2 .
Keerthi