Application Development 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: 

Function Module (sap-abap)

Former Member
0 Kudos

Hi ,

I m using function module 'SPELL_AMOUNT' to convert numeric value into words.if i pass any numeric entry (10000) it shows "TEN THOUSAND".

But my requirement is to show "Ten thousand ".

Pls .guide me to modify this function module or give new function module which gives required out put .

Thx in Adv.

19 REPLIES 19

Former Member
0 Kudos

Hi

U should change the descriptions in table T015Z

Max

Former Member
0 Kudos

Hi,

The FM returns the text in CAPS only,.

You can convert into lower case and make the required things to upper case.

Regards,

Anji

alex_m
Active Contributor
0 Kudos

I think u have to convert the letters to lower case.

Message was edited by:

Alexander Mariadoss

Former Member
0 Kudos

Hi ,

there is a function module which converts characters from upper to lower case , convert all the letters except the first one into lower case.

Regards,

Sunmit.

Former Member
0 Kudos

Hi,

It will give only in CAPS. You have change Manually doing coding.

Regards

Bhupal Reddy

Former Member
0 Kudos

hi,

you have to use this statement after getting the output from FM

translate amount to lower case

.

regards,

pankaj singh

0 Kudos

hi,

us this.

transalate <EN THOUSAND> to lower case.

except fist letter,

Now u can concentenate first letter and reaming word into the stirng, then u can write that string to the output.

regards,

seshu

Former Member
0 Kudos
You can convert to lower case

also chk this

REPORT ZTEST.

DATA: AMT_IN_NUM LIKE PC207-BETRG.
DATA: WORDS(200) TYPE C.

AMT_IN_NUM = '10000'.

CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
EXPORTING
AMT_IN_NUM = AMT_IN_NUM
IMPORTING
AMT_IN_WORDS = WORDS
* EXCEPTIONS
* DATA_TYPE_MISMATCH = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

WRITE:/ WORDS.

Former Member
0 Kudos

Use <b><b>HR_P06I_CONVERT_TO_LOWERCASE</b></b> And Pass The Variables

After which letters u want smalls.

Former Member
0 Kudos

Hi,

you have to do it manually i think.

Change the words to lower case using translate command.

Former Member
0 Kudos

Hi Bapi.....

Use any one of these function Modules after getting the amount in words to get out put as u desired.....

<b>HR_P06I_CONVERT_TO_LOWERCASE.</b> or

<b> STRING_UPPER_LOWER_CASE</b>

Message was edited by:

RK Pasupuleti

0 Kudos

Use FM : ISP_CONVERT_FIRSTCHARS_TOUPPER

Regards,

Laxman

former_member227141
Active Participant
0 Kudos

I think there is no function that could accomplish that, but you could do it "manually" using TRANSLATE statement after SPELL_AMOUNT. I wrote below code and I got the output you need. I translate the whole string to lowercase and then just the first letter.

REPORT ztests.

DATA: amount TYPE i VALUE 10000,

       in_words TYPE spell.

CALL FUNCTION 'SPELL_AMOUNT'

   EXPORTING

     amount    = amount

     currency  = sy-waers

     language  = sy-langu

   IMPORTING

     in_words  = in_words

   EXCEPTIONS

     not_found = 1

     too_large = 2

     OTHERS    = 3.

IF sy-subrc EQ 0.

   TRANSLATE in_words-word TO LOWER CASE.

   TRANSLATE in_words-word(1) TO UPPER CASE.

   WRITE in_words-word.

ENDIF.

Hope it helps you.

Regards,

Karina Hurtado

Former Member
0 Kudos

Try This...

Complete Code,

   DATA: ASD LIKE  SPELL.
DATA: TO_STRING TYPE  SPELL-WORD.

CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
   AMOUNT          = 100
   LANGUAGE        = SY-LANGU
IMPORTING
   IN_WORDS        = ASD
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:/ ASD-WORD.
  TO_STRING = ASD-WORD..
  TRANSLATE TO_STRING TO LOWER CASE.
  WRITE:/ TO_STRING.
ENDIF.

0 Kudos

Hi Kaushik, good contribution but I think it doesn't fulfill the requirement. According what I understand, he needs first letter in capital.

" But my requirement is to show "Ten thousand "."

Regards,

Karina Hurtado

0 Kudos

Hi Bobby,


try this,


CALL FUNCTION 'HR_IN_CHG_INR_WRDS'

   EXPORTING

     AMT_IN_NUM         = TOT_AMT  -------------> 10000

   IMPORTING

     AMT_IN_WORDS       = IN_WORDS

   EXCEPTIONS

     DATA_TYPE_MISMATCH = 1

     OTHERS             = 2.

IF SY-SUBRC <> 0.

* Implement suitable error handling here

ENDIF.

CALL FUNCTION 'ISP_CONVERT_FIRSTCHARS_TOUPPER'

   EXPORTING

     INPUT_STRING  = IN_WORDS

   IMPORTING

     OUTPUT_STRING = AMT_WRDS.

write: AMT_WRDS.


Actual out put is "TEN THOUSAND".

By using 'ISP_CONVERT_FIRSTCHARS_TOUPPER' Fm  you can get "Ten Thousand".



Thanks & Regards,

Bhargav D.


former_member187748
Active Contributor
0 Kudos

Hi Bobby,

please try this, this will surely be needful, i have used this code in taking output as you desired.

data : final(130).

data : v_amt type PC207-BETRG.

data: vlen type i.

v_amt = v_TOTAL.

CALL FUNCTION 'HR_IN_CHG_INR_WRDS'

   EXPORTING

     amt_in_num               = v_amt

  IMPORTING

    AMT_IN_WORDS             = final

  EXCEPTIONS

    DATA_TYPE_MISMATCH       = 1

    OTHERS                   = 2

           .

IF sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*break stabap.

v_words = final.

if v_words+0(1) eq ''.

   vlen = strlen( v_words ).

   v_words = v_words+1(vlen).

endif.

CALL FUNCTION 'STRING_UPPER_LOWER_CASE'

   EXPORTING

     delimiter       = '/'

     string1         = v_words

  IMPORTING

    STRING          = v_words.

* EXCEPTIONS

*   NOT_VALID       = 1

*   TOO_LONG        = 2

*   TOO_SMALL       = 3

*   OTHERS          = 4

The output will be v_words.

former_member187748
Active Contributor
0 Kudos

Hi bobby,

if you have got your answer, then mark those from where you have got your answer, and please

lock this discussion.

0 Kudos

Did you notice that Bobby asked this almost seven years ago? He probably since learned to search before posting, so does not need to come back that often.


Thomas