2012 Nov 02 4:57 AM
Hello,
I used CALL FUNCTION 'SPELL_AMOUNT' to spell out the number 162500.00. But the output is SIXTEEN MILLION .... . The correct one should be ONE HUNDRED AND SIXTY THOUSAND .... . It seems that the two decimal places are misinterpreted. How can I output the number correctly?
Thanks a lot!
Regards,
2012 Nov 02 5:29 AM
2012 Nov 02 5:24 AM
Hi T S,
If you use SPELL_AMOUNT for the 162500.00, the decimal portion will not be translated.
For 162500 use SPELL_AMOUNT and for decimal (.00) use SPELL_AMOUNT separately.
Pass Currency as 'INR'.
Regards,
Debopriya
2012 Nov 02 5:24 AM
2012 Nov 02 5:26 AM
Hi TS,
May I know are you passing the currency value according to the currency in your program.
If yes,
Use
CONCATENATE SPELL-WORD C_DASH SPELL-DECWORD C_ONLY
INTO WORD
SEPARATED BY SPACE.
PERFORM SPLIT_WORD USING WORD
C_38(Constant with value 38)
CHANGING PE_OUTPUT-WORD1
PE_OUTPUT-WORD2.
ENDFORM.
In the Perform,
FORM SPLIT_WORD USING PI_WORD
PI_SPOINT TYPE INT2
CHANGING PE_WORD1
PE_WORD2.
DATA: L_STRLEN TYPE INT4,
L_CPOINT TYPE INT2,
L_CHAR(1).
L_STRLEN = STRLEN( PI_WORD ).
IF L_STRLEN LE PI_SPOINT.
PE_WORD1 = PI_WORD.
CLEAR PE_WORD2.
ENDIF.
L_CPOINT = PI_SPOINT.
DO.
L_CHAR = PI_WORD+L_CPOINT(1).
IF L_CHAR = SPACE.
EXIT.
ENDIF.
ADD 1 TO L_CPOINT.
ENDDO.
CALL FUNCTION 'TEXT_SPLIT'
EXPORTING
LENGTH = L_CPOINT
TEXT = PI_WORD
AS_CHARACTER = 'X'
IMPORTING
LINE = PE_WORD1
REST = PE_WORD2.
Hope This Helps..
Regards,
Srik.
2012 Nov 02 5:29 AM
2012 Nov 02 5:33 AM
Hi,
Try this one & revert back.
*&---------------------------------------------------------------------*
*& Report ZSP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZSP.
PARAMETERS:
pLANGU LIKE T002-SPRAS DEFAULT SY-LANGU,
pCURR LIKE TCURC-WAERS DEFAULT 'INR',
pAMOUNT LIKE VBAP-MWSBP ,
pFILLER(1) TYPE C DEFAULT ' '.
DATA :
WS_SPELL TYPE SPELL.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
AMOUNT = pAMOUNT
CURRENCY = pCURR
FILLER = pFILLER
LANGUAGE = pLANGU "SY-LANGU
IMPORTING
IN_WORDS = WS_SPELL
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.
ELSE.
WRITE :/ WS_SPELL-word , WS_SPELL-decword.
ENDIF.
To display the country code
u can use vbrk-waerk.
then concatenate WAERK field with wa_spell-word & wa_spell-decword.
Otherwise try
select single * from tcurt where waers = pcurr.
then u can use the TCURT-KTEXT field for currency text instead of displaying WAERK field directly.
Thanks.
Gourav.
2012 Nov 02 5:34 AM
Hi,
Currency field needs to be passed in case where amount is decimal number otherwise it considers the entire amount as number ignoring the decimal. For example, if you pass Amount = 165000.00 but keep currency field as blank it will consider this amount as number and return words for 16500000 ignoring decimal. But if you give currency field it will give you the exact value with decimal figures in words.
2023 Mar 16 5:41 PM
Hello community,
In case you want this scenario in S/4HANA Cloud, please have a look:3313878 - How to convert amount to text in S/4HANA Cloud
Thank you.
Kind Regards,
Iza