Converting char to decimal value format as defined in SU3(User profile)

Hi Techies,
Is there any FM to convert CHAR value into Decimal fomat as defined in SU3.
If we use, WRITE statement for printing the value in decimal format , it shows the value in decimal format correctly
in SU3 transaction , there are three different decimal format notations which can be user specific
I would appreciate your valuable inputs ....
Thanks
Santhosh

This is my code in a generic method to transform a table into a csvrow
when 'P'.
        tmpstr = <p_field>.
        len = strlen( tmpstr ) - 1.
        tmpstr = tmpstr+0(len).
        if <p_field> < 0.
          sign = '-'.
        else.
          sign = ' '.
        endif.
        case decimalformat.
          when 'X' or 'E'.
            split tmpstr at '.' into int frac.
            ptmp = int.
            write ptmp to cp.
            shift cp left deleting leading space.
            replace all occurrences of '.' in cp with ','.
            concatenate
              s
              sign
              cp
              frac
              delimiter
            into s in character mode.
          when 'Y' or 'D'.
            split tmpstr at '.' into int frac.
            ptmp = int.
            write ptmp to cp.
            shift cp left deleting leading space.
            replace all occurrences of ',' in cp with '.'.
            concatenate
              s
              sign
              cp
              frac
              delimiter
            into s in character mode.
          when ' '.
            concatenate s sign tmpstr delimiter into s in character mode.
          when others.
            concatenate s '????????' delimiter into s in character mode.
        endcase.
where pfield is a fieldsymbol type P. (honestly ist from type any, but determined by RTTI). I needed this cause i want to format the value from "outside" without taking the user settings in consideration as write...to.. is doing.
What i'm doing is to use the write... to... clause modifying the result (change decimal point, thousand separator and sign) according to the demanded decimal notation.
Edited by: Rainer Hübenthal on Oct 7, 2009 4:47 PM

