Amount in words in indian format

Dear All,
I have refer this link to get amount in words in indian format.but it is showing me error.what i copied in sql is -
*if exists (select * from dbo.sysobjects where id = object_id(N'dbo.AmountToWords') and xtype in (N'FN', N'IF', N'TF')) drop function dbo.AmountToWords GO if exists (select * from dbo.sysobjects where id = object_id(N'dbo.GetTextValue') and xtype in (N'FN', N'IF', N'TF')) drop function dbo.GetTextValue GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO CREATE function AmountToWords ( @InNumber Numeric(18,2) ) --Returns the number as words. returns VARCHAR(2000) as BEGIN --SEt NoCount ON Declare @Num Varchar(20) Declare @Dec Varchar(3) Declare @Return Varchar(2000) Set @Dec = SubString(Convert(Varchar(20),@Innumber),Len(Convert(Varchar(20),@Innumber))-2,3) Set @Num = SubString(Convert(Varchar(20),@Innumber),1, Len(Convert(Varchar(20),@Innumber))-3) Declare @Hundred Char(8) Declare @HundredAnd Char(12) Declare @Thousand Char(9) Declare @Lakh Char(5) Declare @Lakhs Char(6) Declare @Crore Char(6) Declare @Crores Char(7) Set @Hundred = 'Hundred ' Set @Thousand = 'Thousand ' Set @Lakh = 'Lakh ' Set @Lakhs = 'Lakhs ' Set @Crore = 'Crore ' Set @Crores = 'Crores ' Set @HundredAnd = 'Hundred and ' if Len(@Num) = 1 -- One Begin Set @Return = dbo.GetTextValue(@Num) End Else if Len(@Num) = 2 -- Ten Begin Set @Return = dbo.GetTextValue(@Num) End Else if Len(@Num) = 3 -- Hundred Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Hundred IF SubString(@num,2,2) '00' Set @Return = @Return + 'And ' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2)) End Else if Len(@Num) = 4 -- thousand Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Thousand If SubString(@Num,2,1) '0' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,1)) + @Hundred IF SubString(@num,3,2) '00' Set @Return = @Return + 'And ' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2)) End Else if Len(@Num) = 5 -- Ten Thousand Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,2)) + @Thousand If SubString(@Num,3,1) '0' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,1)) + @Hundred IF SubString(@num,4,2) '00' Set @Return = @Return + 'And ' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2)) End Else if Len(@Num) = 6 -- Lakh Begin If SubString(@Num,1,1) = '1' Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Lakh Else Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Lakhs If SubString(@Num,2,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2)) + @Thousand If SubString(@Num,4,1) '0' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,1)) + @Hundred IF SubString(@num,5,2) '00' Set @Return = @Return + 'And ' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2)) End Else if Len(@Num) = 7 -- Ten Lakhs Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,2)) + @Lakhs If SubString(@Num,3,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2)) + @Thousand If SubString(@Num,6,1) '0' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,1)) + @Hundred IF SubString(@num,6,2) '00' Set @Return = @Return + 'And ' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,2)) End Else if Len(@Num) = 8 -- Crore Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Crore If SubString(@Num,2,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2)) + @Lakhs If SubString(@Num,4,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2)) + @Thousand If SubString(@Num,6,1) '0' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,1)) + @Hundred IF SubString(@num,7,2) '00' Set @Return = @Return + 'And ' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,7,2)) End Else if Len(@Num) = 9 -- Ten Crore Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,2)) + @Crores If SubString(@Num,3,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2)) + @Lakhs If SubString(@Num,5,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2)) + @Thousand If SubString(@Num,7,1) '0' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,7,1)) + @Hundred IF SubString(@num,8,2) '00' Set @Return = @Return + 'And ' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,8,2)) End Else if Len(@Num) = 10 -- Hundred Crore Begin Set @Return = dbo.GetTextValue(Substring(@Num,1,1)) + @Hundred IF Substring(@Num,2,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2)) Set @Return = @Return + @Crores If SubString(@Num,4,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2)) + @Lakhs If SubString(@Num,6,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,2)) + @Thousand If SubString(@Num,8,1) '0' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,8,1)) + @Hundred IF SubString(@num,9,2) '00' Set @Return = @Return + 'And ' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,9,2)) End Else if Len(@Num) = 11 -- Thousand Crore Begin Set @Return = dbo.GetTextValue(Substring(@Num,1,1)) + @Thousand IF SubString(@Num,2,1) '0' Set @Return = @Return + dbo.GetTextValue(Substring(@Num,2,1)) + @Hundred IF Substring(@Num,3,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2)) Set @Return = @Return + @Crores If SubString(@Num,5,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2)) + @Lakhs If SubString(@Num,7,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,7,2)) + @Thousand If SubString(@Num,9,1) '0' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,9,1)) + @Hundred IF SubString(@num,10,2) '00' Set @Return = @Return + 'And ' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,10,2)) End Else if Len(@Num) = 12 -- Ten thousand Crore Begin Set @Return = dbo.GetTextValue(Substring(@Num,1,2)) + @Thousand IF SubString(@Num,3,1) '0' Set @Return = @Return + dbo.GetTextValue(Substring(@Num,3,1)) + @Hundred IF Substring(@Num,4,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2)) Set @Return = @Return + @Crores If SubString(@Num,6,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,2)) + @Lakhs If SubString(@Num,8,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,8,2)) + @Thousand If SubString(@Num,10,1) '0' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,10,1)) + @Hundred IF SubString(@num,11,2) '00' Set @Return = @Return + 'And ' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,11,2)) End Else if Len(@Num) = 13 -- Lakh Crore Begin Set @Return = dbo.GetTextValue(Substring(@Num,1,1)) + @Lakh If Substring(@Num,2,2) '00' Set @Return = @Return + dbo.GetTextValue(Substring(@Num,2,2)) + @Thousand IF SubString(@Num,4,1) '0' Set @Return = @Return + dbo.GetTextValue(Substring(@Num,4,1)) + @Hundred IF Substring(@Num,5,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2)) Set @Return = @Return + @Crores If SubString(@Num,7,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,7,2)) + @Lakhs If SubString(@Num,9,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,9,2)) + @Thousand If SubString(@Num,11,1) '0' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,11,1)) + @Hundred IF SubString(@num,12,2) '00' Set @Return = @Return + 'And ' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,12,2)) End Else if Len(@Num) = 14 -- Ten Lakh Crore Begin Set @Return = dbo.GetTextValue(Substring(@Num,1,2)) + @Lakhs If Substring(@Num,3,2) '00' Set @Return = @Return + dbo.GetTextValue(Substring(@Num,3,2)) + @Thousand IF SubString(@Num,5,1) '0' Set @Return = @Return + dbo.GetTextValue(Substring(@Num,5,1)) + @Hundred IF Substring(@Num,6,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,2)) Set @Return = @Return + @Crores If SubString(@Num,8,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,8,2)) + @Lakhs If SubString(@Num,10,2) '00' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,10,2)) + @Thousand If SubString(@Num,12,1) '0' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,12,1)) + @Hundred IF SubString(@num,13,2) '00' Set @Return = @Return + 'And ' Set @Return = @Return + dbo.GetTextValue(SubString(@Num,13,2)) End If @Dec '.00' Set @Return = @Return + 'Rupees And ' + dbo.GetTextValue(SubString(@Dec,2,2)) + 'Paise' ELSE Set @Return =@Return +'Rupees' Return @return End GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO CREATE Function dbo.GetTextValue ( @dblNumber Numeric ) Returns Varchar(1000) As Begin Declare @StrWord Varchar(400) SEt @strWord = Case @dblNumber When 1 Then 'One ' When 2 Then 'Two ' When 3 Then 'Three ' When 4 Then 'Four ' When 5 Then 'Five ' When 6 Then 'Six ' When 7 Then 'Seven ' When 8 Then 'Eight ' When 9 Then 'Nine ' When 10 Then 'Ten ' When 11 Then 'Eleven ' When 12 Then 'Twelve ' When 13 Then 'Thirteen ' When 14 Then 'Fourteen ' When 15 Then 'Fifteen ' When 16 Then 'Sixteen ' When 17 Then 'Seventeen ' When 18 Then 'Eighteen ' When 19 Then 'Nineteen ' When 20 Then 'Twenty ' When 21 Then 'Twenty One ' When 22 Then 'Twenty Two ' When 23 Then 'Twenty Three ' When 24 Then 'Twenty Four ' When 25 Then 'Twenty Five ' When 26 Then 'Twenty Six ' When 27 Then 'Twenty Seven ' When 28 Then 'Twenty Eight ' When 29 Then 'Twenty Nine ' When 30 Then 'Thirty ' When 31 Then 'Thirty One ' When 32 Then 'Thirty Two ' When 33 Then 'Thirty Three ' When 34 Then 'Thirty Four ' When 35 Then 'Thirty Five ' When 36 Then 'Thirty Six ' When 37 Then 'Thirty Seven ' When 38 Then 'Thirty Eight ' When 39 Then 'Thirty Nine ' When 40 Then 'Fourty ' When 41 Then 'Fourty One ' When 42 Then 'Fourty Two ' When 43 Then 'Fourty Three ' When 44 Then 'Fourty Four ' When 45 Then 'Fourty Five ' When 46 Then 'Fourty Six ' When 47 Then 'Fourty Seven ' When 48 Then 'Fourty Eight ' When 49 Then 'Fourty Nine ' When 50 Then 'Fifty ' When 51 Then 'Fifty One ' When 52 Then 'Fifty Two ' When 53 Then 'Fifty Three ' When 54 Then 'Fifty Four ' When 55 Then 'Fifty Five ' When 56 Then 'Fifty Six ' When 57 Then 'Fifty Seven ' When 58 Then 'Fifty Eight ' When 59 Then 'Fifty Nine ' When 60 Then 'Sixty ' When 61 Then 'Sixty One ' When 62 Then 'Sixty Two ' When 63 Then 'Sixty Three ' When 64 Then 'Sixty Four ' When 65 Then 'Sixty Five ' When 66 Then 'Sixty Six ' When 67 Then 'Sixty Seven ' When 68 Then 'Sixty Eight ' When 69 Then 'Sixty Nine ' When 70 Then 'Seventy ' When 71 Then 'Seventy One ' When 72 Then 'Seventy Two ' When 73 Then 'Seventy Three ' When 74 Then 'Seventy Four ' When 75 Then 'Seventy Five ' When 76 Then 'Seventy Six ' When 77 Then 'Seventy Seven ' When 78 Then 'Seventy Eight ' When 79 Then 'Seventy Nine ' When 80 Then 'Eighty ' When 81 Then 'Eighty One ' When 82 Then 'Eighty Two ' When 83 Then 'Eighty Three ' When 84 Then 'Eighty Four ' When 85 Then 'Eighty Five ' When 86 Then 'Eighty Six ' When 87 Then 'Eighty Seven ' When 88 Then 'Eighty Eight ' When 89 Then 'Eighty Nine ' When 90 Then 'Ninety ' When 91 Then 'Ninety One ' When 92 Then 'Ninety Two ' When 93 Then 'Ninety Three ' When 94 Then 'Ninety Four ' When 95 Then 'Ninety Five ' When 96 Then 'Ninety Six ' When 97 Then 'Ninety Seven ' When 98 Then 'Ninety Eight ' When 99 Then 'Ninety Nine ' When 100 Then 'One hundred ' else ' ' End Return @strWord End GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO*
but it showed me error.Let me know where i am getting wrong.
I also  created 1 UDF on the document where you want the amount in words as per indian format. run the query generateor,paste the below query... and save it. declare @Doc_total numeric (19,6) set @Doc_total=$[OINV.DocTotal] select dbo.AmountToWords (@Doc_total) now apply formated search on the UDF you created(For e.g. i created on SALes Invoice) refresh regularly on doctotal. now choose that UDF on pld. Hope this will help u. Regards, Neetu
Regards-
Mona.

Dear,,
Run the below functions in your database:
                                                                                Create function [dbo].[AmountToWords]
