05-03-2007 11:54 AM
need to create a program wherin i ve to convert amount into words without FM spell_amount.the table T015z shows the digits and numbers in words but how to get the units tens and hundreds place together if user enters 2-3 digit number?
05-03-2007 11:58 AM
Hi,
Make use of this FM, this will solve ur query.
HR_IN_CHG_INR_WRDS
CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
EXPORTING
amt_in_num =
IMPORTING
AMT_IN_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.
Regards,
Suresh
05-03-2007 12:01 PM
thanks for suggesting alternative..bt i want to convert without using any FM
05-03-2007 12:05 PM
Hi..
Just paste this code...solves ur problem..
<b>Parameters:</b>
p_Number(9) type c. " Input string.
<b>data:</b>
w_number(9) type c, " Input number
w_strlen(9) type c, " Strlen
w_numc(9) type n, " Digit string
w_2bit(2) type c. " first 2 ositions
w_number = p_number.
w_numc = p_number.
write: 'The given number in words: '.
<b>do 5 times.</b>
case sy-index.
when 1.
w_2bit = w_numc+0(2).
when 2.
w_2bit = w_numc+2(2).
when 3.
w_2bit = w_numc+4(2).
when 4.
w_2bit+0(1) = 0.
w_2bit1(1) = w_numc6(1).
when 5.
w_2bit = w_numc+7(2).
endcase. " CASE SY-INDEX.
if w_2bit+0(2) ne 0.
if w_2bit le 19.
case w_2bit.
when '01'.
write 'ONE'.
when '02'.
write 'TWO'.
when '03'.
write 'THREE'.
when '04'.
write 'FOUR'.
when '05'.
write 'FIVE'.
when '06'.
write 'SIX'.
when '07'.
write 'SEVEN'.
when '08'.
write 'EIGHT'.
when '09'.
write 'NINE'.
when '10'.
write 'TEN'.
when '11'.
write 'LEVEN'.
when '12'.
write 'TWELVE'.
when '13'.
write 'THIRTEEN'.
when '14'.
write 'FOURTEEN'.
when '15'.
write 'FIFTEEN'.
when '16'.
write 'SIXTEEN'.
when '17'.
write 'SEVENTEEN'.
when '18'.
write 'EIGHTEEN'.
when '19'.
write 'NINETEEN'.
endcase. " CASE 2BITS POSITIONS 1,2.
else.
case w_2bit+0(1).
when '2'.
write 'TWENTY'.
when '3'.
write 'THIRTY'.
when '4'.
write 'FOURTY'.
when '5'.
write 'FIFTY'.
when '6'.
write 'SIXTY'.
when '7'.
write 'SEVENTY'.
when '8'.
write 'EIGHTY'.
when '9'.
write 'NINETY'.
endcase. " CASE W_2BIT+0(1)
if w_2bit+1(1) ne 0.
case w_2bit+1(1).
when '1'.
write 'ONE'.
when '2'.
write 'TWO'.
when '3'.
write 'THREE'.
when '4'.
write 'FOUR'.
when '5'.
write 'FIVE'.
when '6'.
write 'SIX'.
when '7'.
write 'SEVEN'.
when '8'.
write 'EIGHT'.
when '9'.
write 'NINE'.
when others.
write ' '.
endcase. " CASE W_2BIT+1(1)
endif. " IF W_2BIT+1(1)
endif. " IF 2BIT LE 19
case sy-index.
when 1.
write 'CRORES'.
when 2.
write 'LAKHS'.
when 3.
write 'THOUSANDS'.
when 4.
write 'HUNDREDS'.
endcase. " CASE SY-INDEX
endif. " IF 2BIT NE 0
<b>enddo. </b> " DO 5 TIMES
<b>add Ruppes at last.</b>
Message was edited by:
Rammohan Nagam
05-03-2007 12:00 PM
Hi,
try this code
TABLES SPELL.
DATA : T_SPELL LIKE SPELL OCCURS 0 WITH HEADER LINE.
DATA : PAMOUNT LIKE SPELL-NUMBER VALUE '123451022343333235'.
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
or
Use FM HR_IN_CHG_INR_WRDS
DATA cur LIKE pc207-betrg VALUE '100000.00'.
DATA words(100) TYPE c.
CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
EXPORTING
amt_in_num = cur
IMPORTING
amt_in_words = words.
WRITE words.
Regards
Nilesh
05-03-2007 12:00 PM
HI Rashmi
Did u try FM <b>HR_IN_CHG_INR_WRDS</b>
DATA cur LIKE pc207-betrg VALUE '100000.00'.
DATA words(100) TYPE c.
CALL FUNCTION 'HR_IN_CHG_INR_WRDS'
EXPORTING
amt_in_num = cur
IMPORTING
amt_in_words = words.
WRITE words.
Regards Rk
05-03-2007 12:01 PM
Hi Rashmi,
I fu dont wanna use any of the function modules u can acheive it by using case statement.
i will give u the logic.
capture each digit of the number pass it to case structure and assign the word equilant to that digit.
hope u got it.
reward if helpful.
regards,
Ravi G
05-03-2007 12:01 PM
Hi
Use the STRLEN function to find the length of the number
if it contains say for example 4 digits
take the leftside 1st digit and use THOUSAND along with number spell. for 2nd digit use HUNDRED along with number spell
and to concatenate all together
Reward points if useful
Regards
Anji