create or replace function amtinwords (numinput number) return char is
LvInput Number(16,2);
Output Varchar2(600);
LvOutput Varchar2(600);
Paise Number(2);
Ps Varchar2(30);
Thous Number(6);
Ths VarChar2(200);
Lakhs Number(2);
Ls VarChar2(30);
Crores Number(6);
Cs VarChar2(200);
--If Amount is Negative set the flag to 'T'
NegAmt varchar2(1):='F';
BEGIN
Output := ' Only';
--LvInput := :CF_GRAND_TOTAL;
LvInput := NUMINPUT;
IF LvInput < 0 then
LvInput:=ABS(LvInput);
NegAmt:='T';
ELSE
NegAmt:='F';
END IF;
LvInput := LvInput*100;
Paise := MOD(LvInput,100);
dbms_output.put_line('Paise:' ||paise);
IF Paise != 0 THEN
SELECT TO_CHAR(TO_DATE(Paise,'J'),' Jsp') INTO Ps FROM Dual;
Output := 'Rupee '||LTRIM(RTRIM(Ps))||' Paise '||OutPut;
END IF;
LvInput := TRUNC(LvInput/100);
Thous := MOD(LvInput,100000);
IF Thous != 0 THEN
SELECT TO_CHAR(TO_DATE(Thous,'J'),' Jsp')INTO Ths FROM Dual;
Output := LTRIM(RTRIM(Ths))||' '||OutPut;
END IF;
LvInput := TRUNC(LvInput/100000);
Lakhs := MOD(LvInput,100);
IF Lakhs != 0 THEN
SELECT TO_CHAR(TO_DATE(Lakhs,'J'),' Jsp')INTO Ls FROM Dual;
Output := LTRIM(RTRIM(Ls))||' Lakh '||OutPut;
END IF;
LvInput := TRUNC(LvInput/100);
Crores := MOD(LvInput,100000);
IF Crores !=0 THEN
SELECT TO_CHAR(TO_DATE(Crores,'J'),' Jsp')INTO Cs FROM Dual;
Output := LTRIM(RTRIM(Cs))||' Crore '||OutPut;
END IF;
IF NegAmt='T' THEN
-- <> Indicates Negative Amount
RETURN(REPLACE(Output,'-',' ')||'>');
ELSE
RETURN(REPLACE(Output,'-',' '));
END IF;
end;
No comments:
Post a Comment