Similar Messages

  • Converting the comma seperator value  format

    i am getting the content of a table in a internal table with comma separator value format, dynamically by using dfies table i am getting the header of the table, and displaying it in the output, now my query is that the content of the data which i am getting in a itab having only one field of type string
    data : begin of itab occurs 0,
              data1 type string,
             end of itab.
    some where they were concatenating the content of the data and storing it inthe itab, now i want the content of the itab should be displayed corresponding to there header in the output

    Hi Santosh,
    You can remove the commas from the record by using the REPLACE command as below -
    LOOP AT itab.
      DO.
        REPLACE ',' WITH '' INTO itab-data1.
        IF sy-subrc NE 0.
          EXIT.
        ENDIF.
      ENDDO.
    ENDLOOP.
    Reward points if found useful...!
    Cheers
    Abhishek

  • Converting char to number value specfically like '6.35'

    I am facing a very peculiar problem, if i try to convert a FLOATING NO. in form of CHARACTER to NUMBER value , then to_number function gives VALUE-ERROR
    eG. TO_NUMBER('6.35') is resulting in an error. But TO_NUMBER('6') works fine. My forms are working absolutely ok on 2-tier but not on 3-tier.Please Help.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Bogdan Dincescu ([email protected]):
    Must have something to do with your NLS settings on your application server, something for the decimal separator. I guess to_number('6,35') would work OK.
    I'm not sure exactly what settings you should have on the application server.<HR></BLOCKQUOTE>
    Thank you for your reply, I guess it can be the problem becoz forms with such code are working fine on Win2000 but are giving a problem on NT , can u give me a clue why it is happening ???
    null

  • Data conversion - How to convert char to decimal variant?

    Hi expert,
    In the example below, I want to convert the variable l_var1 to l_result
    data l_var1(16) type c.
    data l_preis(11) TYPE p DECIMALS 2.
    data l_result(11) TYPE p DECIMALS 2.
    l_preis = 10981.
    write l_preis to l_var1.
    after the write statement, l_var1 = 10,981.00. currently i want to move l_var1 to l_result. Is there anyone who knows how to do it? Thank you very much.

    Hi Liu,
    I want to know the exact requirement. Instead of what you are trying to do , you can do the following way.
    DATA l_var1(16) TYPE c.
    *data l_preis(11) TYPE p DECIMALS 2.
    DATA l_result(11) TYPE p DECIMALS 2.
    l_var1 = 10981.
    MOVE l_var1 TO l_result.
    WRITE l_result.
    <li> MOVE statement gives desired result. It gives rounding values.
    Thanks
    Venkat.O

  • Converting char to numeric value

    I have table with social security no. but application does not
    have any validation for data so i get all different kinds of
    data like...
    123-24-0988
    123458900
    n/a
    N
    f234-90-8877
    12 345 6789
    Now i want to remove all '-' and alpha char from value and just
    want to remain only nuemric characters so i can use it as where
    parameter.
    Is their any function that i can use for this or any other logic
    that i can use for this?
    Thanks

    As demonstrated in a previous discussion regarding checking for
    numeric values, translate does not produce the proper results
    when you translate it to a null value. However, you can achieve
    the desired results, by translating to spaces, then replacing
    the spaces:
    UPDATE table_name
    SET ssn = REPLACE (TRANSLATE (LOWER
    (ssn), 'abcdefghijklmnopqrstuvwxyz- ', ' '), ' ', '');

  • Converting character to decimal format

    hi
    i am working on a development where the selection screen has date and time as select options.
    and based on the input i have to concatenate date and time into the format- DD.MM.YYY HH.MM.SS
    there is a value in the table that has a field containing the above value and i have to fetch the data based on this input.
    Now the problem is the field in the table is of format DECIMAL of 16 length.
    i want to know how can i pass this value to the select statement.
    thanks in advance

    Hi ,
    Please check the blog on the below link.
    [Re: Converting char to decimal value format as defined in SU3(User profile);
    This will solve your query.
    Regards
    Abhii......

  • Converting Time format to Decimal Value

    Dear All,
    How to convert time to decimal value for substraction of time and decimal value
    for eg l_time type tims
           l_dec type p.
    l_diff = l_time - l_dec
    Kindly let me know.
    Thanks in Advacne,
    Ranjan

    Hi,
    Try like this...
    PARAMETERS : tim TYPE tims,
                 y TYPE p.
    DATA : t TYPE string,
           t1 TYPE string,
           t2 TYPE string,
           t3 TYPE string.
    START-OF-SELECTION.
      t = tim(2).
      t  = t * 3600. " hours to second
      t1 = tim+2(2).
      t1 = t1 * 60.  " minutes to second
      t2 = tim+4(2).
      t3 = t + t1 + t2. " total time in second
      t3 = t3 - y.
    Regards
    Debarshi

  • Convert inch fraction to decimal value

    I get a lot of printer requirements tin Fractions (12 11/16 Inches, 2 1/8 inches, etc.) Is there a way in illustrator to convert those to decimal values?

    In illustrator, most dialog boxes can do math, so do the fraction first. 5/8  which would be .625 then enter the whole number 12 in front of the decimal 12.625
    That's assuming the dialog box can not handle the whole number and the fraction at the same time.

  • How to convert string to decimal in data association function?

    In a BPM Script component, how in the Data Association can I use an expression to convert an argument from String to Decimal?  I have a Process argument named percentage which is a string.  I need to set the value of a data object called signed to either "Y" or "N" based on the percentage being greater than 0.4.  Something like this:
    (percentage > 0.4) ? "Y" : "N"
    The problem here is that percentage is a string, so must be converted to a decimal value before the compare will work.  I cannot find a function that allows that.  I need something like parseDecimal(percentage), but the Expression Builder does not offer that for a string using a Simple Expression.
    If it cannot be converted, is there another way to do this?

    Guessing you figured this out on your own, but if you wanted to use a Script activity one way to do what you want is when you're creating your data associations drag the "Expression" icon in the middle and double click the icon in the middle you just added:
    Get out of the Simple expression mode and into the XPath expression mode by clicking the dropdown in the upper left corner -> click "XPath Exp".
    In the Functions dropdown on the right, click "Conversion Functions" -> click "number" and then insert it into the expression.
    In the Variables list, select your string variable and insert it into the number function so that it looks something like this:  number(bpmn:getDataObject('myStringVariable'))
    Click OK
    Click your expression icon in the middle and drag it over your decimal variable.
    To have it evaluate and return a Boolean expression in your Script activity, add a Boolean process variable and add an XPath expression as described above except have the logic be this:  number(bpmn:getDataObject('myStringVariable')) > .4  (the "greater than" shown above is added to the expression by clicking "Logical Functions" from the functions dropdown).  Click OK and drag your expression icon over your Boolean variable.
    Dan

  • Public int indexOf(int ch, int fromIdx) doesn't work for some decimal value

    I have tested two strings below. These two string are identical, except the first string has a char 'ƒ, which has a decimal value of 131. And the second string has a char 'À', which has a decimal value of 192. I am expecting the same output, which is 11, but I got -1 for the test I did using the first string. In the API for public int indexOf(int ch, int fromIndex), values of ch is in the range from 0 to 0xFFFF (inclusive). It is highly appreciated if anyone could provide any insights on why -1 returned when the first string is tested. Thank you in advance.
    String strHasDecimal131 = "Test value ƒ, it has a decimal value of 131";
    String strHasDecimal192 = "Test value À, it has a decimal value of 192";
    int badDecimal = 131;
    int idxBadDecimal = strHasDecimal131.indexOf( badDecimal, 0);
    System.out.println( "index of Bad Decimal: " + idxBadDecimal );
    The output is: index of Bad Decimal -1
    int badDecimal = 192;
    int idxBadDecimal = strHasDecimal192.indexOf( badDecimal, 0);
    System.out.println( "index of Bad Decimal: " + idxBadDecimal );
    The output is: index of Bad Decimal: 11

    Thank you everyone for your inputs. Following are the print statements and the output: for character 'ƒ' and ' À':
    System.out.println((int)'\u0083' + ", " + (int)'\u00C0' + " print decimal value" );
    Output: 131, 192 print decimal value
    System.out.println((char)'\u0083' + ", " + (char)'\u00C0' + " print character value" );
    Output: ?, À print character value
    According to Latin-1 Supplement table, the first char in the output would have the appearance of ƒ, instead it has the appearance of ?
    System.out.println( (int)'ƒ' + ", "+ (int)'À' + " print integer value");
    Output: 402, 192 print integer value
    I also have tried to print out the decimal value of following char: € &#65533; ‚ ƒ „ … † ‡, according to Latin-1 Supplement table, these char has decimal value of 128 through 135 and hex value 0x0080 through 0x0087. And the output from java println is: 8364 65533 8218 8222 8230 402 8224 8225.
    System.out.println((int)'€' + " " + (int)'&#65533;' + " " + (int)'‚' + " " +(int)'„' + " " + (int)'…' + " " +(int)'ƒ' + " " + (int)'†' + " " + (int)'‡' );
    As I did before, I print out character of decimal value of 128 through 135
    System.out.println((char)128 + " " + (char)129 + " " + (char)130 + " " +(char)131 + " " + (char)132 + " " +(char)133 + " " + (char)134 + " " + (char)135 );
    Output: ? ? ? ? ? ? ? ?
    Not sure why java prints character for decimal value of 128 through 159 differently from what appears in the Latin-1 Supplement table. Any of your inputs are appreciately.

  • How to Convert your DVD to any format at your will...

    Long time ago, I hope I could take part in some classes to strengthen my health and my good figure. But due to my special job as a salesman, I don't have enough time to do that. So I bought one DVD of yoga, I hope I could do that through watching DVD. So I put DVD into my computer to be ready to practice, unfortunately all my players can't read them. I feel so upset. I tried to look for nearly all the ways I knew to deal with it, but nothing had happened. One of my friends introduce AiseesoftDVD Riper to me. I tried it, yes, it works. Now I could play yoga anytime and anywhere when I am free. It is benifit both for my health and my figure, I love this feelings. Now I hope I could help you through my experiences.
    This guide aims to show you how to convert DVD to different video format both for windows/mac users.
    Part 1: How to Convert DVD on Windows with AiseesoftBest DVD Ripper
    Step 1: Load DVD
    Put your DVD to your DVD Drive and click "Load DVD" button to add your DVD
    Step 2: Choose Profile
    Choose your output video profile from a drop-down list.
    Step 3: Start Conversion win
    Part 2: How to Convert DVD on Mac with AiseesoftDVD Ripper for Mac
    Step 1: Load DVD
    Click the "Load DVD" button, find the DVD folder of the movie you want to add from your DVD-ROM, and Click "Open".
    Step 2: Choose output profile and settings
    Selecting output format is really easy, you can chose your output format according to your devices players and the default setting works great.
    For a veteran of digital player, you could customize your own settings by clicking "Settings" button to chose your own video resolution, frame rate, bit rate, encoder, etc.
    Step 3: Start Conversion
    What amazing softwares! I hope it is helped for all of you.

    Hi,
    source structure---------------------->target structure
    x--------------------------------------->y
        sample------------------------------->root1
        a(1)------------------------------------->attribute1
        b(2)------------------------------------->attribute2
        c(3)------------------------------------->attribute3
            sample1(123)------------------------->element1
             a(1)-------------------------------->attribute1.1
             b(2)-------------------------------->attribute1.2
             c(3)-------------------------------->attribute1.3
    Everything specified under target are elements.

  • Loading decimal  value to an infoobject of type char

    I have an extract structure with field timestamp, which is of type dec and length 15. Now i want to load this value to an infoobject in ODS. But this infoobject is of type char and length 18. when infopackage loading is scheduled it is giving the following error. Record 1 :InfoObject /BIC/IFITMSTMP does not contain alpa-conforming value 20061206084944.
    Is it because i tried to move a dec valu into a char field with a different length? If so  how will i load a decimal value of length 15 to a char of length 18. Can anyone please help me with this?
    Thanks in advance.

    if u r using BI7.0
    go to the datasource of the cube
    in the general info tab of the datasource
    there is a check box with PSA not typed
    check it
    if u check it all the values from the external source will be converted into character format irrespective of their data type

  • Loading a decimal value to an infoobject of type char

    I have an extract structure with field timestamp, which is of type dec and length 15. Now i want to load this value to an infoobject in ODS. But this infoobject is of type char and length 18. when infopackage loading is scheduled it is giving the following error. Record 1 :InfoObject /BIC/IFITMSTMP does not contain alpa-conforming value 20061206084944.
    Is it because i tried to move a dec valu into a char field with a different length? If so  how will i load a decimal value of length 15 to a char of length 18. Can anyone please help me with this?
    Thanks in advance.

    if u r using BI7.0
    go to the datasource of the cube
    in the general info tab of the datasource
    there is a check box with PSA not typed
    check it
    if u check it all the values from the external source will be converted into character format irrespective of their data type

  • Convert the money datatype to a 2 decimal point format.

    Whats the best way to convert the money datatype to a 2 decimal point format in ms sql 2005 for use in my applications.
    this?
    CAST(tr.depositReceivedAmount AS decimal(10 , 2))

    I respectfully disagree with the notion that you should change the SQL column from a 'money' data-type to something else.
    In most database servers, 'money' is a data type that is designed to provide very consistent behavior with regard to arithmetic accuracy.  In Microsoft Access, the representation is a scaled-integer.  In MS SQL Server, it is obviously similar.  Ditto Oracle and all the others.
    You want the money data-type in the database to have this accuracy, because "hell hath no fury like an accountant in search of one lousy penny."   The database column storage-formats are designed to satisfy accountants, and that is a Good Thing.
    Meanwhile, you also want to take care as to exactly how you deal with the values.  There are several points where rounding could take place.  You do not have at your disposal the strongest possible handling of floating data-types in ColdFusion.  You are also somewhat at the mercy of whatever interface software may lie between you and whatever SQL server you may use.  "It's okay to round values once, but not multiple times."
    I suggest rounding the value right before display, and stipulating that the user's input must be two decimal places.
    Then, you might have to do some things at the SQL server's end.  For instance, when you update a value in the table, you may need to use server-side logic to explicitly truncate the value to two decimal-points, so that an update of "$34.56" explicitly updates the column to "$34.5600."  (This sort of thing has to happen within the SQL server context.)  You know that the user's input has exactly two significant digits, but maybe (maybe not...!) the SQL server might not know this.  You want to ensure that the server's internally-stored value represents exactly two significant digits, when the value originates from a user-input.
    Don't err on the side of "your convenience" or "what looks good on-screen."  (If you do, get ready to get phone-calls from the accountants, always at inopportune hours of the night.)

  • Very Urgent - Converting Character value to Hexa Decimal value

    Hi
    data: lv_stsor_hex(16) type X.
    p_is_ppc_comp_conf-stsor is a char 10 field ***
    <b>write p_is_ppc_comp_conf-stsor to lv_stsor_hex.</b> "<-- Hex Conversion
    In 4.6C version this write statement is working fine but this is obsolete in ECC 6.0
    and its showing syntax error.
    Can anyone tell me how to convert a 10 char length value to a hexa decimal value
    which is of 16 characters length and of type hexadecimal
    Thanks a lot. Points will be rewarded immediately.

    Hi,
    Use the Function module CHAR_HEX_CONVERSION.
    report zeta_hex.
    data: s type string.
    data: h(1) type x.
    data: c(1) type c.
    data: byte(2) type c.
    data: length type i.
      FIELD-SYMBOLS: <DUMMY>.
    s = 'ThisIsAString'.
    length = strlen( s ).
    do length times.
      byte = ( sy-index - 1 ).
      c = s+byte(1).
    * You can do this
      ASSIGN h TO <DUMMY> TYPE 'X'.
      WRITE c TO <DUMMY>.
    * or you can do this
    *  call function 'CHAR_HEX_CONVERSION'
    *       exporting
    *            input     = c
    *       importing
    *            hexstring = h.
      write:/ h.
    enddo.
    Regards
    Sudheer

Maybe you are looking for