Adding zeros

Can anyone help me with this small query..
Ex. Latitude is generally 2 digits ie 44,55,66 etc. I want to comeup with a select statement which can check if the latitude is two digits or a single digit and add a 0 before the latitude if it is single digit.
Ex: Latiude ir 4 should be 04..

As already suggested you can use to_char with the '09' format model, but remember that an extra blank character at the beginning of the string will be added to manage the sign:
SQL> select length(to_char(4,'09')) from dual;
LENGTH(TO_CHAR(4,'09'))
                      3So if you want a two bytes string you must use the FM09 format model:
SQL> select length(to_char(4,'fm09')), to_char(4,'fm09')
  2    from dual;
LENGTH(TO_CHAR(4,'FM09')) TO_
                        2 04Max
[My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/02/query-gerarchiche/]

Similar Messages

  • (ADI) JOURNAL UPLOAD IS ADDING ZEROS TO SEGMENT VALUES

    제품 : FIN_GL
    작성날짜 : 2003-09-16
    (ADI) JOURNAL UPLOAD IS ADDING ZEROS TO SEGMENT VALUES
    ======================================================
    Problem Description
    ADI에서 Journal Import를 시도할때, Account segment value값에"0"를 자리수만큼 채워서 upload를 시도하는 경우가 있다.
    예를들어, segment value가 300 인데, ADI에서 Journal Import시
    0300 으로 바뀌는 경우이다.
    이 경우, Segment Value중에 0300이라는 값이 없기 때문에, upload시
    에러가 발생한다.
    재현방법 :
    Responsibility = General Ledger Super User
    ADI path = Click on the Ledger Book from the ADI toolbar/Enter Journals
    1. Log on to ADI as the General Ledger Super User.
    2. Proceed to the Create Journal Worksheet form using the above navigation.
    3. Choose the appropriate journal type and click on the green check mark to
    continue. This will load Excel and the appropriate journal template.
    4. Enter your Journal information in the header and body. Place the value of
    the segments that you would like in the segment value portion of the journal.
    5. Once the journal is completed, click on the Ledger Book from the ADI toolbar
    and select the green arrow to upload the journal.
    6. Once the journal upload is complete, you notice that the values that were
    uploaded for a certain segment have a zero added to them.
    Solution Description
    "0"가 자릿수만큼 채워지는 것을 막기위해, ADI setup중 "Zero Pad" 기능을 uncheck한다.
    Responsibility = General Ledger Super User
    ADI path = Click on the Hammer and Screwdriver(망치와 드라이버가 그려져 있는 Icon) from the ADI toolbar/General
    options/Settings
    1. Log on to ADI as the General Ledger Super User.
    2. Proceed to the Settings form using the above menu path.
    3. Uncheck the Zero Pad check box on this form.
    4. Save your changes and repeat the journal import process for this journal.
    Explanation
    "Zero Pad"기능은 check되었을때, 해당 Segment의 Maximun Size만큼 "0"으로 채워준다.
    이 기능을 uncheck하면, "0"의 추가확장 없이 입력된 그대로를 사용하게 된다.
    Reference Documents
    Note : 113051.1

    Hi,
    Are you choosing Functional Journals template and trying to upload Foreign Currency journals or vice versa? Please check
    Regards,
    Sridhar

  • Adding zeros to filenames when exporting in Lightroom "Filename-001" "Fliename-002" etc?

    Hi, does anyone know if it is possible to add zeros before numbers when exporting files eg: "Filename-001" "Fliename-002" etc? The default setting is "Filename-1" "Filename-2" ect. The reason I want to have zeros in the number sequence is that certain software will display files in the wrong numerical sequence eg: "Filename-1" "Filename-10" Filename-11" etc and then "Filename-2" after "Filename-19". If zeros are added the files will always be displayed in the correct sequence "Filename-001" "Filename-002"... "Filename-009" "Filename-010" "Filename-011" etc.

    Just customize the filename using the template editor, and use the Sequence token set to the number of leading zeroes you want, as shown.

  • Adding zeros to the external material number

    Hello Friends,
    I needed your assistance with  a routine in BI 7, Infosource Transformations or in the Infoobject transformations (update Rules).
    I have data comming from a  flat file without the leading zeros for an infoobject.I need to have the leading zeros but i need a code that will do a record count and then accordingly add the zeros.
    EX:     1)  67909344 i need it to look  like  000067909344
              2) 505289 then i need it to look like 000000505289
    Basically, if its 8 digit number then i want 4 zeros before it and if its a 6 digit number then i need 6 zeros before it, those are the only tyoes ill have 6 and 8 digits
    Thanks alot.

    Hello Ronit,
    You can use FM CONVERSION_EXIT_ALPHA_INPUT.
    Declare a variable to contain that value, for example, 67909344.
    If you declare a variable like CHAR10, and use it like this:
    lv_variable = '67909344'.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING                                  
      INPUT  = lv_variable                        
    IMPORTING                                  
      OUTPUT = lv_variable.                       
    The result will be 0067909344.
    If you declare the variable as length 12, the result will be 000067909344.
    And it goes on...
    See if this can be helpful to you.
    Kind regards,
    Bruno
    Edited by: Bruno Garcia on May 27, 2008 5:54 PM

  • Adding zeros to a character string

    Hello friends,
    I want to add leading zeros for a field.
    the field is a character string.
    for example ,
    data: A(5) type c.
    now when A  = 'ab' (non-numeric value)
    i want this to be converted in '000ab'
    so, is there any standard Function module or any other way for doing this conversion ?
    I tried the FM   'CONVERSION_EXIT_ALPHA_INPUT' but this FM does not work for non-numeric inputs..
    Thanks.

    Hi,
    The packed field is transported right-justified to the character field, if required with a
    decimal point. The first position is reserved for the sign. Leading zeros appear as
    blanks. If the target field is too short, the sign is omitted for positive numbers. If this is still not sufficient, the field is truncated on the left. ABAP indicates the truncation with an asterisk (*). If you want the leading zeros to appear in the character field, use UNPACK instead of MOVE.
    UNPACK
    Converts variables from type P to type C.
    Syntax
    UNPACK <f> TO <g>.
    Unpacks the packed field <f> and places it in the string <g> with leading zeros. The opposite of PACK.
    Regards,
    Bhaskar

  • Adding Zeros infront of a field in Message Mapping

    Hi,
    I need to add zeros infront of my target field (eg Target Field length is fixed (10). If incoming field is having only 3 digits (123), I need to add 7 (10-3) zeros infront of my target field (0000000123). How to go about it. Is there any standard functions to do this ?
    Thanks in advance,
    Jose Augastine

    Try using this UDF
    double d = Double.parseDouble(a);
    DecimalFormat df=new DecimalFormat("0000000000");
                   StringBuffer sb=new StringBuffer();
                    df.format(d,sb,new
    FieldPosition(NumberFormat.INTEGER_FIELD));
                   return(sb.toString());
    Regards,
    Jai Shankar.
    Message was edited by: Jai Shankar

  • Strings adding zero's to arrays

    I have a program that arranges 4 arrays which consist of columns of 10
    data points from each iteration of the program. The final program puts
    these sets of 10 pts into one long column. I converted the array into a
    spreadsheet string. I used the match pattern to find and replace the new
    line characters and returns with tabs. Each column has 10 data
    points, then one zero separating them from the next 10 points. I've
    tried the same idea using backspace, form feed, space characters, etc,
    and I still have one row of zeros separating my data points. Does
    anyone have any idea what this character could be or how to fix this? I
    tried all of the characters in the manuals and none will get rid of this
    problem.
    Heather
    Sent vi
    a Deja.com http://www.deja.com/
    Before you buy.

    The poster who suggested the "zeroes" could be squares- signifying a
    non-printable character, may be on the right track.
    However, it occurs to me that you're using quite an unwieldy way of tackling
    a simple problem- and that the way you're using is unnecessarily platform
    dependent and complicated by the need to handle a return and a linefeed.
    I'm not quite sure how your arrays are arranged- as four discreet arrays?
    If it's four separate arrays with 10 points and you want one big array, you
    can use the "build array" function. If you pop up the right mouse button
    menu over this, you see an option to change an input from an element to an
    array. If you make a "build array" with four array inputs, what you get out
    is one long 1D array with the four sets of data appended one after the
    other. If you then want the output as one long column, a useful trick is to
    feed your new array into another "build array" node, this time with only a
    single "element" input. This promotes the 1D array to a single column 2D
    array, that you can then feed through a "transpose 2D array" and then into a
    "build spreadsheet string" to generate your output string without having to
    do all the search and replace operations. You may or may not need the
    "transpose 2D array", depending on how the file turns out- I tend to simply
    do things like this without thinking them through and then tweak them to
    make them work- which I find quicker than going through all the details in
    advance.
    wrote in message news:[email protected]...
    > I have a program that arranges 4 arrays which consist of columns of 10
    > data points from each iteration of the program. The final program puts
    > these sets of 10 pts into one long column. I converted the array into a
    > spreadsheet string. I used the match pattern to find and replace the new
    > line characters and returns with tabs. Each column has 10 data
    > points, then one zero separating them from the next 10 points. I've
    > tried the same idea using backspace, form feed, space characters, etc,
    > and I still have one row of zeros separating my data points. Does
    > anyone have any idea what this character could be or how to fix this? I
    > tried all of the characters in the manuals and none will get rid of this
    > problem.
    >
    > Heather
    >
    >
    > Sent via Deja.com http://www.deja.com/
    > Before you buy.

  • Adding zeros to a string

    Hi all,As you know mara-matnr field's lenght is 18 char, however in some cases the users do not fill all the length, for example they make it 15 char.
    Here I need to add zeros at the beginning of the matnr, as it requires.
    For instance, if the user has entered the matnr as 13 char: 1234567891234
    then I need to make it as 000001234567891234..
    How can I do it?
    Thanks.

    USE THE FUNCTION MODULE,
    <b>conversion_exit_alpha_input.</b>
    conversion_exit function modules are for the purpose of converting a fiedl from user format to sap format and vise versa. there are many conversion exit fn modules.
    u can give converion_exit* in se37 and see many fn modules.
    example: conversion_exit_alpha_output   this is to convert from sap format to user format.
    this means example in mara table the length of matnt would be 18. but if we give 1 value . it takes 0000000000...1. but the user needs the output as only 1. then we can use conversion_exit_alpha_input to convert from sap to user format.
    conversion_exit_alpha_input cn be used viceversa.
    Message was edited by:
            Hymavathi Oruganti

  • Adding zeros to a variable..

    I hav ea program that manipulates/works on six digit number entered by user.what i want is that if user enters less than 6 digits, program adds zeros at the end of number to make it 6 digit. like if user enters 241 program converts it into 241000 before manipulating it.which area i must look into? contecating or what?

    Strings? Strings? We don' need no stinkin' Strings!
      while(x < 100000) x *= 10;this code works for all non-zero input that is actually 6 digits or less.
    You didn't specify what you want to do for zero input, or negative input, or too long input. Here is some more robust code that works for all those cases, but you will need to check if it does what you want.
      int digitLimit = 1000000; // number of zeros here is number of digits.
      if(x<0){ // input was negative
        while(x <= -digitLimit){x /= 10;}
        x = -x; // done backwards to prevent failure on smallest possible negative number
      } else if (x = 0) { // input was zero
        x = 123456;
      } else if (x >= digitLimit) { // input was too big
        while(x >= digitLimit) {x /= 10;}  
      // this final pass deals with both small neg and small pos
      while(x < digitLimit/10){x *= 10;}

  • Adding Zeros to Blank Cells

    Hi,
    I am looking at what should be a simple piece of config, but I am struggling to implement.
    I want to show Zeros in the blank cells in my reports, in order that I can apply conditions and exceptions to them.
    Can anyone suggest a simple solution, as I am sure I am not the only one to experience this.
    Much appreciated.
    Scott

    Dear Scott,
    Iu2019m going to try helping you about your question,
    Please open your query within the BEx query designer, go to properties select the query name (top of the hierarchy) go to Value Display and select in the Zero Value Display the following option u201CZero as Default Textu201D.
    Then, please go to Rows/Columns tab and select the option u201CDo not suppressu201D in Suppress Zero.
    I hope this comment could help you to answer the question,
    Luis

  • Validations with date(Adding zero's)

    Hi,
      can anyone tell me regarding this:
    if the date is 5/5/2008 - the output should be 05/05/2008, means 0 should be concatenated in month and date.
    else if date is 5/12/2008 - the output should be 05/12/2008
    means 0 should be concatenated only in front of 5.
    please help.

    Hi,
    I cant get your requirement clearly. Anyway I give you some solution below:
    1. Declare the variable of TYPE SY-DATUM, so that automatically concatenate zero in front.
    OR
    2. You need to declare one variable as STRING and assign the input date to the string and split it at '/' then store date and month in two other variables and check those two variables are less than 10. If so then concatenate '0' in front else leave as it and finally concatenate as per your requirement.
    Regards,
    Raghu

  • Adding zeros before quantity or price

    hey can you people tell me how to add Zeros in front of quantity field or price field.
    I used conversion_alpha_input FM before writing to file but its not writing with front zeros..
    any alternatives.
    Ambichan

    Hi,
    Please have a look, logic is quite simple.
    REPORT  ZLEADQUANTZEROS                         .
    DATA: L_MENGE(17).
    DATA: L_DEC(13), L_FRACTION(3).
    DATA: T_MSEG TYPE STANDARD TABLE OF MSEG WITH HEADER LINE.
    SELECT * FROM MSEG
    INTO TABLE T_MSEG
    UP TO 100 ROWS.
    LOOP AT T_MSEG.
      L_MENGE = T_MSEG-MENGE.
      SPLIT L_MENGE AT '.' INTO L_DEC L_FRACTION.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = L_DEC
        IMPORTING
          OUTPUT = L_DEC.
          CONCATENATE L_DEC L_FRACTION INTO L_MENGE
          SEPARATED BY '.' .
      WRITE: / L_MENGE.
    ENDLOOP.

  • Query related to adding Zeros -

    I am having a strange requirement...
    I am having a three fields in a table tab1
    code varchar2(2)
    rdate varchar2(8)
    dura number(3)
    and the data is like this -
    DB
    20080101
    5
    but i am having a tab2 table in which all the three fields will become a primary key and the dura which is a number varies from 0 - 999.
    While populating the tab2 i need the data in this format
    DB20080101005 - have to add two zeroes in front of the dura if it is a single digit and have to add one zero if the dura is two digit and none if it is three digit...
    Please help out....!

    test@ORA10G>
    test@ORA10G> with tab1 as (
      2    select 'DB' as code, '20080101' as rdate, 5 as dura from dual union all
      3    select 'DB', '20080101', 45 from dual union all
      4    select 'DB', '20080101', 345 from dual)
      5  --
      6  select
      7    code,
      8    rdate,
      9    dura,
    10    code||rdate||lpad(dura,3,'0') as str
    11  from tab1;
    CO RDATE          DURA STR
    DB 20080101          5 DB20080101005
    DB 20080101         45 DB20080101045
    DB 20080101        345 DB20080101345
    test@ORA10G>
    test@ORA10G>pratz

  • Adding zeros addition

    Hi All,
    there is a variable with length 2,
    if variable having single charcter value like '1'  need to make the variable value '02'
    how to check the variable length and add the zero if variable having only one character.
    please help me
    regards
    krishna

    Hi,
    try the following code..
    data : var type i,
    var2(3) type n.
    var = 2.
    if var < 10.
    var2 = var.
    endif.
    write /: var, var2.
    var2 will ouput with leading zeros...
    Regards,
    Viji

  • Adding zeros before field.

    HI Experts,
    I have one requirement, which i need to add zeros before filed, if field length is less than 6 characters.
    Ex: 1005--> 001005
    12345--->012345
    like above.
    Please give me the code.
    Regards
    Rajini

    data: result(6).
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input         = <ur field>
    IMPORTING
       OUTPUT        =  result .

Maybe you are looking for

  • Ipod touch will not show up in itunes after update 11.1.14.62

    After updating iTunes to 11.1.14.62 my 3 of my 4 devices will not show up in iTunes.  I have two iPod touch devices, an iPhone 4, and an old iPod Shuffle.  The only one that shows up is the iPod Shuffle.    Everything was fine until this latest updat

  • How do I ammend slow bootup time on my Macbook Pro??

    My comp takes 3-5 mins to boot up. I want to know how i can speed up boot up time?

  • I've reloaded my OS so many times & it still randomly shuts down?!

    My Blackberry Curve 9300 shuts down around 40% without any notification. I've replaced the battery and that didn't solve the issue, I've wiped & did a restore & that still didn't resolve the issue. So I replaced the phone and that didn't even resolve

  • Combo boxes

    hi! Is it possible to force a combo box to accept only the values of the list? Now I can type whatever I want in the field, nothing happens, only when I commit the changes it doesn't work, because it is no value from the list; but maybe some user wil

  • Installing Windows 2003 Server Standard/XP is very slow- how long does it take?

    Hello, I'm looking for some ideas here...  I tried installing Windows 2003 on my newly build computer, but after 3 hours it still wasn't installed, and seemed to just be really really slow, and not frozen.  I ended up giving up and tried putting wind