This Function will convert a numeric value into Word..
--------------------------------------------------------
You need to pass the numberic valueas a Parameter..
and it will return a words
CREATE OR REPLACE FUNCTION APPS.num_to_word (val_in IN NUMBER)
RETURN VARCHAR2
IS
word VARCHAR2 (140);
char_in VARCHAR2 (5);
val_now NUMBER;
num NUMBER;
unit NUMBER;
pos NUMBER;
npos NUMBER;
nxt NUMBER;
both VARCHAR2 (1);
BEGIN
pos := 1;
val_now := val_in;
word := ' Only';
LOOP
EXIT WHEN nxt = 0;
IF pos = 1
THEN
nxt := TRUNC (val_now);
/* message(to_char(nxt),acknowledge);
pause; */
num := (val_now - nxt) * 100;
/* message(to_char(num),acknowledge);
pause; */
ELSIF ( (pos = 3) OR (pos = 7))
THEN
num := (val_now) MOD (10);
nxt := (val_now - num) / 10;
ELSE
num := (val_now) MOD (100);
nxt := (val_now - num) / 100;
END IF;
IF (num > 19)
THEN
unit := (num) MOD (10);
/* message('unit : '||to_char(unit),acknowledge);
pause; */
num := (num - unit) / 10;
/* message('num : '||to_char(num),acknowledge);
pause; */
ELSE
unit := num;
num := 0;
END IF;
npos := pos;
IF (nxt > 0)
THEN
pos := pos + 1;
val_now := nxt;
END IF;
IF ( (num != 0) AND (unit != 0))
THEN
both := '-';
ELSE
both := '';
END IF;
IF ( (num != 0) OR (unit != 0) OR (npos = 6))
THEN
IF npos = 1
THEN
WORD :=
return_tens (num)
|| both
|| return_unit (unit)
|| 'Paise '
|| word;
IF (nxt > 0)
THEN
WORD := 'And ' || WORD;
END IF;
ELSIF npos = 2
THEN
WORD := return_tens (num) || both || return_unit (unit) || word;
ELSIF npos = 3
THEN
WORD :=
return_tens (num)
|| both
|| return_unit (unit)
|| 'Hundred '
|| word;
ELSIF npos = 4
THEN
WORD :=
return_tens (num)
|| both
|| return_unit (unit)
|| 'Thousand '
|| word;
ELSIF npos = 5
THEN
WORD :=
return_tens (num)
|| both
|| return_unit (unit)
|| 'Lakh '
|| word;
ELSIF npos = 6
THEN
WORD :=
return_tens (num)
|| both
|| return_unit (unit)
|| 'Crore '
|| word;
ELSIF npos = 7
THEN
WORD :=
return_tens (num)
|| both
|| return_unit (unit)
|| 'Hundred '
|| word;
END IF;
END IF;
END LOOP;
IF npos > 1
THEN
word := word;
END IF;
RETURN (word);
END;
---------------------------------------------------------------------------------
In the above function i have used two more functions
for ten and units
Function for Returning Tens
--------------------------------
CREATE OR REPLACE FUNCTION APPS.return_tens (val_in in number) RETURN VARCHAR2 AUTHID CURRENT_USER IS
char_in varchar2(5);
char_out varchar2(12);
BEGIN
char_in := to_char(val_in);
if char_in = '0'
then
char_out := '';
elsif char_in = '1'
then
char_out := '';
elsif char_in = '2'
then
char_out := 'Twenty';
elsif char_in = '3'
then
char_out := 'Thirty';
elsif char_in = '4'
then
char_out := 'Forty';
elsif char_in = '5'
then
char_out := 'Fifty';
elsif char_in = '6'
then
char_out := 'Sixty';
elsif char_in = '7'
then
char_out := 'Seventy';
elsif char_in = '8'
then
char_out := 'Eighty';
elsif char_in = '9'
then
char_out := 'Ninety';
else
char_out := 'none';
end if;
return (char_out);
END;
The Fucntion for Returing Units
----------------------------------------
CREATE OR REPLACE function APPS.return_unit (val_in in number) RETURN varchar2 AUTHID CURRENT_USER IS
char_in varchar2(5);
char_out varchar2(12);
BEGIN
char_in := to_char(val_in);
if char_in = '0'
then
char_out := ' ';
elsif char_in = '1'
then
char_out := 'One ';
elsif char_in = '2'
then
char_out := 'Two ';
elsif char_in = '3'
then
char_out := 'Three ';
elsif char_in = '4'
then
char_out := 'Four ';
elsif char_in = '5'
then
char_out := 'Five ';
elsif char_in = '6'
then
char_out := 'Six ';
elsif char_in = '7'
then
char_out := 'Seven ';
elsif char_in = '8'
then
char_out := 'Eight ';
elsif char_in = '9'
then
char_out := 'Nine ';
elsif char_in = '10'
then
char_out := 'Ten ';
elsif char_in = '11'
then
char_out := 'Eleven ';
elsif char_in = '12'
then
char_out := 'Twelve ';
elsif char_in = '13'
then
char_out := 'Thirteen ';
elsif char_in = '14'
then
char_out := 'Fourteen ';
elsif char_in = '15'
then
char_out := 'Fifteen ';
elsif char_in = '16'
then
char_out := 'Sixteen ';
elsif char_in = '17'
then
char_out := 'Seventeen ';
elsif char_in = '18'
then
char_out := 'Eighteen ';
elsif char_in = '19'
then
char_out := 'Nineteen ';
else
char_out := 'none';
end if;
return (char_out);
END;
Subscribe to:
Post Comments (Atom)
Query to Find Receipt Class and its GL Combinition Query
SELECT ARC.NAME ReceiptClass, ARC.CREATION_METHOD_CODE Creation_Mehthod, DECODE (ARC.REMIT_METHOD_CODE, ...
-
GL AND AP GL_CODE_COMBINATIONS AP_INVOICES_ALL code_combination_id = acct_pay_code_combination_id G...
-
Accounts Receivables useful information ACCOUNTS RECEIVABLES: ==================== ACCOUNTING METHOD , ACCRUAL OR CASH : So do you...
-
SELECT hou.name Organization_name, ---------------------- --Customer Information ---------------------- ...
No comments:
Post a Comment