Skip to Content
author's profile photo Former Member
Former Member

REG:Function module

hai,

i want to convert numeric value into text format.

any function module is there.

it's very help full for me..

thank you ,

regards,

sn

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Aug 02, 2006 at 09:40 AM

    try..

    <b>C14W_NUMBER_CHAR_CONVERSION</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 02, 2006 at 09:41 AM

    hi SN,

    If that is the amount use FM <b>SPELL_AMOUNT</b> else use <b>C14W_NUMBER_CHAR_CONVERSION</b> based on your requirement

    Regards,

    Santosh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 02, 2006 at 09:42 AM

    Hello Sn,

    I am assuming you are giving numeric value and want to spell out the value.

    Use SPELL_AMOUT and don't provide currency.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 02, 2006 at 09:42 AM

    Hi ,

    use this one....

    function module....

    FUNCTION Z_CONVERT_AMOUNT_TO_WORDS.

    *"----


    ""Local interface:

    *" IMPORTING

    *" VALUE(F_AMOUNT) LIKE KONV-KAWRT

    *" VALUE(F_CURRENCY) LIKE EKKO-WAERS

    *" EXPORTING

    *" REFERENCE(WORDS) LIKE SPELL-WORD

    *" EXCEPTIONS

    *" ZERO_VALUE

    *" INCORRECT_AMOUNT

    *" AMOUNT_HIGH

    *" INVALID_CURRENCY

    *"----


    tables : tcurt.

    data: maxno type p.

    data : words1 like SPELL.

    SELECT SINGLE * FROM TCURt WHERE WAERS = F_CURRENCY

    and SPRAS = 'EN'.

    if sy-subrc <> 0.

    raise invalid_currency.

    endif.

    if F_CURRENCY = 'INR'.

    maxno = 10 ** 10.

    if ( F_AMOUNT >= maxno ).

    raise AMOUNT_HIGH.

    endif.

    data declaration----


    data: ten(10),single(6),final(130),dec(20),res type i,rp(7).

    data: a1 type i,a2 type i,str(20),d type p,m type i,wrdrep(20).

    data: cntr type i,f1 type i,f2 type i,f3 type i,f4 type i,f5 type i.

    data: f6 type i,f7 type i,f8 type i,f9 type i,f10 type i.

    d = ( F_AMOUNT * 100 ) div 100.

    res = ( F_AMOUNT * 100 ) mod 100.

    if res > 100.

    raise incorrect_amount.

    endif.

    f1 = res div 10.

    f2 = res mod 10.

    perform setnum using f1 f2 changing wrdrep.

    f1 = 0. f2 = 0.

    dec = wrdrep.

    cntr = 1.

    *Go in a loop dividing the numbers by 10 and store the

    *residues as a digit in f1 .... f9

    while ( d > 0 ).

    m = d mod 10.

    d = d div 10.

    case cntr.

    when 1. f1 = m.

    when 2. f2 = m.

    when 3. f3 = m.

    when 4. f4 = m.

    when 5. f5 = m.

    when 6. f6 = m.

    when 7. f7 = m.

    when 8. f8 = m.

    when 9. f9 = m.

    when 10. f10 = m.

    endcase.

    cntr = cntr + 1.

    endwhile.

    cntr = cntr - 1.

    *Going in loop and sending pair of digits to function setnum to get

    *the standing value of digits in words

    while ( cntr > 0 ).

    if ( cntr <= 2 ).

    perform setnum using f2 f1 changing wrdrep.

    concatenate final wrdrep into final separated by ' '.

    elseif ( cntr = 3 ).

    if ( f3 <> 0 ).

    perform setnum using 0 f3 changing wrdrep.

    concatenate final wrdrep 'Hundred' into final separated by ' '.

    endif.

    elseif ( cntr <= 5 ).

    if ( f5 <> 0 ) or ( f4 <> 0 ).

    perform setnum using f5 f4 changing wrdrep.

    concatenate final wrdrep 'Thousand' into final separated by ' '.

    endif.

    if ( cntr = 4 ).

    cntr = 5.

    endif.

    elseif ( cntr <= 7 ).

    if ( f7 <> 0 ) or ( f6 <> 0 ).

    perform setnum using f7 f6 changing wrdrep.

    concatenate final wrdrep 'Lakh' into final separated by ' ' .

    endif.

    elseif ( cntr <= 9 ).

    perform setnum using f9 f8 changing wrdrep.

    concatenate final wrdrep 'Crore' into final separated by ' ' .

    elseif ( cntr = 10 ).

    perform setnum using 0 f10 changing wrdrep.

    concatenate final wrdrep 'Hundred' 'And' into final separated by ' '.

    endif.

    cntr = cntr - 2.

    endwhile.

    *Output the final

    if ( final = ' One' ).rp = 'Rupee'.else. rp = 'Rupees'.endif.

    if ( final = '' ) and ( dec = '' ).

    final = 'NIL'.

    elseif ( final = '' ).

    concatenate 'Paise' dec 'Only' into final separated by ' ' .

    elseif ( dec = '' ).

    concatenate rp final 'Only' into final separated by ' ' .

    else.

    concatenate rp final 'Paise' dec 'Only' into final separated by ' '

    .

    endif.

    words = final.

    else.

    call function 'SPELL_AMOUNT'

    EXPORTING

    AMOUNT = F_AMOUNT

    CURRENCY = F_CURRENCY

    • FILLER = ' '

    • LANGUAGE = SY-LANGU

    IMPORTING

    IN_WORDS = words1

    • EXCEPTIONS

    • NOT_FOUND = 1

    • TOO_LARGE = 2

    • OTHERS = 3

    .

    if sy-subrc = 0.

    words = words1-word. endif.

    concatenate tcurt-ktext words 'Only' into words separated by ' '

    .

    endif.

    endfunction.

    &----


    *& Form SETNUM

    &----


    • converts a number into words *

    ----


    • --> a1,a2 two digits for 2nd and 1st place

    • <-- str outpur in words

    ----


    data: ten(10),single(6),str(20).

    *

    form setnum using a1 a2 changing str.

    ten = ''.single = ''.

    if ( a1 = 1 ).

    case a2.

    when 0. ten = 'Ten'.

    when 1. ten = 'Eleven'.

    when 2. ten = 'Twelve'.

    when 3. ten = 'Thirteen'.

    when 4. ten = 'Fourteen'.

    when 5. ten = 'Fifteen'.

    when 6. ten = 'Sixteen'.

    when 7. ten = 'Seventeen'.

    when 8. ten = 'Eighteen'.

    when 9. ten = 'Nineteen'.

    endcase.

    else.

    case a2.

    when 1. single = 'One'.

    when 2. single = 'Two'.

    when 3. single = 'Three'.

    when 4. single = 'Four'.

    when 5. single = 'Five'.

    when 6. single = 'Six'.

    when 7. single = 'Seven'.

    when 8. single = 'Eight'.

    when 9. single = 'Nine'.

    endcase.

    case a1.

    when 2. ten = 'Twenty'.

    when 3. ten = 'Thirty'.

    when 4. ten = 'Forty'.

    when 5. ten = 'Fifty'.

    when 6. ten = 'Sixty'.

    when 7. ten = 'Seventy'.

    when 8. ten = 'Eighty'.

    when 9. ten = 'Ninety'.

    endcase.

    endif.

    if ( single <> '' ) and ( ten <> '' ).

    concatenate ten single into str separated by ' '.

    elseif single = ''.

    str = ten.

    else.

    str = single.

    endif.

    endform. " SETNUM

    cheers,

    Simha.

    <b>Reward all the helful answers...</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 02, 2006 at 09:44 AM

    Just use the FM <b>SPELL_AMOUNT</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 02, 2006 at 09:48 AM

    hai,

    i want to convert 1 means one

    2 means two

    like that not curreny field..

    spell_amount

    C14W_NUMBER_CHAR_CONVERSION

    any other function module is there..

    thanks in advance,

    sn

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      I think the simplest solution is to read table T015Z with language, unit and figure.

      example in T015Z

      Language = EN

      Unit = 0

      Figure = 1

      Number in words = ONE;

      It ends with semi-colon but surely you can use translate command to replace it with space.

      Regards

      Anurag

      Regards

      Anurag

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.