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

Variable to be declared when calculating ratio.

Former Member
0 Likes
1,567

Hi ABAP Experts,

I need to calculate ratio of the following:

Lv_Ratio = lv_var1 / lv_var2.

Note: TYPE of lv_var1 and lv_var2 = Currency, Length 13, Dec 2.

I would like to know, what 'TYPE' should the variable lv_ratio be declared?

Thanks a lot in advance.

Best regards,

TM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,369

Use type P with DECIMALS.

6 REPLIES 6
Read only

Former Member
0 Likes
1,370

Use type P with DECIMALS.

Read only

former_member222860
Active Contributor
0 Likes
1,369
data: lv_ratio type p decimals 2.
Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
1,369

Refer this:

data: l1 type glt0-tslvt,

l2 type glt0-tslvt,

l3 type glt0-tslvt.

l1 = '19.02'.

l2 = '12.05'.

l3 = l1 / l2.

Read only

Former Member
0 Likes
1,369

Hi,

surely you want the ration value to be in decimal as the two variables can be in decimals so bettre to declare the variable as P with decimal 2 to capture the decimal part also.

Pooja

Read only

Former Member
0 Likes
1,369

Hi,

Declare data like this

data: lv_ratio type p decimals 2

Regards,

Jyothi CH.

Read only

Former Member
0 Likes
1,369

Thanks a lot for the feedback. It'll be Type p Decimals 2