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

spell_amount-wrong amount description

Former Member
0 Likes
1,092

i m using the function module spell_amount. but when i m passing the amount field say value 900,000.12, then the output comin is 'RUPEES NINE HUNDRED THOUSAND AND ZERO PAISA ONLY', which is not correct in my sceneario. i want it to be nine lakh and twelve paise only.

how it could be and what changes i have to make ?

6 REPLIES 6
Read only

Former Member
0 Likes
882

Hi,

Use Function module HR_IN_CHG_INR_WRDS, it will surely resolve your problem.

Edited by: UMANGmehta on Oct 5, 2010 5:19 PM

Read only

0 Likes
882

but i am not able to get the decimal value as paise.

it only shows the rupee not paise(decimal value).

what i need to do for that?

Read only

Former Member
0 Likes
882

Example


TABLES : vbak.
data :
CTOTTEXT type c.
PARAMETER : ncurr(15) type c.
DATA :nsignamt like reguh-rwbtr,
      nLentotake type i,
      actualstrlen type i,
      flen TYPE i,
      nStrt type i,
      nPos type i,
      nIntEndsAt type i,
      decpos type i.
DATA : cFullText(254) type c,
       cstring(18) type c,
       cIntstring(15) type c,
       cPart(2) type c,
       c1stdigit(1) type c,
       c2nddigit(1) type c,
       cDecstring(2) type c,
       cTextpos(10) type c,
       ctext like T015Z-WORT.
  cFullText = ''.
  move ncurr to cString.
  REPLACE '-' WITH ' ' INTO CSTRING.
  REPLACE ',' WITH ' ' INTO CSTRING.
  REPLACE ',' WITH ' ' INTO CSTRING.
  condense cSTring NO-GAPS .

  fLEN = STRLEN( cString ).  "gives correct length
  decpos = flen - 2.
  nIntEndsAt = flen - 3.

*split currency string into integer part and decimal part.
*  move cString+0( nIntendsat ) to cIntString.
  cIntstring  = cString+0(nIntendsat).
  move cString+decpos(2) to cDecString.


* TAKE 2 TIMES AS ONCE FOR INTEGER 2NDLY FOR DECIMAL
  do 2 times.

* whichver part of the amount (int or dec) u want to process put it
* in cstring.
     if sy-index = 1.
        move cIntString to cString .
     else.   " for paise part.
        if cDecstring = '00'.
           EXIT.
        endif.
        CONCATENATE  cFullText  'AND PAISE' INTO cFullText SEPARATED BY
SPACE.
        move cDecString to cString .
     endif.
 fLEN = STRLEN( cString ).  "gives correct length


  nStrt = 0.
  nLentotake = 1.

  DO 10 times.
    CASE flen.
         WHEN 3.  "hundreth position.
              nLentotake = 1.
         WHEN 9 or 7 or 5 or 2.
              nLentotake = 2.
         WHEN  8 or 6 or 4 or 1.
              nLentotake = 1.
    ENDCASE.


Read only

Former Member
0 Likes
882

Continue..........


cpart = ''.
**  take 1 or 2 digits for lakhs, thousand
    move  cstring+nStrt(nLentotake) to cPart  .

**  bring text description as per cpart.
    IF nLenTotake = 1.
      c1stdigit = '0'.
      c2nddigit = cPart+0(1).
    ELSE.
      c1stdigit = cPart+0(1).
      c2nddigit = cPart+1(1).
    ENDIF.

** if pair of digit is 00 then make the cText and cTextpos blank.
    IF ( nLentotake = 1 and c2nddigit = '0' ) or  ( nLentotake = 2 and
cPart = '00' ).

        cText = '' .
        cTextPos = ''.

    ELSE.

    SELECT SINGLE WORT FROM T015Z INTO ctext WHERE spras = 'E' AND EINH
= c1stdigit and ZIFF = c2nddigit .

**  now decide place indicator
    CASE flen.  "NPOS.
         WHEN 8 OR 9.
              CTEXTPOS = 'CRORE'.
         WHEN 6 OR 7.
              CTEXTPOS = 'LAC'.
         WHEN 4 OR 5.
              CTEXTPOS = 'THOUSAND'.
         WHEN 3.
              CTEXTPOS = 'HUNDRED'.
         WHEN OTHERS.
              CTEXTPOS = ''.
    ENDCASE.
  ENDIF.


*   cText contains ; so replace it with space.
    REPLACE ';' WITH ' ' INTO cText.

**  add digit description and place indicator.
    CONCATENATE cFullText cText cTextPOS INTO cFullText SEPARATED BY
SPACE
.

**  decide place & lenght for next loop.
    flen = flen - nLentotake.
* check if string is over.
    if flen = 0.
       exit.
    endif.
    nStrt = nSTrt + nLenTotake.

  ENDDO.
  ENDDO.

  CONCATENATE cFullText 'ONLY' INTO cFullText SEPARATED BY SPACE.
break developer.
  move cFulltext+1  to cTottext.
break developer.
*  write : / ncurr, cTottext.

Read only

0 Likes
882

Hi,

HR_IN_CHG_INR_WRDS function module giving velue in words upto 2 decimals, please check.

EG. if 12,345.78 is the value then

output

TWELVE THOUSAND THREE HUNDRED FORTY FIVE Rupees SEVENTY EIGHT Paise

Edited by: UMANGmehta on Oct 6, 2010 5:20 PM

Read only

Former Member
0 Likes
882

solved.