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

insert decimal

Former Member
0 Likes
3,737

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,056

HI,

Data: Var2 type p decimals 5. 
var1 = 60000567

var2 = var1 / 100000

.

9 REPLIES 9
Read only

Former Member
0 Likes
2,056

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

Read only

Former Member
0 Likes
2,057

HI,

Data: Var2 type p decimals 5. 
var1 = 60000567

var2 = var1 / 100000

.

Read only

former_member156446
Active Contributor
0 Likes
2,056

Hi Try this way:

data: var2 type p decimal 5.

var1 = 60000567.

var2 = var1.

write:/ var2.

Read only

Former Member
0 Likes
2,056

Hi

You can declare the variable as follows:

data:

var1 type p decimals 5.

Regards,

Rajani

Read only

Former Member
0 Likes
2,056

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

Read only

Former Member
0 Likes
2,056

Hi Sangeetha

Try this.

DATA:
  VAR2 TYPE P DECIMALS 5.

MOVE VAR1 TO VAR2.

Now do the calculations

Regards

Hareesh Menon

Read only

Former Member
0 Likes
2,056

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

Read only

Former Member
0 Likes
2,056

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.

Read only

keerthy_k
Product and Topic Expert
Product and Topic Expert
0 Likes
2,056

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