2016 Jan 11 4:25 AM
Dear All,
As per one of our client requirements, We have to print amount in words for cheque printing as per below mention example,
If amount is 100099.23 than It should print like "One Hundred Thousand and Ninty Nine and Twenty Three Cents Only"
If amount is 1000099.23 than It should print like "One Million and Ninty Nine and Twenty Three Cents Only"
Basically they want "And" Between every unit places.
Kindly help me to solve this.
Thanks & Regards,
Dhaval Raval
2016 Jan 11 5:52 AM
HI I DEVELOPE SOME CODE REGARDING UR ISSUE
MAY BE IT WILL SUIT UR REQUIREMENT.
REPORT ZDEMO2.
DATA:LS_SPELL TYPE SPELL.
DATA:LV_STR TYPE STRING.
DATA:LT_STR TYPE STANDARD TABLE OF STRING,
LS_STR TYPE STRING.
FIELD-SYMBOLS:<LS_STR> TYPE ANY.
DATA:LV_LINE TYPE I.
START-OF-SELECTION.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = 510
LANGUAGE = SY-LANGU
IMPORTING
IN_WORDS = LS_SPELL
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS = 3 .
TRANSLATE LS_SPELL-WORD TO LOWER CASE.
SPLIT LS_SPELL-WORD AT ' ' INTO TABLE LT_STR.
LOOP AT LT_STR ASSIGNING <LS_STR>.
CLEAR LV_STR.
LV_STR = <LS_STR>+0(1).
TRANSLATE LV_STR TO UPPER CASE.
CONCATENATE LV_STR <LS_STR>+1 INTO <LS_STR>.
ENDLOOP.
CLEAR:LV_STR,LV_LINE.
LOOP AT LT_STR INTO LS_STR.
IF LS_STR = 'Hundred'.
LV_LINE = SY-TABIX.
LV_LINE = LV_LINE + 1.
READ TABLE LT_STR INDEX LV_LINE TRANSPORTING NO FIELDS.
IF SY-SUBRC = 0.
CONCATENATE LV_STR LS_STR ' And ' INTO LV_STR RESPECTING BLANKS.
ELSE.
CONCATENATE LV_STR LS_STR ' ' INTO LV_STR RESPECTING BLANKS.
ENDIF.
ELSE.
CONCATENATE LV_STR LS_STR ' ' INTO LV_STR RESPECTING BLANKS.
ENDIF.
ENDLOOP.
CONCATENATE LV_STR ' Only' INTO LV_STR RESPECTING BLANKS.
CONDENSE LV_STR.
WRITE LV_STR.
2016 Jan 11 4:33 AM
Hi Dhaval,
Try use below FM:-
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
amount = "your amount in digits"
currency = "currency in which you want it"
language = 'E'
IMPORTING
in_words = "Your output table"
EXCEPTIONS
not_found = 1
too_large = 2
others = 3.
Hope it will help you.
Regards,
Swati
2016 Jan 11 4:40 AM
Hi Swati,
This FM is not giving output as per my requirements.
Pleas go through below mention link to understand exactly what they want,
Cheque Amount to Word Converter
Thanks & Regards,
Dhaval Raval
2016 Jan 11 5:31 AM
Hi Dhaval,
I checked the link you gave. It gives AND only before the UNIT level amount word not everywhere, which you have written in your initial query.
Please try to use below FM :-
DATA IN_WORDS(100) TYPE c.
CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
EXPORTING
amt_in_num = "your amount in digits"
IMPORTING
AMT_IN_WORDS = IN_WORDS
EXCEPTIONS
DATA_TYPE_MISMATCH = 1
OTHERS = 2
Regards,
Swati
2016 Jan 11 5:52 AM
HI I DEVELOPE SOME CODE REGARDING UR ISSUE
MAY BE IT WILL SUIT UR REQUIREMENT.
REPORT ZDEMO2.
DATA:LS_SPELL TYPE SPELL.
DATA:LV_STR TYPE STRING.
DATA:LT_STR TYPE STANDARD TABLE OF STRING,
LS_STR TYPE STRING.
FIELD-SYMBOLS:<LS_STR> TYPE ANY.
DATA:LV_LINE TYPE I.
START-OF-SELECTION.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = 510
LANGUAGE = SY-LANGU
IMPORTING
IN_WORDS = LS_SPELL
EXCEPTIONS
NOT_FOUND = 1
TOO_LARGE = 2
OTHERS = 3 .
TRANSLATE LS_SPELL-WORD TO LOWER CASE.
SPLIT LS_SPELL-WORD AT ' ' INTO TABLE LT_STR.
LOOP AT LT_STR ASSIGNING <LS_STR>.
CLEAR LV_STR.
LV_STR = <LS_STR>+0(1).
TRANSLATE LV_STR TO UPPER CASE.
CONCATENATE LV_STR <LS_STR>+1 INTO <LS_STR>.
ENDLOOP.
CLEAR:LV_STR,LV_LINE.
LOOP AT LT_STR INTO LS_STR.
IF LS_STR = 'Hundred'.
LV_LINE = SY-TABIX.
LV_LINE = LV_LINE + 1.
READ TABLE LT_STR INDEX LV_LINE TRANSPORTING NO FIELDS.
IF SY-SUBRC = 0.
CONCATENATE LV_STR LS_STR ' And ' INTO LV_STR RESPECTING BLANKS.
ELSE.
CONCATENATE LV_STR LS_STR ' ' INTO LV_STR RESPECTING BLANKS.
ENDIF.
ELSE.
CONCATENATE LV_STR LS_STR ' ' INTO LV_STR RESPECTING BLANKS.
ENDIF.
ENDLOOP.
CONCATENATE LV_STR ' Only' INTO LV_STR RESPECTING BLANKS.
CONDENSE LV_STR.
WRITE LV_STR.
2016 Jan 11 6:58 AM
Hi, Krishna,
Thank you so much, its working exactly as I want.
Thanks & Regards,
Dhaval Raval