Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Amount in Words in INR

Hi Guys,,,

Actually we are facing some problem with the amount in words in sap.

My client needs amount in words to be printed in Indian formats for JE's,Incoming & Outgoing Payments,checks and Sales and Purchase documents....

Please give me some solution to acheive this..

Thanks in Advance,

Vams........

Former Member
Former Member replied

Hi,

I have found the below one from some previous thread.

--******************************************-- 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 -- 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 --******************************************-- --******************************************-- 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 -- ----******************************************-- create function AmountToWords (@InNumber Numeric(18,2)) returns VARCHAR(2000) as BEGIN 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 ' -- Ones IF Len(@Num) = 1 Begin Set @Return = dbo.GetTextValue(@Num) End -- Tens Else IF Len(@Num) = 2 Begin Set @Return = dbo.GetTextValue(@Num) End -- Hundreds Else IF Len(@Num) = 3 Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Hundred IF SubString(@num,2,2)!='00'Begin Set @Return = @Return + 'and ' + dbo.GetTextValue(SubString(@Num,2,2)) End End -- thousand Else if Len(@Num) = 4 Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Thousand If SubString(@Num,2,1)!='0' Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,1)) + @Hundred End IF SubString(@num,3,2)!='00' Begin Set @Return = @Return + 'and ' + dbo.GetTextValue(SubString(@Num,3,2)) End End Else if Len(@Num) = 5 -- Ten Thousand Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,2)) + @Thousand If SubString(@Num,3,1) !='0' Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,1)) + @Hundred End IF SubString(@num,4,2) !='00' Begin Set @Return = @Return + 'And ' + dbo.GetTextValue(SubString(@Num,4,2)) --Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2)) End End -- Lakh Else if Len(@Num) = 6 Begin IF SubString(@Num,1,1) > 1 Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Lakhs End Else Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Lakh End If SubString(@Num,2,2)!='00' Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2)) + @Thousand End IF SubString(@num,4,1)!='0' Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,1)) + @Hundred End IF SubString(@num,5,2)!='00' Begin Set @Return = @Return + 'and ' + dbo.GetTextValue(SubString(@Num,5,2)) End End -- Ten Laksh Else if Len(@Num) = 7 Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,2)) + @Lakhs IF SubString(@Num,3,2) != '00' Begin set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2)) + @Thousand End IF SubString(@Num,5,1) != '0' Begin set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,1)) + @Hundred End IF SubString(@Num,6,2) != '00' Begin Set @Return = @Return + 'and '+ dbo.GetTextValue(SubString(@Num,6,2)) End End -- Crore Else If Len(@Num) = 8 Begin IF SubString(@Num,1,1) > 1 Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Crores End Else Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Crore End IF SubString(@Num,2,2) != '00' Begin IF SubString(@Num,2,1) > 1 Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2)) + @Lakhs End Else Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,2)) + @Lakh End End IF Substring(@Num,4,2) != '00' Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2)) + @Thousand End IF SubString(@Num,6,1) != '0' Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,1)) + @Hundred End IF SubString(@Num,7,2) != '00' Begin Set @Return = @Return + 'and ' + dbo.GetTextValue(SubString(@Num,7,2)) End End -- Ten Crore Else if Len(@Num) = 9 Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,2)) + @Crores IF SubString(@Num,3,2) != '00' Begin IF SubString(@Num,3,1) > 1 Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2)) + @Lakhs End Else Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,3,2)) + @Lakh End End IF SubString(@Num,5,2) != '00' Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2)) + @Thousand End IF SubString(@Num,7,1) != '0' Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,7,1)) + @Hundred End IF SubString(@Num,8,2) !='00' Begin Set @Return = @Return + 'and ' + dbo.GetTextValue(SubString(@Num,8,2)) End End Else if Len(@Num) = 10 Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Hundred if SubString(@Num,2,2) != '00' Begin Set @Return = @Return + 'and ' + dbo.GetTextValue(SubString(@Num,2,2)) End Set @Return = @Return + @Crores if SubString(@Num,4,2)!='00' Begin IF SubString(@Num,4,2) > 1 Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2)) + @Lakhs End Else Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,4,2)) + @Lakh End End if SubString(@Num,6,2) !='00' Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,6,2)) + @Thousand End if Substring(@Num,8,3) != '000' Begin if SubString(@Num,8,1) != '0' Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,8,1)) + @Hundred End if SubString(@Num,9,2) != '00' Begin Set @Return = @Return + 'and ' + dbo.GetTextValue(SubString(@Num,9,2)) End End End Else if Len(@Num) = 11 Begin Set @Return = dbo.GetTextValue(SubString(@Num,1,1)) + @Thousand If SubString(@Num,2,3) !='000' Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,2,1)) + @Hundred End If SubString(@Num,3,2) != '00' Begin Set @Return = @Return + 'and ' + dbo.GetTextValue(SubString(@Num,3,2)) End Set @Return = @Return + @Crores If SubString(@Num,5,2) != '00' Begin IF SubString(@Num,5,2) > 1 Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2)) + @Lakhs End Else Begin Set @Return = @Return + dbo.GetTextValue(SubString(@Num,5,2)) + @Lakh End End End Set @Return = @Return + ' Rupee(s) only' return @Return End --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. --------------------------------------------------- FMS in UDF --- for Invocie--- SELECT dbo.amounttowords($[OINV.DocTotal]) ->> Assign the FMS in UDF on Outgoing Payments. ->> Auto Refresh of REMARKS. Ex. 1. Goto the UDF and Clcik Shift+Alt+F2. 2. Select the SEARCH BY SAVED QUERY. 3. Assign the FMS Query. 4. Select the AUTO REFRESH WHEN FIELD CHENGES. 5. Select REMARKS. 6. Check the Display Saved Values.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question