* Test Program
Report ZJNC3.
Data: OffSet type I,
Amt2Words type String.
Selection-Screen: Begin of Block B1Opts with Frame Title TEXT-002.
Parameters: MyAmount type P Decimals 2 ,
MyChrsLn type I ,
MyNumLns type I .
Selection-Screen: End of Block B1Opts.
CALL FUNCTION 'ZAMT2WORDS'
EXPORTING
AMOUNT = MyAmount
CHRSLINE = MyChrsLn
NUMLINES = MyNumLns
CHANGING
AMT2WDS = Amt2Words.
Move 0 to OffSet.
Do MyNumLns Times.
Write: / Amt2Words+OffSet(MyChrsLn).
Add MyChrsLn to OffSet.
EndDo.
------------------------------------------------------------------------------------------
* Function Module ZAMT2WORDS
FUNCTION ZAMT2WORDS.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(AMOUNT) TYPE P
*" REFERENCE(CHRSLINE) TYPE I
*" REFERENCE(NUMLINES) TYPE I
*" CHANGING
*" REFERENCE(AMT2WDS) TYPE STRING
*"----------------------------------------------------------------------
* Nicely Cased words spelt corectly
* suits India
* takes care of singular & plural
* word wraps at line end
* ChrsLine = max no. of chars per line for wordwrapping.
* NumLines = max no. of lines
Data: chramount type String,
workStr type String,
numAmount type P Decimals 2.
Data: MyTwoDigits type I,
quotient type I,
remainder type I.
Data: cr type I,
lk type I,
th type I,
hun type I,
ten type I,
paisa type I.
Compute MAXLEN = ChrsLine * NumLines.
Move '' to mySpaces.
Do MAXLEN Times.
Concatenate mySpaces '.' into mySpaces.
EndDo.
Move ChrsLine to LineLength.
If LineLength <> 120.
Amt2Words = 'Invalid Parameters'.
Perform Rpad2MAX.
Amt2Wds = Amt2Words.
Return.
EndIf.
If Amount = 0.
Amt2Words = 'Rupees Nil Only'.
Perform Rpad2MAX.
Amt2Wds = Amt2Words.
Return.
EndIf.
* Reference is 'Seventeen'.
* Units & Teens
Words1 =
'One......' &
'Two......' &
'Three....' &
'Four.....' &
'Five.....' &
'Six......' &
'Seven....' &
'Eight....' &
'Nine.....' &
'Ten......' &
'Eleven...' &
'Twelve...' &
'Thirteen.' &
'Fourteen.' &
'Fifteen..' &
'Sixteen..' &
'Seventeen' &
'Eighteen.' &
'Nineteen.'.
Move '' to Words2.
* Tens
Words2 =
'Twenty...' &
'Thirty...' &
'Forty....' &
'Fifty....' &
'Sixty....' &
'Seventy..' &
'Eighty...' &
'Ninety...'.
If Amount < 0.
Amt2Words = 'Rupees Minus'.
Else.
Amt2Words = 'Rupees'.
EndIf.
* crlkthhtn.ps.
Compute numAmount = 1000000000 + Abs( Amount ).
Move numAmount to chramount.
Move chramount+1(2) to cr.
Move chramount+3(2) to lk.
Move chramount+5(2) to th.
Move chramount+7(1) to hun.
Move chramount+8(2) to ten.
Move chramount+11(2) to paisa.
If cr > 0.
Perform InWords2Digits Using cr.
If cr > 1.
Perform AppendWord Using 'Crores'.
Else.
Perform AppendWord Using 'Crore'.
EndIf.
EndIf.
If lk > 0.
Perform InWords2Digits Using lk.
If lk > 1.
Perform AppendWord Using 'Lakhs'.
Else.
Perform AppendWord Using 'Lakh'.
EndIf.
EndIf.
If th > 0.
Perform InWords2Digits Using th.
Perform AppendWord Using 'Thousand'.
EndIf.
If hun > 0.
Perform InWords2Digits Using hun.
Perform AppendWord Using 'Hundred'.
EndIf.
If ten > 0.
Perform InWords2Digits Using ten.
EndIf.
If paisa > 0.
If Amt2Words = 'Rupees'.
Amt2Words = 'Paisa'.
Else.
Perform AppendWord Using 'And'.
Perform AppendWord Using 'Paisa'.
EndIf.
Perform InWords2Digits Using paisa.
EndIf.
Perform AppendWord Using 'Only'.
Perform Rpad2MAX.
Amt2Wds = Amt2Words.
ENDFUNCTION.
------------------------------------------------------------------------------------------
* TOP level Include of Function Group ZUTIL
FUNCTION-POOL ZUTIL. "MESSAGE-ID ..
* Global ZUTIL Data
Data: Words1 type String,
Words2 type String,
Amt2Words type String,
mySpaces type String,
LineLength type I ,
MaxLen type I .
*&---------------------------------------------------------------------*
*& Form AppendWord
*&---------------------------------------------------------------------*
FORM AppendWord Using AddWord type String.
Data: NowLen type I,
AddLen type I,
NewLen type I,
DifLen type I,
workStr type String.
NowLen = StrLen( Amt2Words ).
NowLen = NowLen Mod LineLength.
AddLen = StrLen( AddWord ).
Compute NewLen = NowLen + 1 + AddLen.
If NewLen > LineLength.
DifLen = LineLength - NowLen.
If DifLen > 1.
Subtract 1 from DifLen.
Move mySpaces+0(DifLen) to workStr.
Concatenate Amt2Words workStr into Amt2Words.
EndIf.
EndIf.
* exact line boundary
If NowLen = 0.
Concatenate Amt2Words AddWord into Amt2Words.
Else.
Concatenate Amt2Words '.' AddWord into Amt2Words.
EndIf.
EndForm. " AppendWord
*&---------------------------------------------------------------------*
*& Form InWords2Digits
*&---------------------------------------------------------------------*
FORM InWords2Digits Using MyTwoDigits type I.
Data: quotient type I,
remainder type I,
workStr type String,
workIdx type I.
If MyTwoDigits > 19 .
Compute quotient = MyTwoDigits Div 10.
Compute remainder = MyTwoDigits Mod 10.
Compute workIdx = ( quotient - 2 ) * 9.
Move Words2+workIdx(9) to workStr.
Replace All Occurrences Of '.' in workStr with ' '.
Perform AppendWord Using workStr.
If remainder > 0 .
Compute workIdx = ( remainder - 1 ) * 9.
Move Words1+workIdx(9) to workStr.
Replace All Occurrences Of '.' in workStr with ' '.
Perform AppendWord Using workStr.
EndIf.
Else.
Compute workIdx = ( MyTwoDigits - 1 ) * 9.
Move Words1+workIdx(9) to workStr.
Replace All Occurrences Of '.' in workStr with ' '.
Perform AppendWord Using workStr.
EndIf.
EndForm. " InWords2Digits
*&---------------------------------------------------------------------*
*& Form Rpad2MAX
*&---------------------------------------------------------------------*
FORM Rpad2MAX.
Concatenate Amt2Words mySpaces into Amt2Words.
Move Amt2Words+0(MAXLEN) to Amt2Words.
Concatenate Amt2Words '*' into Amt2Words.
Replace All Occurrences Of '.' in Amt2Words With ' !'.
Replace All Occurrences Of '!' in Amt2Words With ' '.
EndForm. " Rpad2MAX
-------------------------------------------------------
Friday, November 23, 2007
sap abap program for Figure to Words for India but can be modified to any requirement
Labels:
Conversion Program
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2007
(952)
-
▼
November
(716)
- SAP Paper Documents
- SAP Repository
- SAP R/3 Implementation and Maintenance Tips
- ABAP/4 programming language overview
- The interactive eLearning system for ABAP™
- Helpful System Administration ABAPS
- free download abap programmin pdf book
- examples of real time objects in sap abap(1)
- examples of real time objects in sap abap
- work flow example2
- Workflow tips
- Miscellaneous sap abap faq
- BDC , LSMW, Conversions faq in abap
- Sap Scripts & Smart forms faqs in abap
- performance tuning in abap faqs
- Real Time BDC & LSMW faqs
- Real Time ABAP Internal Tables faqs
- Real Time ABAP Reports faqs
- Real Time questions ..in sap ABAP
- SAP ABAP FAQ (Technical)
- ABAP and Unicode
- ABAP and JavaScript
- ABAP Objects
- ABAP Database Access
- Running ABAP Programs
- ABAP User Dialogs
- The ABAP Programming Language
- Creating and Changing ABAP Programs
- Overview of the Components of Application Programs
- Introduction to ABAP
- ABAP Programming Documentation
- FREE DOWNLOAD ALE, EDI & IDOCS
- Conversion of IDOCs to XML.pdf
- FREE DOWNLOAD IDOC Interface Technology
- FREE DOWNLOAD EDI, IDOC Interface
- FREE DOWNLOAD IDOC BOOK
- FREE DOWNLOAD LSMW - Idoc Inbound Processing
- FREE DOWNLOAD SAP ABAP Idoc Interface
- FREE DOWNLOAD Java for SAP
- FREE DOWNLOAD Java for ABAP Programmers
- FREE DOWNLOAD Java and BAPI technology for EP
- free download Building Web Services with Java and ...
- free download Enable SAP with the power of Javascript
- FREE DOWNLOAD ABAP Training Simulator
- FREE DOWNLOAD SAP Accounting Training Simulators
- free download SAPScripts Made Easy
- CONDENSE
- CONSTANTS
- ABAP Quick Viewer
- sap abap XXL (EXtended Export of Lists)
- Some ABAP/4 Query header line variable
- Understanding SAP Query
- ABAP/4 Query
- ABAP/4 Query Hints and Tips
- SAP Website Links Exchange for ABAP, Basis or Cons...
- sap abap Program for Generate IDoc
- sap abap program for Reads an existing Idoc and di...
- List of ABAP Function modules
- sap abap FTP programming
- sap abap program for Issuing an Unix Command from ...
- sap abap program for RFC call to get Server List
- sap abap program for A SAP Pop-out Calculator
- sap ABAP program for Timers and Auto-refresh
- sap abap program for WS_EXECUTE to called External...
- sap abap programming Execute DOS Command from ABAP...
- To execute a dos command from ABAP
- sap abap program for Make your SAPGUI Disappear an...
- sap abap program for Using Function Modules F4_FIL...
- abp program for How to Restrict the Select Options
- sap abap program for Take Values from Selection-Sc...
- sap abap program for Change Text Into Password
- sap abap program for Function Module for Encryptio...
- sap abap program for FM VRM_SET_VALUE To List Box
- sap abap program for Value Request For Parameter
- sap abap program for Pop a Message to specific SAP...
- ABAP Pop-out box for user confirmation
- sap ABAP program for POP-UP Window
- sap abap program Sample XML Source Code For SAP
- sap abap XML file to word document through SAP
- sap abap program for How to Write Web Reports in SAP
- sap abap conversion Program to Test Line Selection...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for Convert SAP Spool List to HTML
- sap program for Convert Month to Word in ABAP
- ABAP function to convert Number to Words
- sap abap program for How to Create Tree Control
- sap abap A sample Tree Programming
-
▼
November
(716)
No comments:
Post a Comment