Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CALL FUNCTION 'SPELL_AMOUNT' misinterpretes decimal places

Former Member
0 Likes
5,229

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,

1 ACCEPTED SOLUTION
Read only

Sijin_Chandran
Active Contributor
0 Likes
2,808

Enter a CURRENCY field so that the FM could get the correct conversion factor.

7 REPLIES 7
Read only

reachdebopriya
Active Participant
2,808

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

Read only

Sijin_Chandran
Active Contributor
0 Likes
2,808

Hi ,

What is the value you are passing to CURRENCY  field.

If you pass INR it shows the way you want.

Read only

Former Member
0 Likes
2,808

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.

Read only

Sijin_Chandran
Active Contributor
0 Likes
2,809

Enter a CURRENCY field so that the FM could get the correct conversion factor.

Read only

gouravkumar64
Active Contributor
0 Likes
2,808

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.

Read only

Former Member
0 Likes
2,808

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.

Read only

former_member728975
Active Participant
2,808

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