2 Replies Latest reply: Mar 13, 2007 6:23 AM by Guest RSS

Converting quantity to char

Karishma Gandhi
Currently Being Moderated

How to convert quantity to char without using FM's like C14W_CHAR_NUMBER_CONVERSION,

C14W_NUMBER_CHAR_CONVERSION,

CHAR_INT_CONVERSION as these FM's do not exist in my server?

  • Re: Converting quantity to char
    Currently Being Moderated
    declare one char field and assign it to that
    
    data : v_quan type p decimals 2 value '121.34',
             v_char(18).
    
    v_char = v_quan.
    
    write : v_char.
  • Re: Converting quantity to char
    Rammohan Nagam
    Currently Being Moderated

    Hi...

     

    this is my program...try this code....

     

    Parameters:

      p_Number(9) type c.                  " Input string.

     

    data:

      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 positions

     

      w_number = p_number.

     

      w_numc = p_number.

     

      write: 'The given number in words:  '.

     

      do 5 times.

     

        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

Actions