Wednesday 8 June 2011

Crystal Report ( Display Numbers in Indian Currency Format )

The Following are the steps to display the numbers in Indian Currency format :-

Step  1:- Right click on the text object which you want to display in Indian currency format. 


Step  2:- Select  Format object and then click on common 


Step  3:- On the right side of display string click on X2 button.  


Step  4:- Write this code in that 
               Totext({Field Name},"##,##,##,##,##,##,##,##,##,##0.00",2)                 


Step  5:- Click on Save and Close 


Step  6:- OK



The Following are the steps to display the numbers in Indian Currency Words :-



Step  1:-Click on Field explorer and Right click on the Formula Field select New. 

Step  2:- Name the Formula Field and Click OK

Step  3:- Now write the following code

numbervar RmVal:=0; 
numbervar Amt:=0; 
numbervar pAmt:=0; 
stringvar Inwards :=" ";
numbervar totalAmt;
totalAmt := Sum ({Field Name});
Amt := totalAmt;

if Amt >= 10000000 then
    RmVal := truncate(Amt/10000000); 
if RmVal = 1 then 
    Inwards := Inwards + " " + towords(RmVal,0) + " crore" 
else 
    if RmVal > 1 then 
        InWords := Inwards + " " + towords(RmVal,0) + " crores";
Amt := Amt - Rmval * 10000000;

RmVal := 0;
if Amt >= 100000 then 
    RmVal := truncate(Amt/100000); 
if RmVal = 1 then 
    InWords := Inwards + " " + towords(RmVal,0) + " lakh"
Else
    If RmVal > 1 then 
        InWords := Inwards + " " + ToWords(RmVal,0) + " Lakhs";
Amt := Amt - Rmval * 100000;

RmVal := 0;
if Amt >= 1000 then 
    RmVal := truncate(Amt/1000);
if RmVal =1 then 
    Inwords := Inwards + " " + towords(RmVal,0) + "Thousand"
Else
    if RmVal > 1 then 
        InWords := Inwards + " " + towords(RmVal,0) + "thousand ";
Amt := Amt - RmVal * 1000;
        
if Amt > 0 then 
    InWords := Inwards + "  " + towords(truncate(Amt),0);

pAmt := (Amt - truncate(Amt)) * 100;

if pAmt > 0 then 
    InWords := Inwards + " rupees and " + towords(pAmt,0) + " paisa only" 
else 
    InWords := Inwards + " rupees only";

UPPERCASE(Inwards) 

Step  4:- Click on Save and Close             

Step  5:- OK


Done