Skip to Content
0

Remove Decimal Parts / Alter Code

Jan 18, 2017 at 06:29 AM

60

avatar image

This CReport code results a number into words ,how can i remove the decimal parts from this?If the number is 5678.67 the output should be "Five Thousand six hundred and seventy eight" .

numbervar RmVal:=0; numbervar Amt:=0; numbervar pAmt:=0; stringvar InWords :=""; Amt:= sum({Command.Value}); if Amt > 10000000 then RmVal := truncate(Amt/10000000); if Amt = 10000000 then RmVal := 1; if RmVal = 1 then InWords := InWords + " " + towords(RmVal,0) + " Crore" else if RmVal > 1 then InWords := InWords + " " + towords(RmVal,0) + " Crores"; Amt := Amt - Rmval * 10000000; RmVal :=0; if Amt > 100000 then RmVal := truncate(Amt/100000); if Amt = 100000 then RmVal := 1; if RmVal >=1 then InWords := InWords + " " + towords(RmVal,0) + " Lakhs"; Amt := Amt - Rmval * 100000; RmVal :=0; if Amt > 0 then InWords := InWords + " " + towords(truncate(Amt),0); pAmt := (Amt - truncate(Amt)) * 100; if pAmt > 0 then InWords := Propercase(InWords + " and " + towords(pAmt,0) + " Paisa only") else InWords := propercase(InWords + " Only");

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Sastry Duvvuri Jan 18, 2017 at 04:17 PM
1

Hi

Int(1.22) will display 1.00 , so you can even use int(),

Thanks,

Sastry

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi,

Please be a member in my whatsapp group for SAP Support.

https://chat.whatsapp.com/FbNZK3T4hgHAPQWe3ukEw6

0
Abhilash Kumar
Jan 18, 2017 at 07:30 AM
0

Hi Nabil,

Use the Int() function in your code to get rid of the decimals.

Example:

RmVal := Int(truncate(Amt/10000000));

-Abhilash

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Can u share me the full code?

0
Janos Nagy
Jan 18, 2017 at 04:12 PM
0

Hello

You can use truncate function in Crystal Reports

Truncate(1.999) will return 1 and Truncate(1.22) will return also 1.

Regards,

János

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi,

Please be a member in my whatsapp group for SAP Support

https://chat.whatsapp.com/FbNZK3T4hgHAPQWe3ukEw6

0
Nabil Rashid Jan 19, 2017 at 05:11 AM
0

Hi All ,

Thanks for your answers.I just hide the values that i dont need in the if statement right now it is working.

numbervar RmVal:=0; numbervar Amt:=0; numbervar pAmt:=0; stringvar InWords :=""; Amt:= 567546548.67 ; if Amt > 10000000 then RmVal := truncate(Amt/10000000); if Amt = 10000000 then RmVal := 1; if RmVal = 1 then InWords := InWords + " " + towords(RmVal,0) + " Crore" else if RmVal > 1 then InWords := InWords + " " + towords(RmVal,0) + " Crores"; Amt := Amt - Rmval * 10000000; RmVal :=0; if Amt > 100000 then RmVal := truncate(Amt/100000); if Amt = 100000 then RmVal := 1; if RmVal >=1 then InWords := InWords + " " + towords(RmVal,0) + " Lakhs"; Amt := Amt - Rmval * 100000; RmVal :=0; if Amt > 0 then InWords := InWords + " " + towords(truncate(Amt),0); //pAmt := (Amt - truncate(Amt)) * 100; //if pAmt > 0 then //InWords := Propercase(InWords + " and " + towords(pAmt,0) + " Paisa only") //else InWords := propercase(InWords + " Only");
Share
10 |10000 characters needed characters left characters exceeded