@InNumber Numeric(18,2)
--Returns the number as words.
returns VARCHAR(2000)
as
BEGIN
--SEt NoCount ON
Declare @Num Varchar(20)
Declare @Dec Varchar(3)
Declare @Return Varchar(2000)
Set @Dec = SubString(Convert(Varchar(20),@Innumber),Len(Convert(Varchar(20),@Innumber))-2,3)
Set @Num = SubString(Convert(Varchar(20),@Innumber),1, Len(Convert(Varchar(20),@Innumber))-3)
Declare @Hundred Char(8)
Declare @HundredAnd Char(12)
Declare @Thousand Char(9)
Declare @Lakh Char(5)
Declare @Lakhs Char(6)
Declare @Crore Char(6)
Declare @Crores Char(7)
Set @Hundred = 'Hundred '
Set @Thousand = 'Thousand '
Set @Lakh = 'Lakh '
Set @Lakhs = 'Lakhs '
Set @Crore = 'Crore '
Set @Crores = 'Crores '
Set @HundredAnd = 'Hundred and '
if Len(@Num) = 1 -- One
Begin
Set @Return = dbo.GetTextValue(@Num)
End
Else if Len(@Num) = 2 -- Ten
Begin
Set @Return = dbo.GetTextValue(@Num)
End
Else if Len(@Num) = 3 -- Hundred
Begin
Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Hundred
IF SubString(@num,2,2) <> '00'
Set @Return = @Return + 'And '
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2))
End
Else if Len(@Num) = 4 -- thousand
Begin
Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Thousand
If SubString(@Num,2,1) <> '0'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,1)) + @Hundred
IF SubString(@num,3,2)  <> '00'
Set @Return = @Return + 'And '
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2))
End
Else if Len(@Num) = 5 -- Ten Thousand
Begin
Set @Return = dbo.GetTextValue(SubString(@Num,1,2)) + @Thousand
If SubString(@Num,3,1) <> '0'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,1)) + @Hundred
IF SubString(@num,4,2) <> '00'
Set @Return = @Return + 'And '
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2))
End
Else if Len(@Num) = 6 -- Lakh
Begin
If SubString(@Num,1,1) = '1'
Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Lakh
Else
Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Lakhs
If SubString(@Num,2,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2)) + @Thousand
If SubString(@Num,4,1) <> '0'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,1)) + @Hundred
IF SubString(@num,5,2)  <> '00'
Set @Return = @Return + 'And '
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2))
End
Else if Len(@Num) = 7 -- Ten Lakhs
Begin
Set @Return = dbo.GetTextValue(SubString(@Num,1,2)) + @Lakhs
If SubString(@Num,3,2)  <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2)) + @Thousand
If SubString(@Num,6,1) <> '0'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,1)) + @Hundred
IF SubString(@num,6,2) <> '00'
Set @Return = @Return + 'And '
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,2))
End
Else if Len(@Num) = 8 -- Crore
Begin
Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Crore
If SubString(@Num,2,2)  <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2)) + @Lakhs
If SubString(@Num,4,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2)) + @Thousand
If SubString(@Num,6,1) <> '0'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,1)) + @Hundred
IF SubString(@num,7,2) <> '00'
Set @Return = @Return + 'And '
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,7,2))
End
Else if Len(@Num) = 9 -- Ten Crore
Begin
Set @Return = dbo.GetTextValue(SubString(@Num,1,2)) + @Crores
If SubString(@Num,3,2)  <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2)) + @Lakhs
If SubString(@Num,5,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2)) + @Thousand
If SubString(@Num,7,1)  <> '0'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,7,1)) + @Hundred
IF SubString(@num,8,2) <> '00'
Set @Return = @Return + 'And '
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,8,2))
End
Else if Len(@Num) = 10 -- Hundred Crore
Begin
Set @Return = dbo.GetTextValue(Substring(@Num,1,1)) + @Hundred
IF Substring(@Num,2,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2))
Set @Return = @Return + @Crores
If SubString(@Num,4,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2)) + @Lakhs
If SubString(@Num,6,2)  <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,2)) + @Thousand
If SubString(@Num,8,1) <> '0'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,8,1)) + @Hundred
IF SubString(@num,9,2)  <> '00'
Set @Return = @Return + 'And '
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,9,2))
End
Else if Len(@Num) = 11 -- Thousand Crore
Begin
Set @Return = dbo.GetTextValue(Substring(@Num,1,1)) + @Thousand
IF SubString(@Num,2,1) <> '0'
Set @Return = @Return + dbo.GetTextValue(Substring(@Num,2,1)) + @Hundred
IF Substring(@Num,3,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2))
Set @Return = @Return + @Crores
If SubString(@Num,5,2) <>'00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2)) + @Lakhs
If SubString(@Num,7,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,7,2)) + @Thousand
If SubString(@Num,9,1) <> '0'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,9,1)) + @Hundred
IF SubString(@num,10,2) <> '00'
Set @Return = @Return + 'And '
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,10,2))
End
Else if Len(@Num) = 12 -- Ten thousand Crore
Begin
Set @Return = dbo.GetTextValue(Substring(@Num,1,2)) + @Thousand
IF SubString(@Num,3,1) <> '0'
Set @Return = @Return + dbo.GetTextValue(Substring(@Num,3,1)) + @Hundred
IF Substring(@Num,4,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2))
Set @Return = @Return + @Crores
If SubString(@Num,6,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,2)) + @Lakhs
If SubString(@Num,8,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,8,2)) + @Thousand
If SubString(@Num,10,1) <> '0'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,10,1)) + @Hundred
IF SubString(@num,11,2) <> '00'
Set @Return = @Return + 'And '
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,11,2))
End
Else if Len(@Num) = 13 -- Lakh Crore
Begin
Set @Return = dbo.GetTextValue(Substring(@Num,1,1)) + @Lakh
If Substring(@Num,2,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(Substring(@Num,2,2)) + @Thousand
IF SubString(@Num,4,1)  <> '0'
Set @Return = @Return + dbo.GetTextValue(Substring(@Num,4,1)) + @Hundred
IF Substring(@Num,5,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2))
Set @Return = @Return + @Crores
If SubString(@Num,7,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,7,2)) + @Lakhs
If SubString(@Num,9,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,9,2)) + @Thousand
If SubString(@Num,11,1) <> '0'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,11,1)) + @Hundred
IF SubString(@num,12,2) <> '00'
Set @Return = @Return + 'And '
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,12,2))
End
Else if Len(@Num) = 14 -- Ten Lakh Crore
Begin
Set @Return = dbo.GetTextValue(Substring(@Num,1,2)) + @Lakhs
If Substring(@Num,3,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(Substring(@Num,3,2)) + @Thousand
IF SubString(@Num,5,1) <> '0'
Set @Return = @Return + dbo.GetTextValue(Substring(@Num,5,1)) + @Hundred
IF Substring(@Num,6,2)  <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,2))
Set @Return = @Return + @Crores
If SubString(@Num,8,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,8,2)) + @Lakhs
If SubString(@Num,10,2) <> '00'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,10,2)) + @Thousand
If SubString(@Num,12,1) <> '0'
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,12,1)) + @Hundred
IF SubString(@num,13,2) <> '00'
Set @Return = @Return + 'And '
Set @Return = @Return + dbo.GetTextValue(SubString(@Num,13,2))
End
If @Dec  <> '.00'
Set @Return = @Return + 'Rupees And ' + dbo.GetTextValue(SubString(@Dec,2,2)) + 'Paise Only'
ELSE
Set @Return =@Return+'Zero Rupees Only'
Return @return
End
CREATEFunction [dbo].[GetTextValue]
@dblNumber Numeric
Returns Varchar(1000)
As
Begin
Declare @StrWord Varchar(400)
SEt @strWord = Case @dblNumber
When 1 Then 'One '
When 2 Then 'Two '
When 3 Then 'Three '
When 4 Then 'Four '
When 5 Then 'Five '
When 6 Then 'Six '
When 7 Then 'Seven '
When 8 Then 'Eight '
When 9 Then 'Nine '
When 10 Then 'Ten '
When 11 Then 'Eleven '
When 12 Then 'Twelve '
When 13 Then 'Thirteen '
When 14 Then 'Fourteen '
When 15 Then 'Fifteen '
When 16 Then 'Sixteen '
When 17 Then 'Seventeen '
When 18 Then 'Eighteen '
When 19 Then 'Nineteen '
When 20 Then 'Twenty '
When 21 Then 'Twenty One '
When 22 Then 'Twenty Two '
When 23 Then 'Twenty Three '
When 24 Then 'Twenty Four '
When 25 Then 'Twenty Five '
When 26 Then 'Twenty Six '
When 27 Then 'Twenty Seven '
When 28 Then 'Twenty Eight '
When 29 Then 'Twenty Nine '
When 30 Then 'Thirty '
When 31 Then 'Thirty One '
When 32 Then 'Thirty Two '
When 33 Then 'Thirty Three '
When 34 Then 'Thirty Four '
When 35 Then 'Thirty Five '
When 36 Then 'Thirty Six '
When 37 Then 'Thirty Seven '
When 38 Then 'Thirty Eight '
When 39 Then 'Thirty Nine '
When 40 Then 'Fourty '
When 41 Then 'Fourty One '
When 42 Then 'Fourty Two '
When 43 Then 'Fourty Three '
When 44 Then 'Fourty Four '
When 45 Then 'Fourty Five '
When 46 Then 'Fourty Six '
When 47 Then 'Fourty Seven '
When 48 Then 'Fourty Eight '
When 49 Then 'Fourty Nine '
When 50 Then 'Fifty '
When 51 Then 'Fifty One '
When 52 Then 'Fifty Two '
When 53 Then 'Fifty Three '
When 54 Then 'Fifty Four '
When 55 Then 'Fifty Five '
When 56 Then 'Fifty Six '
When 57 Then 'Fifty Seven '
When 58 Then 'Fifty Eight '
When 59 Then 'Fifty Nine '
When 60 Then 'Sixty '
When 61 Then 'Sixty One '
When 62 Then 'Sixty Two '
When 63 Then 'Sixty Three '
When 64 Then 'Sixty Four '
When 65 Then 'Sixty Five '
When 66 Then 'Sixty Six '
When 67 Then 'Sixty Seven '
When 68 Then 'Sixty Eight '
When 69 Then 'Sixty Nine '
When 70 Then 'Seventy '
When 71 Then 'Seventy One '
When 72 Then 'Seventy Two '
When 73 Then 'Seventy Three '
When 74 Then 'Seventy Four '
When 75 Then 'Seventy Five '
When 76 Then 'Seventy Six '
When 77 Then 'Seventy Seven '
When 78 Then 'Seventy Eight '
When 79 Then 'Seventy Nine '
When 80 Then 'Eighty '
When 81 Then 'Eighty One '
When 82 Then 'Eighty Two '
When 83 Then 'Eighty Three '
When 84 Then 'Eighty Four '
When 85 Then 'Eighty Five '
When 86 Then 'Eighty Six '
When 87 Then 'Eighty Seven '
When 88 Then 'Eighty Eight '
When 89 Then 'Eighty Nine '
When 90 Then 'Ninety '
When 91 Then 'Ninety One '
When 92 Then 'Ninety Two '
When 93 Then 'Ninety Three '
When 94 Then 'Ninety Four '
When 95 Then 'Ninety Five '
When 96 Then 'Ninety Six '
When 97 Then 'Ninety Seven '
When 98 Then 'Ninety Eight '
When 99 Then 'Ninety Nine '
When 100 Then 'One hundred '
else ' '
End
Return @strWord
End
Run the query generator of SAP,paste below query.
Apply FMS on field.
declare @Doc_total numeric (19,6)
set @Doc_total=$[OINV.DocTotal]
select  dbo.AmountToWords (@Doc_total)

