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

amount spell

former_member841898
Participant
0 Likes
2,175

hi everybody,

after coverting amount in words , the amount part after decimal is not showing for e.g. 1000.40 is showing one thousand but 40 paise is not coming ,

pls help me regarding this matter.

regards

pankaj

abap developer

1 ACCEPTED SOLUTION
Read only

varma_narayana
Active Contributor
0 Likes
1,395

Hi Pankaj,

This is the Code for u.

Try out.

REPORT ZSEL_AMOUNT .

PARAMETERS: P_AMT(10) TYPE P DECIMALS 2.

DATA : WA_WORD TYPE SPELL.

DATA: V_WORD TYPE STRING.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = P_AMT

CURRENCY = 'INR'

  • FILLER = ' '

LANGUAGE = SY-LANGU

IMPORTING

IN_WORDS = WA_WORD

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.

ENDIF.

CONCATENATE wa_WORD-word SPACE

' Rupees'

wa_word-decword

' Paise'

into v_word.

Write:/ v_word.

<b>Reward if Helpful</b>

8 REPLIES 8
Read only

Former Member
0 Likes
1,395

Hope you are using FM SPELL_AMOUNT.

pass currency as INR.

you can also see decimal value.Check the below one from SE37

IN_WORDS

NUMBER 000000000001400

DECIMAL 400

CURRDEC 2

WORD <b>ONE THOUSAND FOUR HUNDRED</b>

DECWORD <b>FOURTY</b>

DIG01 ZERO

DIG02 ZERO

DIG03 FOUR

DIG04 ONE

DIG05 ZERO

DIG06 ZERO

DIG07 ZERO

DIG08 ZERO

DIG09 ZERO

DIG10 ZERO

DIG11 ZERO

DIG12 ZERO

DIG13 ZERO

DIG14 ZERO

DIG15 ZERO

Eswar Kanakanti

Read only

Former Member
0 Likes
1,395

Hi,

i think u declared variable is not in decimal type. or some value it won't convert decimals it will take comma(,) bcz convertion routines will be there that perticulor field.....

if it is use full reward me a pointss.....

regards ,

praveen,,,,,,,.........

Read only

Former Member
0 Likes
1,395

report zrich_0003 .

data: i type i.

data: c(10) type c.

data: p(10) type p decimals 2.

c = '3.520,00'.

catch system-exceptions convt_no_number = 1.

p = c.

endcatch.

if sy-subrc = 1.

clear sy-subrc.

while sy-subrc = 0.

replace ',' with space into c.

endwhile.

clear sy-subrc.

while sy-subrc = 0.

replace '.' with space into c.

endwhile.

condense c no-gaps.

endif.

p = c / 100.

write:/ p.

Read only

Former Member
0 Likes
1,395

Currency-specific Output Formats

To format the output of a number field according to a specific currency, use the CURRENCY option of the WRITE statement:

Syntax

WRITE <f> CURRENCY <c>.

This statement determines the number of decimal places in the output according to the currency <c>. If the contents of <c> exist in table TCURX as currency key CURRKEY, the system sets the number of decimal places according to the entry CURRDEC in TCURX. Otherwise, it uses the default setting of two decimal places. This means that table TCURX must contain only exceptions where the number of decimal places is unequal to 2.

The output format for currencies does not depend on the decimal places of a number that may exist in the program. The system uses only the sequence of digits. This sequence of digits thus represents an amount specified in the smallest unit of the currency in use, for example Cents for US Dollar (USD) or Francs for Belgian Francs (BEF). For processing currency amounts in ABAP programs, SAP therefore recommends that you use data type P without decimal places.

REPORT demo_list_write_currency LINE-SIZE 40.

DATA: num1 TYPE p DECIMALS 4 VALUE '12.3456',

num2 TYPE p DECIMALS 0 VALUE '123456'.

SET COUNTRY 'US'.

WRITE: 'USD', num1 CURRENCY 'USD', num2 CURRENCY 'USD',

/ 'BEF', num1 CURRENCY 'BEF', num2 CURRENCY 'BEF',

/ 'KUD', num1 CURRENCY 'KUD', num2 CURRENCY 'KUD'.

This program defines two packed numbers NUM1 and NUM2, containing the same sequence of digits, but different numbers of decimal places. These numbers appear in the output in several currencies:

For each currency, the output formats of NUM1 and NUM2 are the same, since they refer to the sequence of digits only. The currency US Dollar (USD) appears in the default setting of two decimal places, since the smallest unit is one Cent and a hundredth of a Dollar. For Belgian Francs (BEF), CURRDEC in TCURX is set to 0, since the Belgian Franc has no smaller units. Dinars from Kuwait (KUD) have units of a thousandth and therefore three decimal places (CURRDEC is 3).

Read only

Former Member
0 Likes
1,395

Hi Gupta

use spell_amount fm.

before using split the string into two strings

str1= 1000

str2 = 40

now use spell_amount to two strings

and then

string1 has one thousand

and string2two has fourty.

finally concatenate str1 ' ' str2 'paise'.

or

REPORT ZSPELL.

TABLES SPELL.

DATA : T_SPELL LIKE SPELL OCCURS 0 WITH HEADER LINE.

DATA : PAMOUNT LIKE SPELL-NUMBER VALUE '1234510'.

SY-TITLE = 'SPELLING NUMBER'.

PERFORM SPELL_AMOUNT USING PAMOUNT 'USD'.

WRITE: 'NUMBERS', T_SPELL-WORD, 'DECIMALS ', T_SPELL-DECWORD.

FORM SPELL_AMOUNT USING PWRBTR PWAERS.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = PAMOUNT

CURRENCY = PWAERS

FILLER = SPACE

LANGUAGE = 'E'

IMPORTING

IN_WORDS = T_SPELL

EXCEPTIONS

NOT_FOUND = 1

TOO_LARGE = 2

OTHERS = 3.

ENDFORM. " SPELL_AMOUNT

Please Reward points to all helpful answers

kiran.M

Message was edited by:

Kiran Machavarapu

Read only

varma_narayana
Active Contributor
0 Likes
1,396

Hi Pankaj,

This is the Code for u.

Try out.

REPORT ZSEL_AMOUNT .

PARAMETERS: P_AMT(10) TYPE P DECIMALS 2.

DATA : WA_WORD TYPE SPELL.

DATA: V_WORD TYPE STRING.

CALL FUNCTION 'SPELL_AMOUNT'

EXPORTING

AMOUNT = P_AMT

CURRENCY = 'INR'

  • FILLER = ' '

LANGUAGE = SY-LANGU

IMPORTING

IN_WORDS = WA_WORD

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.

ENDIF.

CONCATENATE wa_WORD-word SPACE

' Rupees'

wa_word-decword

' Paise'

into v_word.

Write:/ v_word.

<b>Reward if Helpful</b>

Read only

0 Likes
1,395

thanx mr. verma ur code for amount spell works well.

best wishes

pankaj gupta

abap dev.

Read only

former_member841898
Participant
0 Likes
1,395

hi everybody,

the code for amount spell works very well.

i have work this out for simple report.

but problem arises to work in alv,

i have to use block alv is it?

thanx all of u.

regards

pankaj gupta

abap dev