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

Function Module for Amount in words for cheque Printing

Former Member
0 Likes
1,238

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

1 ACCEPTED SOLUTION
Read only

former_member241258
Active Participant
0 Likes
1,063

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          = .



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.

5 REPLIES 5
Read only

Former Member
0 Likes
1,063

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

Read only

0 Likes
1,063

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

Read only

0 Likes
1,063

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

Read only

former_member241258
Active Participant
0 Likes
1,064

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          = .



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.

Read only

0 Likes
1,063

Hi, Krishna,

Thank you so much, its working exactly as I want.

Thanks & Regards,

Dhaval Raval