Similar Messages

  • Amount total(In Words) in Indian Format.

    Hi All,
    I want to have the amount total of marketing documents in words in Indian format.
    Problem description :
    If the the amount total is 565136.
    Right Now in Print Layout Design its showing : Five hundred and sixty five thousand one hundred and thirty six.
    I want the same in Indian format, that is :
    It should print as : Five lakhs sixty five thousand one hundred and thirty six.
    Please help me.
    Thanks & Regards,
    Saikat Roy

    Hi!
    CREATE    Function dbo.fConvertDigit(@decNumber decimal)
    returns varchar(6)
    as
    Begin
    declare
    @strWords varchar(6)
    Select @strWords = Case @decNumber
         When '1' then 'One'
         When '2' then 'Two'
         When '3' then 'Three'
         When '4' then 'Four'
         When '5' then 'Five'
         When '6' then 'Six'
         When '7' then 'Seven'
         When '8' then 'Eight'
         When '9' then 'Nine'
         Else ''
    end
    return @strWords
    end
    CREATE    Function dbo.fConvertTens(@decNumber varchar(2))
    returns varchar(30)
    as
    Begin
    declare @strWords varchar(30)
    --Is value between 10 and 19?
    If Left(@decNumber, 1) = 1
    begin
    Select @strWords = Case @decNumber
         When '10' then 'Ten'
         When '11' then 'Eleven'
         When '12' then 'Twelve'
         When '13' then 'Thirteen'
         When '14' then 'Fourteen'
         When '15' then 'Fifteen'
         When '16' then 'Sixteen'
         When '17' then 'Seventeen'
         When '18' then 'Eighteen'
         When '19' then 'Nineteen'
    end
    end
    else  -- otherwise it's between 20 and 99.
    begin
    Select @strWords = Case Left(@decNumber, 1)
         When '0' then '' 
         When '2' then 'Twenty '
         When '3' then 'Thirty '
         When '4' then 'Forty '
         When '5' then 'Fifty '
         When '6' then 'Sixty '
         When '7' then 'Seventy '
         When '8' then 'Eighty '
         When '9' then 'Ninety '
    end
    Select @strWords = @strWords + dbo.fConvertDigit(Right(@decNumber, 1))
    end
    --Convert ones place digit.
    return @strWords
    end
    CREATE function dbo.fNumToWords (@decNumber decimal(12, 2))
    returns varchar(300)
    As
    Begin
    Declare
    @strNumber varchar(100),
    @strRupees varchar(200),
    @strPaise varchar(100),
    @strWords varchar(300),
    @intIndex integer,
    @intAndFlag integer
    Select @strNumber = Cast(@decNumber as varchar(100))
    Select @intIndex = CharIndex('.', @strNumber)
    if(@decNumber>99999999.99)
    BEGIN
    RETURN ''
    END
    If @intIndex > 0
    begin
    Select @strPaise = dbo.fConvertTens(Right(@strNumber, Len(@strNumber) - @intIndex))
    Select @strNumber = SubString(@strNumber, 1, Len(@strNumber) - 3)
    If Len(@strPaise) > 0 Select @strPaise = @strPaise + ' paise'
    end
    Select @strRupees = ''
    Select @intIndex=len(@strNumber)
    Select @intAndFlag=2
    while(@intIndex>0)
    begin
    if(@intIndex=8)
    begin
      Select @[email protected](left(@decNumber,1))' Crore '
      Select @strNumber=substring(@strNumber,2,len(@strNumber))
      Select @intIndex=@intIndex-1
    end
    else if(@intIndex=7)
    begin
      if(substring(@strNumber,1,1)='0')
      begin
       if substring(@strNumber,2,1)<>'0'
       begin
        if (@strRupees<>NULL and substring(@strNumber,3,1)='0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and substring(@strNumber,6,1)='0' and substring(@strNumber,7,1)='0' and @intAndFlag=2 and @strPaise=NULL)
        begin
         Select @strRupees=@strRupees+' and ' dbo.fConvertDigit(substring(@strNumber,2,1))' Lakh '
         Select @intAndFlag=1
        end
        else
        begin
         Select @[email protected](substring(@strNumber,2,1))' Lakh '
        end
        Select @strNumber=substring(@strNumber,3,len(@strNumber))
        Select @intIndex=@intIndex-2
       end
       else
       begin
        Select @strNumber=substring(@strNumber,3,len(@strNumber))
        Select @intIndex=@intIndex-2
       end
      end
      else
      begin
       if(substring(@strNumber,3,1)='0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and substring(@strNumber,6,1)='0' and substring(@strNumber,7,1)='0'  and @intAndFlag=2 and @strPaise='')
       begin  
        Select @strRupees=@strRupees+' and ' + dbo.fConvertTens(substring(@strNumber,1,2))+' Lakhs '
        Select @intAndFlag=1
       end
       else
       begin
        Select @[email protected](substring(@strNumber,1,2))' Lakhs '
       end
       Select @strNumber=substring(@strNumber,3,len(@strNumber))
       Select @intIndex=@intIndex-2
      end
    end
    else if(@intIndex=6)
      begin
       if(substring(@strNumber,2,1)<>'0' or substring(@strNumber,3,1)<>'0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and substring(@strNumber,6,1)='0' and @intAndFlag=2 and @strPaise='')
       begin
        if len(@strRupees) <= 0
        begin
         if convert(int,substring(@strNumber,1,1)) = 1
         begin
          Select @strRupees=@strRupees+'' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Lakh '
          Select @intAndFlag=2
         end
         else
         begin
          Select @strRupees=@strRupees+'' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Lakhs '
          Select @intAndFlag=2
         end
        end
        else
        begin
         if convert(int,substring(@strNumber,1,1)) = 1
         begin
          Select @strRupees=@strRupees+' and' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Lakh '
          Select @intAndFlag=1
         end
         else
         begin
          Select @strRupees=@strRupees+' and' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Lakhs '
          Select @intAndFlag=1
         end
        end
       end
       else
       begin
        if convert(int,substring(@strNumber,1,1)) = 1
        begin
         Select @[email protected](substring(@strNumber,1,1))' Lakh '
        end
        else
        begin
         Select @[email protected](substring(@strNumber,1,1))' Lakhs '
        end
       end
       Select @strNumber=substring(@strNumber,2,len(@strNumber))
       Select @intIndex=@intIndex-1
      end
    else if(@intIndex=5)
      begin
       if(substring(@strNumber,1,1)='0')
       begin
        if substring(@strNumber,2,1)<>'0'
        begin
         if(substring(@strNumber,3,1)='0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and @intAndFlag=2 and @strPaise='')
         begin
          Select @strRupees=@strRupees+' and ' dbo.fConvertDigit(substring(@strNumber,2,1))' Thousand '
          Select @intAndFlag=1
         end
         else
         begin
          Select @[email protected](substring(@strNumber,2,1))' Thousand '
         end
         Select @strNumber=substring(@strNumber,3,len(@strNumber))
         Select @intIndex=@intIndex-2
        end
        else
        begin
         Select @strNumber=substring(@strNumber,3,len(@strNumber))
         Select @intIndex=@intIndex-2
        end
       end
       else
       begin
        if(substring(@strNumber,3,1)='0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and @intAndFlag=2 and @strPaise='')
        begin
         Select @strRupees=@strRupees' and 'dbo.fConvertTens(substring(@strNumber,1,2))+' Thousand '
         Select @intAndFlag=1
        end
        else
        begin
         Select @[email protected](substring(@strNumber,1,2))' Thousand '
        end
        Select @strNumber=substring(@strNumber,3,len(@strNumber))
        Select @intIndex=@intIndex-2
       end
      end
    else if(@intIndex=4)
      begin
       if ( (substring(@strNumber,3,1)<>'0' or substring(@strNumber,4,1)<>'0') and substring(@strNumber,2,1)='0' and  @intAndFlag=2 and @strPaise='')
       begin
        Select @strRupees=@strRupees+' and' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Thousand '
        Select @intAndFlag=1
       end
       else
       begin
       Select @[email protected](substring(@strNumber,1,1))' Thousand '
       end
       Select @strNumber=substring(@strNumber,2,len(@strNumber))
       Select @intIndex=@intIndex-1
      end
    else if(@intIndex=3)
      begin
       if  substring(@strNumber,1,1)<>'0'
       begin
        Select @[email protected](substring(@strNumber,1,1))' Hundred '
        Select @strNumber=substring(@strNumber,2,len(@strNumber))
        if( (substring(@strNumber,1,1)<>'0' or  substring(@strNumber,2,1)<>'0') and @intAndFlag=2 )
        begin
         Select @strRupees=@strRupees+' and '
         Select @intAndFlag=1
        end
        Select @intIndex=@intIndex-1
       end
       else
       begin
        Select @strNumber=substring(@strNumber,2,len(@strNumber))
        Select @intIndex=@intIndex-1
       end
      end
    else if(@intIndex=2)
      begin
       if substring(@strNumber,1,1)<>'0'
       begin
        Select @strRupees=@strRupees+dbo.fConvertTens(substring(@strNumber,1,2))
        Select @intIndex=@intIndex-2
       end
       else
       begin
        Select @intIndex=@intIndex-1
       end
      end
    else if(@intIndex=1)
      begin
       if(@strNumber<>'0')
       begin
        Select @strRupees=@strRupees+dbo.fConvertDigit(@strNumber)
       end
       Select @intIndex=@intIndex-1
      end
    continue
    end
    if len(@strRupees)>0 Select @strRupees=@strRupees+ ' rupees '
    IF(len(@strPaise)<>0)
    BEGIN
    if len(@strRupees)>0 Select @strRupees=@strRupees + ' and '
    END
    Select @strWords = IsNull(@strRupees, '') + IsNull(@strPaise, '')
    select @strWords = @strWords + ' only'
    Return @strWords
    End
    ==============================
    Declare @str varchar(500)
    Declare @no numeric(19,6)
    Set @no=12453456.45
    Set @str =dbo.fNumToWords (@no)
    Select @str
    ===============================

  • Covert Amount in words  in other format

    Hi,
    I have a value say 222.20 .
    When I use CALL FUNCTION 'HR_IN_CHG_INR_WRDS' then it gives output as:-
    TWO HUNDRED TWENTY TWO Rupees TWENTY Paise.
    But I want output as:
    TWO HUNDRED TWENTY TWO And 20/100.
    Plz. help.
    Thanks in advance.
    Manoj kumar

    i guess you can not get such o/p by any FM .
    but you can do it programatically.
    1) just split the amount at decimal.
    2) pass the whole no to function module and get the word description in one sting.
    3) get the decimal part converted to whole no like 0.55 will be converted as .55*100 = 55.
    4)then take a string and get values concatenated like 55,/,100.
    where / and 100 will always remain same.
    5) now concatenate the string 1 from word desc and this string 2 in staring3
    6) string 3 is the required o/p.

  • Amounts In Indian Formats

    Hi Gurus,
    I have Designed Some PLD's  and my clients wish to print the amount in words in indian format,
    Like if it is 125000 means it needs  to be printed like  One Lakh Twenty Five Thousands Rupees   but instead of that it is printing like one hundred and twenty five thousands.
    I need wo print in  Indian format.
    So Pls guide me in finding a  proper solution for this issue.
    Thanx in Advance.
    Regards,
    Vamsi

    Hi Parimis,
    If you need to Print a INDIAN STYLE Amount in Words.
    Try this,
    ->> Create 1 UDF in Header on Require Documents (ex. Marketing Documents).
    ->> Create 3 Function in MS SQL Server Management.
    ->> Create 1 FMS in Query Generator and save as Query Manager then Assign to UDF for Amount in Words.
    for example:
    Create UDF in Header on Marketing Documents.
    ->> Choose Tools on Top menu.
    ->> User - Defined Fields. -> User Manage Fields.
    ->> Open the User Manage Fields Window.
    ->> Marketing Documents. -> Title.
    ->> Select Title and Click Add button in Bottom on User Manage Fields Window.
    ->> Create Amount in Words UDF(Code, Description and Type - Character) and Add the UDF.
    Create Function in MS SQL Server Management.
    Check this Link, (have 3 Functions in Link).
    http://techcreeze.blogspot.com/2008/11/convert-amount-into-words-according-to_15.html
    1st Function - to Convert one Digit Number to words
    2nd Function - to convert 2 digit number to words.
    3rd Function - to convert amt in numbers to words.
    ->> Open the MS SQL Server Management Window.
    ->> Choose your Company database and Create NEW Query.
    ->> Create 3 Function Queries one by one.
    ->> Create 3 NEW Query Tab and 1st one put the 1st Function then Run the Function. and
    2nd New Query tab put the 2nd Function then Run the Function.
    3rd New Query tab put the 3rd Function then Run the Function.
    Create FMS in Query Generator and Save as Query Manager.
    ->> Administration.
    ->> Reports. -> Query Generator.
    ->> Open the Query Generator and put the below FMS query.
    for example : Purchase Order Doc. Total (IN WORDS).
    DECLARE @Doc_total numeric (19,6)
    SET @Doc_total=$[OPOR.DocTotal]
    SELECT  dbo.fNumToWords(@Doc_total)
    OR
    Try this Simple FMS
    SELECT dbo.fNumToWords($[OPOR.DocTotal])
    ->> Assign the FMS in UDF on Purchase Order.
    ->> Auto Refresh of Document Total.
    Ex.
    1. Goto the UDF and Clcik ShiftAltF2.
    2. Select the SEARCH BY SAVED QUERY.
    3. Assign the FMS Query.
    4. Select the AUTO REFRESH WHEN FIELD CHANGES.
    5. Select Document Total.
    6. Check the Display Saved Values.
    CLOSE THE THREAD, IF ISSUE SOLVED
    Regards,
    Madhan.

  • Amount in words in F110 (sapscript -indian format)

    Hi Experts.
    I have changed the F110_PRENUM_CHCK to Z110_PRENUM_CHCK .
    I want the amount to be in word in indian format.
    say Ten Lakh ninty thousand and fifty
    But i am getting the output in "One millon .. " format
    Pls give me the coding and also suggest me how to incorporate in sapscript .
    Window CHECKSPL
    545
    Amount in words -
    &'*** 'SPELL-WORD& &' and 'SPELL-DECWORD&***
    Example for amount and decimal places in words
    &'*** 'SPELL-WORD& &REGUD-WAERS&&' and 'SPELL-DECWORD' Cents'& ***
    Example for numbers in words
    &SPELL-DIG06(6)&&SPELL-DIG05(6)&&SPELL-DIG04(6)&&SPELL-DIG03(6)&&SPELL-DIG02(6)&&SPELL-DIG01(7)&
    Pls revert back its urgent
    Thanks
    Pravesh Deshbhratar

    same code i used in smartform:
    DATA : l_spell_a TYPE pc207-betrg,
    l_local   TYPE string,
    w_len     TYPE i.
    * Internal Table Declaration
    DATA : BEGIN OF t_char OCCURS 0,
    char(80) TYPE c,
    END OF t_char.
    l_spell_a = l_amtsum.
    CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
    EXPORTING
    amt_in_num         = l_spell_a
    IMPORTING
    amt_in_words       = l_spell
    EXCEPTIONS
    data_type_mismatch = 1
    OTHERS             = 2.
    IF sy-subrc = 0.

  • Amount in words in SAP 8.8

    Hello expert,
                        I want to  convert the document amount in words in Indian standard and I am using the  below Functions which I got from sdn and its working fine in SAP 2007 but it is giving error in SAP 8.8 and patch level is 5.........please give the feasible solution.....
    1. Function to Convert one Digit Number to words.
    CREATE    Function dbo.fConvertDigit(@decNumber decimal)
    returns varchar(6)
    as
    Begin
    declare
    @strWords varchar(6)
    Select @strWords = Case @decNumber
         When '1' then 'One'
         When '2' then 'Two'
         When '3' then 'Three'
         When '4' then 'Four'
         When '5' then 'Five'
         When '6' then 'Six'
         When '7' then 'Seven'
         When '8' then 'Eight'
         When '9' then 'Nine'
         Else ''
    end
    return @strWords
    end
    2. Function to convert 2 digit number to words.
    CREATE    Function dbo.fConvertTens(@decNumber varchar(2))
    returns varchar(30)
    as
    Begin
    declare @strWords varchar(30)
    --Is value between 10 and 19?
    If Left(@decNumber, 1) = 1
    begin
    Select @strWords = Case @decNumber
         When '10' then 'Ten'
         When '11' then 'Eleven'
         When '12' then 'Twelve'
         When '13' then 'Thirteen'
         When '14' then 'Fourteen'
         When '15' then 'Fifteen'
         When '16' then 'Sixteen'
         When '17' then 'Seventeen'
         When '18' then 'Eighteen'
         When '19' then 'Nineteen'
    end
    end
    else  -- otherwise it's between 20 and 99.
    begin
    Select @strWords = Case Left(@decNumber, 1)
         When '0' then '' 
         When '2' then 'Twenty '
         When '3' then 'Thirty '
         When '4' then 'Forty '
         When '5' then 'Fifty '
         When '6' then 'Sixty '
         When '7' then 'Seventy '
         When '8' then 'Eighty '
         When '9' then 'Ninety '
    end
    Select @strWords = @strWords + dbo.fConvertDigit(Right(@decNumber, 1))
    end
    --Convert ones place digit.
    return @strWords
    end
    3. Function to convert amt in numbers to words. (Built with the help of above 2 functions)
    CREATE function dbo.fNumToWords (@decNumber decimal(12, 2))
    returns varchar(300)
    As
    Begin
    Declare
    @strNumber varchar(100),
    @strRupees varchar(200),
    @strPaise varchar(100),
    @strWords varchar(300),
    @intIndex integer,
    @intAndFlag integer
    Select @strNumber = Cast(@decNumber as varchar(100))
    Select @intIndex = CharIndex('.', @strNumber)
    if(@decNumber>99999999.99)
    BEGIN
    RETURN ''
    END
    If @intIndex > 0
    begin
    Select @strPaise = dbo.fConvertTens(Right(@strNumber, Len(@strNumber) - @intIndex))
    Select @strNumber = SubString(@strNumber, 1, Len(@strNumber) - 3)
    If Len(@strPaise) > 0 Select @strPaise = @strPaise + ' paise'
    end
    Select @strRupees = ''
    Select @intIndex=len(@strNumber)
    Select @intAndFlag=2
    while(@intIndex>0)
    begin
    if(@intIndex=8)
    begin
      Select @[email protected](left(@decNumber,1))' Crore '
      Select @strNumber=substring(@strNumber,2,len(@strNumber))
      Select @intIndex=@intIndex-1
    end
    else if(@intIndex=7)
    begin
      if(substring(@strNumber,1,1)='0')
      begin
       if substring(@strNumber,2,1)<>'0'
       begin
        if (@strRupees<>NULL and substring(@strNumber,3,1)='0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and substring(@strNumber,6,1)='0' and substring(@strNumber,7,1)='0' and @intAndFlag=2 and @strPaise=NULL)
        begin
         Select @strRupees=@strRupees+' and ' dbo.fConvertDigit(substring(@strNumber,2,1))' Lakh '
         Select @intAndFlag=1
        end
        else
        begin
         Select @[email protected](substring(@strNumber,2,1))' Lakh '
        end
        Select @strNumber=substring(@strNumber,3,len(@strNumber))
        Select @intIndex=@intIndex-2
       end
       else
       begin
        Select @strNumber=substring(@strNumber,3,len(@strNumber))
        Select @intIndex=@intIndex-2
       end
      end
      else
      begin
       if(substring(@strNumber,3,1)='0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and substring(@strNumber,6,1)='0' and substring(@strNumber,7,1)='0'  and @intAndFlag=2 and @strPaise='')
       begin  
        Select @strRupees=@strRupees+' and ' + dbo.fConvertTens(substring(@strNumber,1,2))+' Lakhs '
        Select @intAndFlag=1
       end
       else
       begin
        Select @[email protected](substring(@strNumber,1,2))' Lakhs '
       end
       Select @strNumber=substring(@strNumber,3,len(@strNumber))
       Select @intIndex=@intIndex-2
      end
    end
    else if(@intIndex=6)
      begin
       if(substring(@strNumber,2,1)<>'0' or substring(@strNumber,3,1)<>'0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and substring(@strNumber,6,1)='0' and @intAndFlag=2 and @strPaise='')
       begin
        if len(@strRupees) <= 0
        begin
         if convert(int,substring(@strNumber,1,1)) = 1
         begin
          Select @strRupees=@strRupees+'' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Lakh '
          Select @intAndFlag=2
         end
         else
         begin
          Select @strRupees=@strRupees+'' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Lakhs '
          Select @intAndFlag=2
         end
        end
        else
        begin
         if convert(int,substring(@strNumber,1,1)) = 1
         begin
          Select @strRupees=@strRupees+' and' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Lakh '
          Select @intAndFlag=1
         end
         else
         begin
          Select @strRupees=@strRupees+' and' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Lakhs '
          Select @intAndFlag=1
         end
        end
       end
       else
       begin
        if convert(int,substring(@strNumber,1,1)) = 1
        begin
         Select @[email protected](substring(@strNumber,1,1))' Lakh '
        end
        else
        begin
         Select @[email protected](substring(@strNumber,1,1))' Lakhs '
        end
       end
       Select @strNumber=substring(@strNumber,2,len(@strNumber))
       Select @intIndex=@intIndex-1
      end
    else if(@intIndex=5)
      begin
       if(substring(@strNumber,1,1)='0')
       begin
        if substring(@strNumber,2,1)<>'0'
        begin
         if(substring(@strNumber,3,1)='0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and @intAndFlag=2 and @strPaise='')
         begin
          Select @strRupees=@strRupees+' and ' dbo.fConvertDigit(substring(@strNumber,2,1))' Thousand '
          Select @intAndFlag=1
         end
         else
         begin
          Select @[email protected](substring(@strNumber,2,1))' Thousand '
         end
         Select @strNumber=substring(@strNumber,3,len(@strNumber))
         Select @intIndex=@intIndex-2
        end
        else
        begin
         Select @strNumber=substring(@strNumber,3,len(@strNumber))
         Select @intIndex=@intIndex-2
        end
       end
       else
       begin
        if(substring(@strNumber,3,1)='0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and @intAndFlag=2 and @strPaise='')
        begin
         Select @strRupees=@strRupees' and 'dbo.fConvertTens(substring(@strNumber,1,2))+' Thousand '
         Select @intAndFlag=1
        end
        else
        begin
         Select @[email protected](substring(@strNumber,1,2))' Thousand '
        end
        Select @strNumber=substring(@strNumber,3,len(@strNumber))
        Select @intIndex=@intIndex-2
       end
      end
    else if(@intIndex=4)
      begin
       if ( (substring(@strNumber,3,1)<>'0' or substring(@strNumber,4,1)<>'0') and substring(@strNumber,2,1)='0' and  @intAndFlag=2 and @strPaise='')
       begin
        Select @strRupees=@strRupees+' and' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Thousand '
        Select @intAndFlag=1
       end
       else
       begin
       Select @[email protected](substring(@strNumber,1,1))' Thousand '
       end
       Select @strNumber=substring(@strNumber,2,len(@strNumber))
       Select @intIndex=@intIndex-1
      end
    else if(@intIndex=3)
      begin
       if  substring(@strNumber,1,1)<>'0'
       begin
        Select @[email protected](substring(@strNumber,1,1))' Hundred '
        Select @strNumber=substring(@strNumber,2,len(@strNumber))
        if( (substring(@strNumber,1,1)<>'0' or  substring(@strNumber,2,1)<>'0') and @intAndFlag=2 )
        begin
         Select @strRupees=@strRupees+' and '
         Select @intAndFlag=1
        end
        Select @intIndex=@intIndex-1
       end
       else
       begin
        Select @strNumber=substring(@strNumber,2,len(@strNumber))
        Select @intIndex=@intIndex-1
       end
      end
    else if(@intIndex=2)
      begin
       if substring(@strNumber,1,1)<>'0'
       begin
        Select @strRupees=@strRupees+dbo.fConvertTens(substring(@strNumber,1,2))
        Select @intIndex=@intIndex-2
       end
       else
       begin
        Select @intIndex=@intIndex-1
       end
      end
    else if(@intIndex=1)
      begin
       if(@strNumber<>'0')
       begin
        Select @strRupees=@strRupees+dbo.fConvertDigit(@strNumber)
       end
       Select @intIndex=@intIndex-1
      end
    continue
    end
    if len(@strRupees)>0 Select @strRupees=@strRupees+ ' rupees '
    IF(len(@strPaise)<>0)
    BEGIN
    if len(@strRupees)>0 Select @strRupees=@strRupees + ' and '
    END
    Select @strWords = IsNull(@strRupees, '') + IsNull(@strPaise, '')
    select @strWords = @strWords + ' only'
    Return @strWords
    End
    ->> Create 1 UDF in Header on Requrie Documents (ex. Marketing Documents).
    ->> Create 3 Function in MSSQL Server Management.
    ->> Create 1 FMS in Query Generator and save as Query Manager then Assign to UDF for Amount in Words.
    for example:
    Create UDF in Header on Marketing Documents.
    ->> Choose Tools on Top menu.
    ->> User - Defined Fields. -> User Manage Fields.
    ->> Open the User Manage Fields Widnow.
    ->> Marketing Documents. -> Title.
    ->> Select Title and Click Add button in Bottom on User Manage Fields Window.
    ->> Create Amount in Words UDF(Code, Discription and Type - Character) and Add the UDF.
    Create Function in MSSQL Server Management.
    Check this Link, (have 3 Functions in Link).
    http://techcreeze.blogspot.com/2008/11/convert-amount-into-words-according-to_15.html
    1st Funciton - to Convert one Digit Number to words
    2nd Funciton - to convert 2 digit number to words.
    3rd Funciton - to convert amt in numbers to words.
    ->> Open the MSSQL Server Management Window.
    ->> Choose your Company database and Create NEW Query.
    ->> Create 3 Function Queries one by one.
    ->> Create 3 NEW Query Tab and 1st one put the 1st Function then Run the Function. and
    2nd New Query tab put the 2nd Function then Run the Function.
    3rd New Query tab put the 3rd Function then Run the Function.
    Create FMS in Query Generator and Save as Query Manager.
    ->> Adminstration.
    ->> Reports. -> Query Generator.
    ->> Open the Query Generator and put the below FMS query.
    for example : Purchase Order Doc. Toal(in wrods).
    declare @Doc_total numeric (19,6)
    set @Doc_total=$[OPOR.DocTotal]
    select  dbo.fNumToWords (@Doc_total)
    ->> Assign the FMS in UDF on Purchase Order.
    ->> Auto Refresh of Document Total.
    Ex.
    1. Goto the UDF and Clcik ShiftAltF2.
    2. Select the SEARCH BY SAVED QUERY.
    3. Assign the FMS Query.
    4. Select the AUTO REFRESH WHEN FIELD CHENGES.
    5. Select Document Total.
    6. Check the Display Saved Values.

    Hi Neetu,
    its not converting decimal values  in paisa...
    Regards
    Deepak tyagi

  • Amount in words problem

    Hi All,
    Please help me to get Amount in words in Indian standards
    i.e
    if amount is 125000 then it should print
    "One Lakh Twenty-five thousand rupees only"
    All these I need in a Check Print layout
    here i  can see amount but how will i get Amount in words there.
    I have made a query CheckPrint
    which contains follwing fields from OPCH (A/P Invoice table)
    DocNum , DocDate, CardName, DocTotal.
    I just want DocTotal in words so that i can display it on the layout and get the print on Cheque.
    I am using SAP 2005 B version.
    Please help I am not a trained professional in SAP Business One
    Kindly do the needful.
    Thanks and Regards,
    Murtaza Piyersoap

    Hi Murtaza,
    I had a similar issue, and I addressed it by:
    1. Creating a UDF in the Payments>Title called AmountInWord of Type AlphaNumeric Structure Text (i.e. in OVPM Table)
    2. Created a Function called I_ConvertN2W in the database, which converts any number into Words as per Indian Style i.e. Lakh, Crore
    3. In the SBO_SP_TransactionNotification, I am filling the Value in the UDF on every Add of Outgoing Payment
    4. In the PLD for the printing of the cheque, I am using the UDF, instead of the SAPB1 Amount (which is non Indian Style)
    Step 1:
    Create the UDF as mentioned above, I guess no further explanation required
    Step 2:
    Creating the Function I_ConvertN2W, but first you will have to create all the support functions, I am listing the function in the order of creation
    CREATE FUNCTION I_Modulus (@INPUT INT, @DIVIDER INT) 
    RETURNS INT AS 
    BEGIN
    DECLARE @RETVAL AS INT, @MODULUS AS INT
    IF @INPUT = @DIVIDER
    BEGIN
         SET @RETVAL = 0
    END
    IF @INPUT < @DIVIDER
    BEGIN
         SET @RETVAL = @INPUT
    END
    SET @MODULUS = @INPUT
    WHILE @MODULUS >= @DIVIDER
    BEGIN
         SET @MODULUS = @MODULUS - @DIVIDER
    END
    SET @RETVAL = @MODULUS
    RETURN (@RETVAL)
    END
    CREATE FUNCTION I_Mid (@sInput VARCHAR(8000), @iStart INT, @iLen INT) 
    RETURNS VARCHAR(8000) AS 
    BEGIN
    --Adapted from the Mid function of Visual Basic
    DECLARE @sRetVal AS VARCHAR(8000)
    IF @iLen = 0
    BEGIN
         SET @iLen = LEN(@sInput)-(@iStart-1)
    END
    SET @sRetVal = RIGHT(@sInput,LEN(@sInput) - (@iStart-1))
    SET @sRetVal = LEFT(@sRetVal,@iLen)
    RETURN (@sRetVal)
    END
    CREATE FUNCTION I_CN2W_GetWord (@cValue INT) 
    RETURNS nvarchar(10)
    AS 
    BEGIN
    DECLARE @sRetVal AS NVARCHAR(10)
    SET @sRetVal =
         CASE
              WHEN @cValue = 0 THEN ''
              WHEN @cValue = 1 THEN 'One'
              WHEN @cValue = 2 THEN 'Two'
              WHEN @cValue = 3 THEN 'Three'
              WHEN @cValue = 4 THEN 'Four'
              WHEN @cValue = 5 THEN 'Five'
              WHEN @cValue = 6 THEN 'Six'
              WHEN @cValue = 7 THEN 'Seven'
              WHEN @cValue = 8 THEN 'Eight'
              WHEN @cValue = 9 THEN 'Nine'
              WHEN @cValue = 10 THEN 'Ten'
              WHEN @cValue = 11 THEN 'Eleven'
              WHEN @cValue = 12 THEN 'Twelve'
              WHEN @cValue = 13 THEN 'Thirteen'
              WHEN @cValue = 14 THEN 'Fourteen'
              WHEN @cValue = 15 THEN 'Fifteen'
              WHEN @cValue = 16 THEN 'Sixteen'
              WHEN @cValue = 17 THEN 'Seventeen'
              WHEN @cValue = 18 THEN 'Eighteen'
              WHEN @cValue = 19 THEN 'Ninteen'
              WHEN @cValue = 20 THEN 'Twenty'
              WHEN @cValue = 30 THEN 'Thirty'
              WHEN @cValue = 40 THEN 'Forty'
              WHEN @cValue = 50 THEN 'Fifty'
              WHEN @cValue = 60 THEN 'Sixty'
              WHEN @cValue = 70 THEN 'Seventy'
              WHEN @cValue = 80 THEN 'Eighty'
              WHEN @cValue = 90 THEN 'Ninty'
         END
    RETURN (@sRetVal)
    END
    CREATE FUNCTION I_CN2W_GetTens (@sValue as NVARCHAR(100)) 
    RETURNS NVARCHAR(100) AS 
    BEGIN
    DECLARE @sTens AS NVARCHAR(100), @iNum AS INT, @cnt AS INT, @iDigit AS INT, @sRetVal AS NVARCHAR(100)
    SET @iNum = CAST(@sValue AS INT)
    SET @sTens = ''
    IF @iNum <= 20
    BEGIN
         SET @sRetVal =  dbo.I_CN2W_GetWord(@iNum)
    END
    ELSE
    BEGIN
         SET @cnt = 1
         WHILE @iNum > 0
              BEGIN
                   SET @iDigit = dbo.I_Modulus(@iNum, 10)
                   IF @cnt = 1
                        SET @sTens = dbo.I_CN2W_GetWord(@iDigit)
                   ELSE
                   BEGIN
                        SET @iDigit = @iDigit * 10
                        SET @sTens = dbo.I_CN2W_GetWord(@iDigit) + ' ' + @sTens
                   END
                   SET @cnt = (@cnt + 1)
                   SET @iNum = (@iNum / 10)
              END
         SET @sRetVal = @sTens
    END
    RETURN (@sRetVal)
    END
    CREATE FUNCTION I_CN2W_GetHundreds (@sValue NVARCHAR(100)) 
    RETURNS NVARCHAR(100) AS 
    BEGIN
    DECLARE @rstHun as NVARCHAR(100), @sHun as NVARCHAR(100), @sTens AS NVARCHAR(100), @sRetVal as NVARCHAR(100)
    IF RTRIM(LTRIM(@sValue)) = '000'
    BEGIN
         SET @sRetVal = ''
    END
    ELSE
    BEGIN
         SET @sHun = SUBSTRING(RTRIM(LTRIM(@sValue)),1,1)
         SET @sTens = dbo.I_CN2W_GetTens(SUBSTRING(RTRIM(LTRIM(@sValue)),2,2))
         IF (LEN(RTRIM(LTRIM(@sTens))) > 0)
         BEGIN
              SET @rstHun = dbo.I_CN2W_GetWord(CONVERT(INT, @sHun))
              IF (LEN(RTRIM(LTRIM(@rstHun))) > 0)
              BEGIN
                   SET @rstHun = @rstHun + ' Hundred and ' + @sTens
              END
              ELSE
              BEGIN
                   SET @rstHun = @sTens
              END
         END
         ELSE
         BEGIN
              SET @rstHun = dbo.I_CN2W_GetWord(CONVERT(INT, @sHun)) + ' Hundred'
         END
         SET @sRetVal = @rstHun
    END
    RETURN (@sRetVal)
    END
    CREATE FUNCTION I_CN2W_GetThousands (@sValue NVARCHAR(100)) 
    RETURNS NVARCHAR(100) AS 
    BEGIN
    DECLARE @rstHun as NVARCHAR(100), @rstThou AS NVARCHAR(100), @strHun as NVARCHAR(100), @strNum AS NVARCHAR(100), @strThou AS NVARCHAR(100)
    DECLARE @sRetVal as NVARCHAR(100)
    IF @sValue = '00000'
    BEGIN
         SET @sRetVal = ''
    END
    ELSE
    BEGIN
         SET @strNum = RTRIM(LTRIM(@sValue))
         SET @strHun =
              CASE
                   WHEN LEN(@strNum) = 4 THEN SUBSTRING(@strNum,2,3)
                   ELSE SUBSTRING(@strNum,3,3)
              END
         SET @strThou = SUBSTRING(@strNum,1,LEN(@strNum)-3)
         SET @rstHun = dbo.I_CN2W_GetHundreds(@strHun)
         SET @rstThou =
              CASE
                   WHEN CAST(@strThou AS INT) <= 20 THEN dbo.I_CN2W_GetWord(CONVERT(INT, @strThou))
                   ELSE dbo.I_CN2W_GetTens(@strThou)
              END
         IF (LEN(@rstThou)>0)
         BEGIN
              SET @rstThou = @rstThou + ' Thousand ' + @rstHun
         END
         ELSE
         BEGIN
              SET @rstThou = @rstHun
         END
         SET @sRetVal = @rstThou
    END
    RETURN (@sRetVal)
    END
    CREATE FUNCTION I_CN2W_GetLakhs (@sValue NVARCHAR(100)) 
    RETURNS NVARCHAR(100) AS 
    BEGIN
    DECLARE @rstThou as NVARCHAR(100), @rstLakhs AS NVARCHAR(100), @strLakhs as NVARCHAR(100), @strNum AS NVARCHAR(100), @strThou AS NVARCHAR(100)
    DECLARE @sRetVal as NVARCHAR(100)
    IF @sValue = '0000000'
    BEGIN
         SET @sRetVal = ''
    END
    ELSE
    BEGIN
         SET @strNum = RTRIM(LTRIM(@sValue))
         SET @strThou =
              CASE
                   WHEN LEN(@strNum) = 6 THEN SUBSTRING(@strNum,2,5)
                   ELSE SUBSTRING(@strNum,3,5)
              END
         SET @strLakhs = SUBSTRING(@strNum,1,LEN(@strNum)-5)
         SET @rstThou = dbo.I_CN2W_GetThousands(@strThou)
         SET @rstLakhs =
              CASE
                   WHEN CAST(@strLakhs AS INT) <= 20 THEN dbo.I_CN2W_GetWord(CONVERT(INT, @strLakhs))
                   ELSE dbo.I_CN2W_GetTens(@strLakhs)
              END
         IF (LEN(@rstLakhs)>0)
         BEGIN
              SET @rstLakhs = @rstLakhs + ' Lakh ' + @rstThou
         END
         ELSE
         BEGIN
              SET @rstLakhs = @rstThou
         END
         SET @sRetVal = @rstLakhs
    END
    RETURN (@sRetVal)
    END
    CREATE FUNCTION I_CN2W_GetCrores (@sValue NVARCHAR(255)) 
    RETURNS NVARCHAR(255) AS 
    BEGIN
    DECLARE @rstCro as NVARCHAR(255), @rstLakhs AS NVARCHAR(255), @strNum as NVARCHAR(100), @strLakhs AS NVARCHAR(255), @strCro AS NVARCHAR(255)
    DECLARE @sRetVal as NVARCHAR(255)
    IF @sValue = '000000000'
    BEGIN
         SET @sRetVal = ''
    END
    ELSE
    BEGIN
         SET @strNum = RTRIM(LTRIM(@sValue))
         SET @strLakhs =
              CASE
                   WHEN LEN(@strNum) = 8 THEN SUBSTRING(@strNum,2,7)
                   ELSE SUBSTRING(@strNum,3,7)
              END
         SET @strCro = SUBSTRING(@strNum,1,LEN(@strNum)-7)
         SET @rstLakhs = dbo.I_CN2W_GetLakhs(@strLakhs)
         SET @rstCro =
              CASE
                   WHEN CAST(@strCro AS INT) <= 20 THEN dbo.I_CN2W_GetWord(CONVERT(INT, @strCro))
                   ELSE dbo.I_CN2W_GetTens(@strCro)
              END
         IF LEN(@rstCro)>0
         BEGIN
              SET @rstCro = @rstCro + ' Crore ' + @rstLakhs
         END
         ELSE
         BEGIN
              SET @rstCro = @rstLakhs
         END
         SET @sRetVal = @rstCro
    END
    RETURN (@sRetVal)
    END
    CREATE FUNCTION I_CN2W_GetArabs (@sValue NVARCHAR(255)) 
    RETURNS NVARCHAR(255) AS 
    BEGIN
    DECLARE @rstArab as NVARCHAR(255), @rstCro AS NVARCHAR(255), @strNum as NVARCHAR(255), @strCro AS NVARCHAR(255), @strArab AS NVARCHAR(255)
    DECLARE @sRetVal as NVARCHAR(255)
    IF @sValue = '00000000000'
    BEGIN
         SET @sRetVal = ''
    END
    ELSE
    BEGIN
         SET @strNum = RTRIM(LTRIM(@sValue))
         SET @strCro =
              CASE
                   WHEN LEN(@strNum) = 10 THEN SUBSTRING(@strNum,2,9)
                   ELSE SUBSTRING(@strNum,3,9)
              END
         SET @strArab = SUBSTRING(@strNum,1,LEN(@strNum)-9)
         SET @rstCro = dbo.I_CN2W_GetCrores(@strCro)
         SET @rstArab =
              CASE
                   WHEN CAST(@strArab AS INT) <= 20 THEN dbo.I_CN2W_GetWord(CONVERT(INT, @strArab))
                   ELSE dbo.I_CN2W_GetTens(@strArab)
              END
         IF LEN(@rstArab)>0
         BEGIN
              SET @rstArab = @rstArab + ' Arab ' + @rstCro
         END
         ELSE
         BEGIN
              SET @rstArab = @rstCro
         END
         SET @sRetVal = @rstArab
    END
    RETURN (@sRetVal)
    END
    CREATE FUNCTION I_CN2W_GetKharabs (@sValue NVARCHAR(255)) 
    RETURNS NVARCHAR(255) AS 
    BEGIN
    DECLARE @rstArab as NVARCHAR(255), @rstKharab AS NVARCHAR(255), @strNum as NVARCHAR(255), @strKharab AS NVARCHAR(255), @strArab AS NVARCHAR(255)
    DECLARE @sRetVal as NVARCHAR(255)
    IF @sValue = '10000000000000'
    BEGIN
         SET @sRetVal = 'Hundred Kharab '
    END
    ELSE
    BEGIN
         SET @strNum = RTRIM(LTRIM(@sValue))
         SET @strArab =
              CASE
                   WHEN LEN(@strNum) = 12 THEN SUBSTRING(@strNum,2,11)
                   ELSE SUBSTRING(@strNum,3,11)
              END
         SET @strKharab = SUBSTRING(@strNum,1,LEN(@strNum)-11)
         SET @rstArab = dbo.I_CN2W_GetArabs(@strArab)
         SET @rstKharab =
              CASE
                   WHEN CAST(@strKharab AS INT) <= 20 THEN dbo.I_CN2W_GetWord(CONVERT(INT, @strKharab))
                   ELSE dbo.I_CN2W_GetTens(@strKharab)
              END
         IF @rstKharab IS NOT NULL
         BEGIN
              SET @rstKharab = @rstKharab + ' Kharab ' + @rstArab
         END
         ELSE
         BEGIN
              SET @rstKharab = @rstArab
         END
         SET @sRetVal = @rstKharab
    END
    RETURN (@sRetVal)
    END
    CREATE FUNCTION I_CN2W_GetAbvKharab (@sValue NVARCHAR(255)) 
    RETURNS NVARCHAR(255) AS 
    BEGIN
    DECLARE @rstArab as NVARCHAR(255), @rstAbvKharab AS NVARCHAR(255), @strNum as NVARCHAR(255), @strArab AS NVARCHAR(255), @strAbvKharab AS NVARCHAR(255)
    DECLARE @sRetVal as NVARCHAR(255), @ONLY AS NVARCHAR(10)
    SET @ONLY = 'Only'
    SET @strNum = RTRIM(LTRIM(@sValue))
    SET @strArab = SUBSTRING(@strNum, ((LEN(@strNum)-11)+1),11)
    SET @strAbvKharab = SUBSTRING(@strNum,1,LEN(@strNum)-11)
    SET @rstArab = dbo.I_CN2W_GetArabs(@strArab)
    SET @rstAbvKharab = REPLACE(dbo.I_ConvertN2W(CONVERT(MONEY, @strAbvKharab),0),@ONLY,'')
    SET @rstAbvKharab = @rstAbvKharab + ' Kharab ' + @rstArab
    SET @sRetVal = @rstAbvKharab
    RETURN (@sRetVal)
    END
    CREATE FUNCTION I_ConvertN2W (@curNumber MONEY, @bPrefixCurrencyName BIT)
    RETURNS VARCHAR(400) AS 
    BEGIN
    ---This Function is an Adapted (Scaled Down) version of ConvertN2W from the ITCCF32.dll Custom Functions Library by Infinite Technologies
    ---Original and Adapted (SQL) both Versions authored by Murtaza R.E. This function is provided on AS IS WHERE IS BASIS
    ---This peice of code can be freely used for all puposes, however please Do Not Forget to mention the source
    ---Suggestions and Bugs can be send to me at murtaza1972 at gmail dot com, I do not assure an immediate fix, but will try as time permits
    ---If you find this peice of code helpful, please do drop me a mail, this will encourage me to do something more creative
    DECLARE @sRetVal AS VARCHAR(400), @RUP AS NVARCHAR(10), @PAISE AS NVARCHAR(10), @ONLY AS NVARCHAR(10)
    DECLARE @curr AS MONEY, @strFirst AS VARCHAR(100), @lngDeciLen AS INT, @strDeci AS VARCHAR(100)
    DECLARE @i AS INT, @rstDeci AS VARCHAR(100), @strNum as VARCHAR(400), @lngNum AS INT, @rstNum AS VARCHAR(400)
    DECLARE @rstWord AS VARCHAR(400)
    SET @RUP =
         CASE
              WHEN (@bPrefixCurrencyName = 1) THEN 'Rupees'
              ELSE ''
         END
    SET @PAISE = 'Paise'
    SET @ONLY = 'Only'
    SET @curr = @curNumber
    IF @curr < 0
    BEGIN     
         SET @sRetVal = NULL
    END
    IF @curr = 0
    BEGIN
         SET @sRetVal = @RUP + ' Zero ' + @ONLY
    END
    SET @strFirst = LTRIM(STR(@curNumber,30,2))
    SET @lngDeciLen =
         CASE
              WHEN PATINDEX('%.%',@strFirst) > 0 THEN (LEN(@strFirst)-PATINDEX('%.%',@strFirst))
              ELSE 0
         END
    IF @lngDeciLen <> 0
    BEGIN
         SET @i = CASE
                   WHEN PATINDEX('%.%',@strFirst) > 0 THEN (PATINDEX('%.%',@strFirst) + 1)
                   ELSE 0
              END
         SET @strDeci = dbo.I_Mid(@strFirst, @i, @lngDeciLen)
    END
    ELSE
    BEGIN
         SET @strDeci = '0'
    END
    SET @strDeci =
         CASE
              WHEN LEN(@strDeci) = 1 THEN (@strDeci + '0')
              ELSE @strDeci
         END
    SET @rstDeci = dbo.I_CN2W_GetTens(@strDeci)
    SET @i =
         CASE
              WHEN PATINDEX('%.%', @strFirst)>0 THEN (PATINDEX('%.%',@strFirst)-1)
              ELSE LEN(@strFirst)
         END
    SET @strNum = dbo.I_Mid(@strFirst,1,@i)
    IF (@strNum IS NULL) OR (LEN(@strNum)=0)
    BEGIN
         SET @strNum = '0'
    END
    IF CONVERT(MONEY,@strNum) <= 99999
    BEGIN
         SET @lngNum = CONVERT(INT,@strNum)
         SET @rstNum =
              CASE
                   WHEN (@lngNum <= 20) THEN dbo.I_CN2W_GetWord(@lngNum)
                   WHEN ((@lngNum > 21) AND (@lngNum <= 99)) THEN dbo.I_CN2W_GetTens(@strNum)
                   WHEN ((@lngNum > 99) AND (@lngNum <= 999)) THEN dbo.I_CN2W_GetHundreds(@strNum)
                   WHEN ((@lngNum > 999) AND (@lngNum <= 99999)) THEN dbo.I_CN2W_GetThousands(@strNum)
              END
    END
    IF CONVERT(MONEY,@strNum) > 99999
    BEGIN
         SET @rstNum =
              CASE
                   WHEN ((CONVERT(MONEY,@strNum) > 99999) AND (CONVERT(MONEY,@strNum) <= 9999999)) THEN dbo.I_CN2W_GetLakhs(@strNum)
                   WHEN ((CONVERT(MONEY,@strNum) > 9999999) AND (CONVERT(MONEY,@strNum) <= 999999999)) THEN dbo.I_CN2W_GetCrores(@strNum)
                   WHEN ((CONVERT(MONEY,@strNum) > 999999999) AND (CONVERT(MONEY,@strNum) <= 99999999999)) THEN dbo.I_CN2W_GetArabs(@strNum)
                   WHEN (CONVERT(MONEY,@strNum) <= 10000000000000) THEN dbo.I_CN2W_GetKharabs(@strNum)
                   WHEN (CONVERT(MONEY,@strNum) > 10000000000000) THEN dbo.I_CN2W_GetAbvKharab(@strNum)
              END
    END
    IF (LEN(RTRIM(LTRIM(@rstDeci))) = 0) OR (@rstDeci IS NULL)
    BEGIN
         SET @rstWord = @RUP + ' ' + @rstNum + ' ' + @ONLY
    END
    ELSE
    BEGIN
         IF (LEN(RTRIM(LTRIM(@rstNum))) > 0) OR (@rstNum IS NOT NULL)
         BEGIN
              SET @rstWord = @RUP + ' ' + @rstNum + ' and ' + @rstDeci + ' ' + @PAISE + ' ' + @ONLY
         END
         ELSE
         BEGIN
              SET @rstWord = @rstDeci + ' ' + @PAISE + ' ' + @ONLY
         END
    END
    SET @sRetVal =
         CASE
              WHEN ((LEN(RTRIM(LTRIM(@rstWord)))=0) OR (@rstWord IS NULL)) THEN 'Zero'
              ELSE REPLACE(RTRIM(LTRIM(@rstWord)),'  ',' ')
         END     
    RETURN (@sRetVal)
    END
    Step 3:
    Code in SBO_SP_TransactionNotification
    IF ((@object_type = '46') AND (@transaction_type = 'A')) -- Outgoing PAYMENT
    BEGIN
         DECLARE @sWords AS VARCHAR(400), @iValue AS MONEY
         SET @error = 46
         SET @iValue = (SELECT [CheckSum] FROM dbo.OVPM WHERE DocEntry = @list_of_cols_val_tab_del)
         SET @sWords =
              CASE
                   WHEN @iValue > 0 THEN dbo.I_ConvertN2W(@iValue,0) --call the function only when the value is more than 0
              END
         UPDATE dbo.OVPM
              SET U_AmountInWord = @sWords
              WHERE ((DocEntry = @list_of_cols_val_tab_del) AND ([CheckSum]>0)) --we want to update only when the means of payment is by cheque
         SET @error = 0 --success
    END
    xxxxxxxxxxxxxxxENDxxxxxxxxxxxxxxxxxx---
    This is being currently used by me, and works fine for me, I hope this will be useful to you and others
    Regards,
    Murtaza R.E.

  • Amount in Words (Indian Rupees)

    Dear All,
    I am using SAP 2007B PL 18.I have found out the below mentioned function for converting the amount to words in SDN only. But when i try and create the function it gives error "Incorrect Syntax near 00' . I think there is an incomplete syntax near the SubString function. Can someone please help me on the same and give the correct function.
    Create function [dbo].[AmountToWords] ( @InNumber Numeric(18,2) )
    --Returns the number as words.
    returns VARCHAR(2000)
    as
    BEGIN
    SET NoCount ON
    Declare @Num Varchar(20)
    Declare @Dec Varchar(3)
    Declare @Return Varchar(2000)
    Set @Dec = SubString(Convert(Varchar(20),@Innumber),Len(Convert(Varchar(20),@Innumber))-2,3)
    Set @Num = SubString(Convert(Varchar(20),@Innumber),1, Len(Convert(Varchar(20),@Innumber))-3)
    Declare @Hundred Char(8) Declare @HundredAnd Char(12) Declare @Thousand Char(9)
    Declare @Lakh Char(5)
    Declare @Lakhs Char(6)
    Declare @Crore Char(6)
    Declare @Crores Char(7)
    Set @Hundred = 'Hundred '
    Set @Thousand = 'Thousand '
    Set @Lakh = 'Lakh '
    Set @Lakhs = 'Lakhs '
    Set @Crore = 'Crore '
    Set @Crores = 'Crores '
    Set @HundredAnd = 'Hundred and '
    if Len(@Num) = 1
    -- One
    Begin
    Set @Return = dbo.GetTextValue(@Num)
    End
    Else if Len(@Num) = 2
    -- Ten
    Begin
    Set @Return = dbo.GetTextValue(@Num)
    End
    Else if Len(@Num) = 3
    -- Hundred
    Begin
    Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Hundred
    IF SubString(@num,2,2) '00'
    Set @Return = @Return + 'And '
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2))
    End
    Else if Len(@Num) = 4
    -- thousand
    Begin
    Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Thousand
    If SubString(@Num,2,1) '0'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,1)) + @Hundred
    IF SubString(@num,3,2) '00'
    Set @Return = @Return + 'And '
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2))
    End
    Else if Len(@Num) = 5
    -- Ten Thousand
    Begin
    Set @Return = dbo.GetTextValue(SubString(@Num,1,2)) + @Thousand
    If SubString(@Num,3,1) '0'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,1)) + @Hundred
    IF SubString(@num,4,2) '00'
    Set @Return = @Return + 'And '
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2))
    End
    Else if Len(@Num) = 6
    -- Lakh
    Begin
    If SubString(@Num,1,1) = '1'
    Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Lakh
    Else
    Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Lakhs
    If SubString(@Num,2,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2)) + @Thousand
    If SubString(@Num,4,1) '0'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,1)) + @Hundred
    IF SubString(@num,5,2) '00'
    Set @Return = @Return + 'And '
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2))
    End
    Else if Len(@Num) = 7
    -- Ten Lakhs
    Begin
    Set @Return = dbo.GetTextValue(SubString(@Num,1,2)) + @Lakhs
    If SubString(@Num,3,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2)) + @Thousand
    If SubString(@Num,6,1) '0'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,1)) + @Hundred
    IF SubString(@num,6,2) '00'
    Set @Return = @Return + 'And '
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,2))
    End
    Else if Len(@Num) = 8
    -- Crore
    Begin
    Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Crore
    If SubString(@Num,2,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2)) + @Lakhs
    If SubString(@Num,4,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2)) + @Thousand
    If SubString(@Num,6,1) '0'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,1)) + @Hundred
    IF SubString(@num,7,2) '00'
    Set @Return = @Return + 'And '
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,7,2))
    End
    Else if Len(@Num) = 9
    -- Ten Crore
    Begin
    Set @Return = dbo.GetTextValue(SubString(@Num,1,2)) + @Crores
    If SubString(@Num,3,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2)) + @Lakhs
    If SubString(@Num,5,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2)) + @Thousand
    If SubString(@Num,7,1) '0'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,7,1)) + @Hundred
    IF SubString(@num,8,2) '00'
    Set @Return = @Return + 'And '
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,8,2))
    End
    Else if Len(@Num) = 10
    -- Hundred Crore
    Begin
    Set @Return = dbo.GetTextValue(Substring(@Num,1,1)) + @Hundred
    IF Substring(@Num,2,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2))
    Set @Return = @Return + @Crores
    If SubString(@Num,4,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2)) + @Lakhs
    If SubString(@Num,6,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,2)) + @Thousand
    If SubString(@Num,8,1) '0'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,8,1)) + @Hundred
    IF SubString(@num,9,2) '00'
    Set @Return = @Return + 'And '
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,9,2))
    End
    Else if Len(@Num) = 11
    -- Thousand Crore
    Begin Set @Return = dbo.GetTextValue(Substring(@Num,1,1)) + @Thousand
    IF SubString(@Num,2,1) '0'
    Set @Return = @Return + dbo.GetTextValue(Substring(@Num,2,1)) + @Hundred
    IF Substring(@Num,3,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2))
    Set @Return = @Return + @Crores If SubString(@Num,5,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2)) + @Lakhs
    If SubString(@Num,7,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,7,2)) + @Thousand
    If SubString(@Num,9,1) '0'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,9,1)) + @Hundred
    IF SubString(@num,10,2) '00'
    Set @Return = @Return + 'And '
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,10,2))
    End
    Else if Len(@Num) = 12
    -- Ten thousand Crore
    Begin Set @Return = dbo.GetTextValue(Substring(@Num,1,2)) + @Thousand
    IF SubString(@Num,3,1) '0'
    Set @Return = @Return + dbo.GetTextValue(Substring(@Num,3,1)) + @Hundred
    IF Substring(@Num,4,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2))
    Set @Return = @Return + @Crores If SubString(@Num,6,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,2)) + @Lakhs
    If SubString(@Num,8,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,8,2)) + @Thousand
    If SubString(@Num,10,1) '0'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,10,1)) + @Hundred
    IF SubString(@num,11,2) '00'
    Set @Return = @Return + 'And '
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,11,2))
    End
    Else if Len(@Num) = 13
    -- Lakh Crore
    Begin Set @Return = dbo.GetTextValue(Substring(@Num,1,1)) + @Lakh
    If Substring(@Num,2,2) '00'
    Set @Return = @Return + dbo.GetTextValue(Substring(@Num,2,2)) + @Thousand
    IF SubString(@Num,4,1) '0'
    Set @Return = @Return + dbo.GetTextValue(Substring(@Num,4,1)) + @Hundred
    IF Substring(@Num,5,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2))
    Set @Return = @Return + @Crores
    If SubString(@Num,7,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,7,2)) + @Lakhs
    If SubString(@Num,9,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,9,2)) + @Thousand
    If SubString(@Num,11,1) '0'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,11,1)) + @Hundred
    IF SubString(@num,12,2) '00'
    Set @Return = @Return + 'And '
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,12,2))
    End
    Else if Len(@Num) = 14
    -- Ten Lakh Crore
    Begin Set @Return = dbo.GetTextValue(Substring(@Num,1,2)) + @Lakhs
    If Substring(@Num,3,2) '00'
    Set @Return = @Return + dbo.GetTextValue(Substring(@Num,3,2)) + @Thousand
    IF SubString(@Num,5,1) '0'
    Set @Return = @Return + dbo.GetTextValue(Substring(@Num,5,1)) + @Hundred
    IF Substring(@Num,6,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,2))
    Set @Return = @Return + @Crores If SubString(@Num,8,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,8,2)) + @Lakhs
    If SubString(@Num,10,2) '00'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,10,2)) + @Thousand
    If SubString(@Num,12,1) '0'
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,12,1)) + @Hundred
    IF SubString(@num,13,2) '00'
    Set @Return = @Return + 'And '
    Set @Return = @Return + dbo.GetTextValue(SubString(@Num,13,2))
    End
    If @Dec '.00'
    Set @Return = @Return + 'Rupees And ' + dbo.GetTextValue(SubString(@Dec,2,2)) + 'Paise Only'
    ELSE
    Set @Return =@Return+'Zero Rupees Only'
    Return @return
    End
    CREATE Function [dbo].[GetTextValue] ( @dblNumber Numeric )
    Returns Varchar(1000)
    As
    Begin
    Declare @StrWord Varchar(400)
    SET @strWord = Case @dblNumber
    When 1 Then 'One '
    When 2 Then 'Two '
    When 3 Then 'Three '
    When 4 Then 'Four '
    When 5 Then 'Five '
    When 6 Then 'Six '
    When 7 Then 'Seven '
    When 8 Then 'Eight '
    When 9 Then 'Nine '
    When 10 Then 'Ten '
    When 11 Then 'Eleven '
    When 12 Then 'Twelve '
    When 13 Then 'Thirteen '
    When 14 Then 'Fourteen '
    When 15 Then 'Fifteen '
    When 16 Then 'Sixteen '
    When 17 Then 'Seventeen '
    When 18 Then 'Eighteen '
    When 19 Then 'Nineteen '
    When 20 Then 'Twenty '
    When 21 Then 'Twenty One '
    When 22 Then 'Twenty Two '
    When 23 Then 'Twenty Three '
    When 24 Then 'Twenty Four '
    When 25 Then 'Twenty Five '
    When 26 Then 'Twenty Six '
    When 27 Then 'Twenty Seven '
    When 28 Then 'Twenty Eight '
    When 29 Then 'Twenty Nine '
    When 30 Then 'Thirty '
    When 31 Then 'Thirty One '
    When 32 Then 'Thirty Two '
    When 33 Then 'Thirty Three '
    When 34 Then 'Thirty Four '
    When 35 Then 'Thirty Five '
    When 36 Then 'Thirty Six '
    When 37 Then 'Thirty Seven '
    When 38 Then 'Thirty Eight '
    When 39 Then 'Thirty Nine '
    When 40 Then 'Fourty '
    When 41 Then 'Fourty One '
    When 42 Then 'Fourty Two '
    When 43 Then 'Fourty Three '
    When 44 Then 'Fourty Four '
    When 45 Then 'Fourty Five '
    When 46 Then 'Fourty Six '
    When 47 Then 'Fourty Seven '
    When 48 Then 'Fourty Eight '
    When 49 Then 'Fourty Nine '
    When 50 Then 'Fifty '
    When 51 Then 'Fifty One '
    When 52 Then 'Fifty Two '
    When 53 Then 'Fifty Three '
    When 54 Then 'Fifty Four '
    When 55 Then 'Fifty Five '
    When 56 Then 'Fifty Six '
    When 57 Then 'Fifty Seven '
    When 58 Then 'Fifty Eight '
    When 59 Then 'Fifty Nine '
    When 60 Then 'Sixty '
    When 61 Then 'Sixty One '
    When 62 Then 'Sixty Two '
    When 63 Then 'Sixty Three '
    When 64 Then 'Sixty Four '
    When 65 Then 'Sixty Five '
    When 66 Then 'Sixty Six '
    When 67 Then 'Sixty Seven '
    When 68 Then 'Sixty Eight '
    When 69 Then 'Sixty Nine '
    When 70 Then 'Seventy '
    When 71 Then 'Seventy One '
    When 72 Then 'Seventy Two '
    When 73 Then 'Seventy Three '
    When 74 Then 'Seventy Four '
    When 75 Then 'Seventy Five '
    When 76 Then 'Seventy Six '
    When 77 Then 'Seventy Seven '
    When 78 Then 'Seventy Eight '
    When 79 Then 'Seventy Nine '
    When 80 Then 'Eighty '
    When 81 Then 'Eighty One '
    When 82 Then 'Eighty Two '
    When 83 Then 'Eighty Three '
    When 84 Then 'Eighty Four '
    When 85 Then 'Eighty Five '
    When 86 Then 'Eighty Six '
    When 87 Then 'Eighty Seven '
    When 88 Then 'Eighty Eight '
    When 89 Then 'Eighty Nine '
    When 90 Then 'Ninety '
    When 91 Then 'Ninety One '
    When 92 Then 'Ninety Two '
    When 93 Then 'Ninety Three '
    When 94 Then 'Ninety Four '
    When 95 Then 'Ninety Five '
    When 96 Then 'Ninety Six '
    When 97 Then 'Ninety Seven '
    When 98 Then 'Ninety Eight '
    When 99 Then 'Ninety Nine '
    When 100 Then 'One hundred '
    else ' '
    End
    Return @strWord
    End
    Regards,
    Rahul

    Dear Rahul,
    Try this,
    ->> Create 1 UDF in Header on Requrie Documents (ex. Marketing Documents).
    ->> Create 3 Function in MSSQL Server Management.
    ->> Create 1 FMS in Query Generator and save as Query Manager then Assign to UDF for Amount in Words.
    for example:
    Create UDF in Header on Marketing Documents.
    ->> Choose Tools on Top menu.
    ->> User - Defined Fields. -> User Manage Fields.
    ->> Open the User Manage Fields Widnow.
    ->> Marketing Documents. -> Title.
    ->> Select Title and Click Add button in Bottom on User Manage Fields Window.
    ->> Create Amount in Words UDF(Code, Discription and Type - Character) and Add the UDF.
    Create Function in MSSQL Server Management.
    Check this Link, (have 3 Functions in Link).
    http://techcreeze.blogspot.com/2008/11/convert-amount-into-words-according-to_15.html
    1st Funciton - to Convert one Digit Number to words
    2nd Funciton - to convert 2 digit number to words.
    3rd Funciton - to convert amt in numbers to words.
    ->> Open the MSSQL Server Management Window.
    ->> Choose your Company database and Create NEW Query.
    ->> Create 3 Function Queries one by one.
    ->> Create 3 NEW Query Tab and 1st one put the 1st Function then Run the Function. and
    2nd New Query tab put the 2nd Function then Run the Function.
    3rd New Query tab put the 3rd Function then Run the Function.
    Create FMS in Query Generator and Save as Query Manager.
    ->> Adminstration.
    ->> Reports. -> Query Generator.
    ->> Open the Query Generator and put the below FMS query.
    for example : Purchase Order Doc. Toal(in wrods).
    declare @Doc_total numeric (19,6)
    set @Doc_total=$[OPOR.DocTotal]
    select  dbo.fNumToWords (@Doc_total)
    ->> Assign the FMS in UDF on Purchase Order.
    ->> Auto Refresh of Document Total.
    Ex.
    1. Goto the UDF and Clcik ShiftAltF2.
    2. Select the SEARCH BY SAVED QUERY.
    3. Assign the FMS Query.
    4. Select the AUTO REFRESH WHEN FIELD CHENGES.
    5. Select Document Total.
    6. Check the Display Saved Values.

  • How to convert standard (Western) numerical format to Indian format?

    I have been doing a lot of research and while I've repeatedly found the function module to convert numerical amounts in to words (HR_IN_CHG_INR_WRDS) I haven't found a way to convert a standard numerical format, 121,212,123 in to the Indian format of 12,12,12,123 or 505,000 to 5,05,000 for example.
    I repeatedly saw in other threads people were suggesting to change the decimal format of the currency in OY01 however the Indian format option is not listed.  We only have the following options:
    X 1,234,567.89
    Y 1 234 567,89
        1.234.567,89
    Whereas I would need 12,34,567.89.
    Is there a Function Module we can use? Is there some CIN add-on we need to import to make the additonal decimal format available?
    Thanks in advance

    Check [this link>>>|http://www.xe.com/ucc/convert.cgi?Amount=10000000&From=USD&To=INR&image.x=62&image.y=20&image=Submit]
    else.. You might have to write a conversion routine...
    DATA: curr TYPE netwr,
          c(20) TYPE c.
    curr = '1234567890'.
    WRITE:/ 'before:', curr.
    WRITE curr TO c USING EDIT MASK '__,__,___.__'.
    WRITE:/ 'after:', c.

  • Print Layout : Amount in Words

    Hai To All,
           I customize print layout of A/P Invoice on that i have some problem:
    1) there iam calculating total amount.At the bottom of my page that amount should display in words.How to do that???
    2) In between repetitive Area and End of Report there is no border while taking print its not looking good.
    Anyone have idea about this????
    Regards,
    Anitha

    Hi Ani,
              For 1st question:
    1. select the that field. goto Properties
    2. In General Tab u can find Link to Textbox
    3. In that textbox select the field-id of the Total Amount
    4. Now goto Format tab, select the Amount in words check box 
            This is the way u can print Amount in words.
            For 2nd Question:
    1. select the repetitive area in Field Index window
    2. Now goto Properties Window, select the Border Tab
    3. there, in low textbox, put 1.
    Thanks,
    Suresh Yerra

  • How to display amount in words in the last page

    Hi,
    I am very new to Oracle Report, but v.good experience in Crystal report.
    How can i display amount in words for an invoice amount total in the last page of the invoice and after total amount. I created a new non repeating frame and put the amount in words inside that, and set the frames diplay property Print on Last Page, but the problem is already there is a repeating frame to print all the invoices item, and the total in figure. But the amount in words frame is not always coming after the total amount,either it should be at the bottom of the last page in fixed position, otherwise it should move just below the total amount.
    I am using Oracle 11g.
    Thanks in advance...
    Fsl

    Hi ,
    Use This function
    create or replace FUNCTION xxg4_zen_conv_words (p_amount IN Number) RETURN Varchar2 IS
    --Creation Date   :  11-DEC-2009
    --Purpose         :  This Function returns amount in words.
    --Parameters      :
    --1) p_amount : Only positive and negative values are allowed.
    Precision can be entered upto 10 digits and only 2 scales
    are allowed e.g 9999999999.99
    -- Index by Tables to store word list
    TYPE typ_word_list IS TABLE OF Varchar2(200) INDEX BY BINARY_INTEGER;
    t_typ_word_list typ_word_list;
    TYPE typ_word_gap IS TABLE OF Varchar2(200) INDEX BY BINARY_INTEGER;
    t_typ_word_gap typ_word_gap;
    -- Local Variables
    v_amount Number := p_amount;
    v_amount_length Number;
    v_words Varchar2(10000);
    v_point_found Varchar2(1) := 'N';
    v_point_value Number;
    BEGIN
    /*Getting value after point if found */
    v_point_value := SUBSTR(v_amount,(INSTR(v_amount,'.',1) + 1),2);
    /*Checking whether amount has any scale value also */
    v_point_found := CASE WHEN (INSTR(v_amount,'.',1)) = 0 THEN 'N'
    WHEN (INSTR(v_amount,'.',1)) > 0 THEN 'Y'
    END;
    /*Converting amount into pure numeric format */
    v_amount := FLOOR(ABS(v_amount));
    v_amount_length := LENGTH(v_amount);
    t_typ_word_gap(2) := 'and Paise';
    t_typ_word_gap(3) := 'Hundred';
    t_typ_word_gap(4) := 'Thousand';
    t_typ_word_gap(6) := 'Lakh';
    t_typ_word_gap(8) := 'Crore';
    t_typ_word_gap(10) := 'Arab';
    FOR i IN 1..99
    LOOP
    t_typ_word_list(i) := To_Char(To_Date(i,'J'),'Jsp');
    END LOOP;
    IF v_amount_length <= 2
    THEN
    /* Conversion 1 to 99 digits */
    v_words := t_typ_word_list(v_amount);
    ELSIF v_amount_length = 3
    THEN
    /* Conversion for 3 digits till 999 */
    v_words := t_typ_word_list(SUBSTR(v_amount,1,1))||' '||t_typ_word_gap(3);
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,2,2));
    ELSIF v_amount_length = 4
    THEN
    /* Conversion for 4 digits till 9999 */
    v_words := t_typ_word_list(SUBSTR(v_amount,1,1))||' '||t_typ_word_gap(4);
    IF SUBSTR(v_amount,2,1) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,2,1))||' '||t_typ_word_gap(3);
    END IF;
    IF SUBSTR(v_amount,3,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,3,2));
    END IF;
    ELSIF v_amount_length = 5
    THEN
    /* Conversion for 5 digits till 99999 */
    v_words := t_typ_word_list(SUBSTR(v_amount,1,2))||' '||t_typ_word_gap(4);
    IF SUBSTR(v_amount,3,1) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,3,1))||' '||t_typ_word_gap(3);
    END IF;
    IF SUBSTR(v_amount,4,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,4,2));
    END IF;
    ELSIF v_amount_length = 6
    THEN
    /* Conversion for 6 digits till 999999 */
    v_words := t_typ_word_list(SUBSTR(v_amount,1,1))||' '||t_typ_word_gap(6);
    IF SUBSTR(v_amount,2,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,2,2))||' '||t_typ_word_gap(4);
    END IF;
    IF SUBSTR(v_amount,4,1) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,4,1))||' '||t_typ_word_gap(3);
    END IF;
    IF SUBSTR(v_amount,5,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,5,2));
    END IF;
    ELSIF v_amount_length = 7
    THEN
    /* Conversion for 7 digits till 9999999 */
    v_words := t_typ_word_list(SUBSTR(v_amount,1,2))||' '||t_typ_word_gap(6);
    IF SUBSTR(v_amount,3,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,3,2))||' '||t_typ_word_gap(4);
    END IF;
    IF SUBSTR(v_amount,5,1) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,5,1))||' '||t_typ_word_gap(3);
    END IF;
    IF SUBSTR(v_amount,6,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,6,2));
    END IF;
    ELSIF v_amount_length = 8
    THEN
    /* Conversion for 8 digits till 99999999 */
    v_words := t_typ_word_list(SUBSTR(v_amount,1,1))||' '||t_typ_word_gap(8);
    IF SUBSTR(v_amount,2,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,2,2))||' '||t_typ_word_gap(6);
    END IF;
    IF SUBSTR(v_amount,4,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,4,2))||' '||t_typ_word_gap(4);
    END IF;
    IF SUBSTR(v_amount,6,1) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,6,1))||' '||t_typ_word_gap(3);
    END IF;
    IF SUBSTR(v_amount,7,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,7,2));
    END IF;
    ELSIF v_amount_length = 9
    THEN
    /* Conversion for 9 digits till 999999999 */
    v_words := t_typ_word_list(SUBSTR(v_amount,1,2))||' '||t_typ_word_gap(8);
    IF SUBSTR(v_amount,3,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,3,2))||' '||t_typ_word_gap(6);
    END IF;
    IF SUBSTR(v_amount,5,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,5,2))||' '||t_typ_word_gap(4);
    END IF;
    IF SUBSTR(v_amount,7,1) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,7,1))||' '||t_typ_word_gap(3);
    END IF;
    IF SUBSTR(v_amount,8,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,8,2));
    END IF;
    ELSIF v_amount_length = 10
    THEN
    /* Conversion for 10 digits till 9999999999 */
    v_words := t_typ_word_list(SUBSTR(v_amount,1,1))||' '||t_typ_word_gap(10);
    IF SUBSTR(v_amount,2,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,2,2))||' '||t_typ_word_gap(8);
    END IF;
    IF SUBSTR(v_amount,4,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,4,2))||' '||t_typ_word_gap(6);
    END IF;
    IF SUBSTR(v_amount,6,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,6,2))||' '||t_typ_word_gap(4);
    END IF;
    IF SUBSTR(v_amount,8,1) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,8,1))||' '||t_typ_word_gap(3);
    END IF;
    IF SUBSTR(v_amount,9,2) != 0
    THEN
    v_words := v_words ||' '||t_typ_word_list(SUBSTR(v_amount,9,2));
    END IF;
    END IF;
    IF v_point_found = 'Y'
    THEN
    IF v_point_value != 0
    THEN
    v_words := v_words||' '||t_typ_word_gap(2)||' '||t_typ_word_list(CASE WHEN LENGTH(SUBSTR(p_amount,(INSTR(p_amount,'.',1) + 1),2)) = 1 THEN SUBSTR(p_amount,(INSTR(p_amount,'.',1) + 1),2)||'0'
    WHEN LENGTH(SUBSTR(p_amount,(INSTR(p_amount,'.',1) + 1),2)) = 2 THEN SUBSTR(p_amount,(INSTR(p_amount,'.',1) + 1),2)
    END);
    END IF;
    END IF;
    IF p_amount < 0
    THEN
    v_words := 'Minus '||v_words;
    ELSIF p_amount = 0
    THEN
    v_words := 'Zero';
    END IF;
    IF LENGTH(v_amount) > 10
    THEN
    v_words := 'Value larger than specified precision allowed to convert into words. Maximum 10 digits allowed for precision.';
    END IF;
    RETURN (v_words);
    END xxg4_Zen_Conv_Words;
    --Thanks
    SAGAR SANKPAL

  • Converting the amount in words

    Hi ,
    Issues is like if the amount is $137,510.82 for US currency it should give as   ONE HUNDRED THIRTY-SEVEN THOUSAND FIVE HUNDRED TEN USD and 82/100.
    But when the document currency is german in the check it should give as ONE HUNDRED THIRTY THOPUSAND AND 51082/100.
    THE LOGIC SHOULD BE CURRENCY DEPENDENT.
    HOW DO I DI THIS...

    following is a customized report to convert amount to words...
    *& Report  ZCFM_REPT_RUPEE_CONVERSION                                  *
    *This report is a copy of report 'ZRUPECO1' in Tengl server            *
    Date                    :  25-Oct-2006                               *
    Author                  :  Amiya Shrivastava                         *
    Title                   :  Report to convert amount into words as per*
                               Indian spelling conventions               *
    Original Request number :  DEVK917286                                *
    report  zcfm_rept_rupee_conversion              .
    include zcfm_incl_rupee_conv_data.
    *&      Form  COVERSION1
          text
         -->NUMBER     text
         -->ANS        text
    form coversion1 using number changing ans.
      clear: gtab,
             giritab,
             giriline,
             girijtab,
             line ,
             ans,
             init, initnam, initno , init1,
             cnam1, cnam2, cnam3,cnam4, point,jpoint,
             kpoint,lpoint1, lpoint2,lpoint,fpoint,
             cnt1 , cnt2, cnt3 ,
             flhun, flth, flla, flcr1,flcr2, flchu1, flchu2, flpt, res.
      refresh :
             itab ,
             ktab ,
             jtab .
      init = number.
      init1 = init.
      cnt1 = strlen( init ).
      cnt2 = cnt1 - 1.
      do cnt1 times.
        initnam = init+0(1).
        shift init by 1 places left.
        if initnam = '.'.
          cnam1 = init1+0(initno).
        endif.
        initno = initno + 1.
      enddo.
      do cnt1 times.
        cnam2 = init1+0(1).
        shift init1 by 1 places left.
        if cnam2 = '.'.
          point = init1+0(2).
          exit.
        endif.
      enddo.
      do 2 times.
        jpoint = point+0(1).
        shift point by 1 places left.
        if sy-index = 1.
          kpoint = point.
        endif.
        perform points.
      enddo.
      cnt1 = strlen( cnam1 ).
      do cnt1 times.
        cnam2 = cnam1+0(1).
        perform calcu .
        shift cnam1 by 1 places left.
      enddo.
      sort itab descending by index.
      loop at itab.
        if sy-tabix = 1.
          jtab-result = itab-result.
          jtab-index = itab-index.
          append jtab.
        else.
          if itab-result = 'One  ' and  ( sy-tabix = 2 or sy-tabix = 5 or
                    sy-tabix = 7 or sy-tabix = 9 ).
            perform teens.
            move space to line-result.
            modify jtab from line index cnt3 transporting result .
          else.
            if itab-result <> space.
              perform ties.
            else.
              jtab-result = itab-result.
              jtab-index = itab-index.
              append jtab.
            endif.
          endif.
        endif.
        cnt3 = sy-tabix.
        res = itab-result.
      endloop.
      skip.
      loop at jtab.
        case sy-tabix.
          when 10.
            if jtab-result <> space.
              if flcr1 = 'X' and flcr2 = 'X'.
                concatenate jtab-result 'Hundred Crores' into line-result
                      separated by ' '.
                modify jtab from line index sy-tabix transporting result.
              else.
                concatenate jtab-result 'Hundred AND' into line-result
                      separated by ' '.
                modify jtab from line index sy-tabix transporting result.
              endif.
            endif.
          when 9.
            if flcr1 = 'X'.
              if jtab-result <> space.
                concatenate jtab-result 'Crores' into line-result
                                separated by ' '.
                modify jtab from line index sy-tabix transporting result.
              else.
                flcr2 = 'X'.
              endif.
            endif.
          when 8.
            if jtab-result <> space.
              concatenate jtab-result 'Crores' into line-result
                              separated by ' '.
              modify jtab from line index sy-tabix transporting result.
            else.
              flcr1 = 'X'.
            endif.
          when 7.
            if flla = 'X'.
              if jtab-result <> space.
                concatenate jtab-result 'Lacs' into line-result
                            separated by ' '.
                modify jtab from line index sy-tabix transporting result.
              endif.
            endif.
          when 6.
            if jtab-result <> space.
              concatenate jtab-result 'Lacs' into line-result
                             separated by ' '.
              modify jtab from line index sy-tabix transporting result.
            else.
              flla = 'X'.
            endif.
          when 5.
            if jtab-result <> space.
              if flth = 'X'.
                concatenate jtab-result 'Thousand' into line-result
                 separated by ' '.
                modify jtab from line index sy-tabix transporting result.
              endif.
            endif.
          when 4.
            if jtab-result <> space.
              concatenate jtab-result 'Thousand' into line-result
                       separated by ' '.
              modify jtab from line index sy-tabix transporting result.
            else.
              flth = 'X'.
            endif.
          when 3.
            if jtab-result <> space.
              if flchu1 = 'X' and flchu2 = 'X'.
                concatenate jtab-result 'Hundred' into line-result
                    separated by ' '.
              else.
                concatenate jtab-result 'Hundred AND' into line-result
                    separated by ' '.
              endif.
              modify jtab from line index sy-tabix transporting result.
            else.
              flhun = 'X'.
            endif.
          when 2.
            if jtab-result = space.
              flchu2 = 'X'.
            endif.
          when 1.
            if jtab-result = space.
              flchu1 = 'X'.
            endif.
        endcase.
      endloop.
    *SORT JTAB ASCENDING BY INDEX.
      loop at jtab.
        if sy-tabix = 1.
          cnam4 = jtab-result.
        else.
          concatenate jtab-result cnam4  into cnam4 separated by space.
        endif.
      endloop.
      if lpoint2 = space and lpoint1 = space.
        lpoint = 'only'.
      else.
        concatenate 'Paise' lpoint2 lpoint1 'only' into lpoint separated by
        space.
      endif.
      if cnam4 <> space.
        shift cnam4 left deleting leading space.
        concatenate 'Rupees' cnam4 lpoint into ans separated by space.
    *WRITE : / 'RUPEES', CNAM4.
    *WRITE : / ANS.
      endif.
    endform.                                                    "COVERSION1
    *WRITE : / LPOINT NO-GAP.
    form ties.
      jtab-index = itab-index.
      if sy-tabix = 2 or sy-tabix = 5 or sy-tabix = 7 or sy-tabix = 9.
        case itab-result.
          when 'Two  '.
            jtab-result = 'Twenty'.
          when 'Three'.
            jtab-result = 'Thirty'.
          when 'Four '.
            jtab-result = 'Fourty'.
          when 'Five '.
            jtab-result = 'Fifty'.
          when 'Six  '.
            jtab-result = 'Sixty'.
          when 'Seven'.
            jtab-result = 'Seventy'.
          when 'Eight'.
            jtab-result = 'Eighty'.
          when 'Nine '.
            jtab-result = 'Ninety'.
          when space.
            jtab-result = space.
        endcase.
      else.
        jtab-result = itab-result.
      endif.
      append jtab.
    endform.                    "TIES
    *&      Form  TEENS
          text
    form teens.
      jtab-index = itab-index.
      case res.
        when 'One  '.
          jtab-result = 'Eleven'.
        when 'Two  '.
          jtab-result = 'Twelve'.
        when 'Three'.
          jtab-result = 'Thirteen'.
        when 'Four '.
          jtab-result = 'Fourteen'.
        when 'Five '.
          jtab-result = 'Fifteen'.
        when 'Six  '.
          jtab-result = 'Sixteen'.
        when 'Seven'.
          jtab-result = 'Seventeen'.
        when 'Eight'.
          jtab-result = 'Eighteen'.
        when 'Nine '.
          jtab-result = 'Nineteen'.
        when space.
          jtab-result = 'Ten'.
      endcase.
      append jtab.
    endform.                    "TEENS
    *&      Form  CALCU
          text
    form calcu .
      itab-index = sy-index.
      case cnam2.
        when '1'.
          itab-result = 'One'.
        when '2'.
          itab-result = 'Two'.
        when '3'.
          itab-result = 'Three'.
        when '4'.
          itab-result = 'Four'.
        when '5'.
          itab-result = 'Five'.
        when '6'.
          itab-result = 'Six'.
        when '7'.
          itab-result = 'Seven'.
        when '8'.
          itab-result = 'Eight'.
        when '9'.
          itab-result = 'Nine'.
        when '0'.
          itab-result = space.
      endcase.
      append itab.
    endform.                    "CALCU
    *&      Form  POINTS
          text
    form points.
      if sy-index = 2.
        if fpoint = space.
          case jpoint.
            when '1'.
              lpoint1 = 'One'.
            when '2'.
              lpoint1 = 'Two'.
            when '3'.
              lpoint1 = 'Three'.
            when '4'.
              lpoint1 = 'Four'.
            when '5'.
              lpoint1 = 'Five'.
            when '6'.
              lpoint1 = 'Six'.
            when '7'.
              lpoint1 = 'Seven'.
            when '8'.
              lpoint1 = 'Eight'.
            when '9'.
              lpoint1 = 'Nine'.
            when '0'.
              lpoint1 = space.
          endcase.
        endif.
      endif.
      if sy-index = 1.
        case jpoint.
          when '1'.
            perform lpointy.
          when '2'.
            lpoint2 = 'Twenty'.
          when '3'.
            lpoint2 = 'Thirty'.
          when '4'.
            lpoint2 = 'Forty'.
          when '5'.
            lpoint2 = 'Fifty'.
          when '6'.
            lpoint2 = 'Sixty'.
          when '7'.
            lpoint2 = 'Seventy'.
          when '8'.
            lpoint2 = 'Eighty'.
          when '9'.
            lpoint2 = 'Ninety'.
          when '0'.
            lpoint2 = space.
        endcase.
      endif.
    endform.                    "POINTS
    *&      Form  LPOINTY
          text
    form lpointy.
      case kpoint.
        when '1'.
          lpoint2 = 'Eleven'.
        when '2'.
          lpoint2 = 'Twelve'.
        when '3'.
          lpoint2 = 'Thirteen'.
        when '4'.
          lpoint2 = 'Fourteen'.
        when '5'.
          lpoint2 = 'Fifteen'.
        when '6'.
          lpoint2 = 'Sixteen'.
        when '7'.
          lpoint2 = 'Seventeen'.
        when '8'.
          lpoint2 = 'Eighteen'.
        when '9'.
          lpoint2 = 'Nineteen'.
        when '0'.
          lpoint2 = 'Ten'.
      endcase.
      lpoint1 = space.
      fpoint = 'X'.
    endform.                    "LPOINTY

  • How to display currency values in indian format

    hi all,
       When I am displaying Currency values as output , those are displaying in U.S. format (ie.1,234,000.00) , But I need to display those in Indian Rupee format (i.e 12,34,000.00).
    Plz any one can help me that how to display this
    thank you,
    regards
    Hanuma

    Hi Hanuma kumar, please try this code.
    REPORT ZAMOUNT_CONVERSION.
    DATA : RESULT1(20).
    PARAMETERS : NUM TYPE P DECIMALS 2.
    DATA : num2 type STRING.
    DATA :  col_amt(20) type n,"15
             col_b type i,
             num_1(20) type C,"15
             Length type i.
    num_1 = num.
    write : 'default format      :',num.
    uline.
    skip.
    IF ( num >= 999999999 ).
           write num_1 using edit mask 'RR__,__,__,__,______' to col_amt.
           CONDENSE col_amt.
           length = STRLEN( col_amt ).
           if length = 16.
             REPLACE first OCCURRENCE OF ',' in col_amt with space.
             write :/'amount indian format:',col_amt.
           else.
           write :/'amount indian format:',col_amt.
           endif.
    ELSEIF NUM < 999999999 AND NUM >= 9999999.
           write num_1 using edit mask 'RR__,__,__,______' to col_amt.
           condense col_amt .
           length = STRLEN( COL_AMT ).
           if length = 13.
             REPLACE first OCCURRENCE OF ',' in col_amt with space.
             write :/'amount indian format:',col_amt.
           else.
             write :/'amount indian format:',col_amt.
          endif.
    ELSEIF NUM < 9999999  AND NUM >= 99999.
           write num_1 using edit mask 'RR__,__,______' to col_amt.
           condense col_amt .
           length = STRLEN( COL_AMT ).
           write :/'amount indian format:',col_amt.
    ELSEIF NUM < 99999.
       data : dumy(10) type c.
       dumy = num .
       CONDENSE dumy.
       length = STRLEN( dumy ).
         if length <= 6.
           write :/'amount indian format:',num.
           else.
           write num_1 using edit mask 'RR__,______' to col_amt.
           write :/'amount indian format:',col_amt.
          endif.
       ENDIF.
       uline.

  • Convert Amount in Numbers into Amount in Words

    Hello everyone,
    I am tasked to draft format for our company's check printing layout using Numbers/Pages, I already did but since the existing format was just manual inputted by the users, it always resulting to typographical errors on our printed checks, particularly the 'amount in words'. May I please ask for anybody's help on how to to do this automatically:
    Amount in Figure
    Amount in Words
    1,500.50
    ONE THOUSAND FIVE HUNDRED AND 50/100
    Thanks and best regards,
    DirekRod

    Try this website I found:
    http://www.easysurf.cc/cnvert18.htm
    http://javascript.about.com/library/bltoword.htm?inum=345.76&rnum=
    I will look at how to use an Applescript to perform the conversion but I cannot get to it right now.

  • Reg Currency Description and Amount in words

    Hi
    Can anybody help me out in finding Function Module for Currency Descripton and Amount in words.
    For  Example, if currency type is <b>USD</b> and the amount is <b>29,012.50</b>
    then it should display the currency description as <b>The sum of US Dollars</b> and the amount in words as <b>Twenty Nine Thousand Twelve and Cents Fifty</b> and it should work for any currency type.
    Thanks in Advance.
    Swathi

    Hi swathi,
    Cents are not known in SAP only USD with decimal places in known.
    however check if this can solve teh problem...
    for indian currency inr use the below function module....
    HR_IN_CHG_INR_WRDS
    for usd currency use the following code as an example..
    data: amt_in type  pc207-betrg value '29012.50'.
    data: words type spell.
    data: result type string.
    call function 'SPELL_AMOUNT'
    exporting
       amount          = amt_in
       currency        = 'USD'
      FILLER          = ' '
      LANGUAGE        = SY-LANGU
    importing
       in_words        = words
    EXCEPTIONS
      NOT_FOUND       = 1
      TOO_LARGE       = 2
      OTHERS          = 3
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    concatenate 'USD' words-word 'AND' words-decword 'CENTS'
             into result separated by space.
    write:/ result.
    hope this helps,
    all the best,
    sampath
    award helpful answers

Maybe you are looking for