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: 

how to calculate percentage

Former Member
0 Kudos

hi,

i have requirement below.

i want to calculate 20 percent of wa_ameng .and if wa_menge value is more than 20 percent of wa_ameng then i will capture that value to another varibale.how to write the code please help me

data:wa_ameng type i,

wa_menge type i,

wa_percent type i.

*DATA: BEGIN OF xe1edp10.

  • INCLUDE STRUCTURE e1edp10.

*DATA: END OF xe1edp10.

*

LOOP AT dint_edidd

WHERE segnam EQ 'E1EDP10'.

CLEAR xe1edp10.

MOVE dint_edidd-sdata TO xe1edp10.

loop at DEKEH .

move dekeh-ameng to wa_ameng.

move dekeh-menge to wa_menge.

endloop.

ENDLOOP.

3 REPLIES 3

sridhar_meesala
Active Contributor
0 Kudos

Hi,

Take the variables of type P with decimals insted of I.

wa_percent  = (20 /100) * wa_amen.
if wa_menge GT wa_percent
 wa_percent1 = wa_percent 
endif.

Thanks,

Sri.

0 Kudos

hi,

thanks.means i declared now

data:wa_ameng type p ,

wa_menge type p,

wa_percent type p,

wa_percent1 type p.

is it ok??

please answer.dont neglect.

0 Kudos

Hi,

Add decimals to it.

data :wa_ameng type p DECIMALS 2,
      wa_menge type p DECIMALS 2 ,
      wa_percent type p DECIMALS 2 ,
      wa_percent1 type p DECIMALS 2 .

Thanks,

Sri.