Substr function? extracting just the records with 4 digits?

have a column like this in a table
SZSCAPD_SEC_SCHOOL_CEEB
364775
460460
460240
2562
164625
460240
230969I need to be able to retrieve just the values with 4 digits like 2562 and add 00 at the front, so it will ended like 002562
I am thinking in the substr function, but it won't work, because I will be extracting the first 4 digits of each number.
How I will do this? I want to only retrieve the numbers with 4 digits Then I will concatenate the 00 in front.
Thank you

Hi,
peace4all wrote:
... How I will do this? I want to only retrieve the numbers with 4 digits One way to do that is
WHERE   TRANSLATE ( szscapd_sec_school_ceeb
            , '123456789'
            , '000000000'
            ) = '0000'
Then I will concatenate the 00 in front.
'00' || szscapd_sec_school_ceebThis assumes that szscapd_sec_school_ceeb is a string.
If szscapd_sec_school_ceeb is a positive number, and you want to ignore any fractional part, use
WHERE   szscapd_sec_school_ceeb     >=  1000
AND     szscapd_sec_school_ceeb <  10000to find the numbers and
TO_CHAR (szscapd_sec_school_ceeb, 'FM000000')to display them as 6 digits, with leading 0's.
Edited by: Frank Kulash on Aug 20, 2010 11:01 AM
Added NUMBER alternative.

Similar Messages

  • Use of substr function will avoid the use of indexes in a table

    i have one table which will contain some 3,00,000 records, it contains some 11 primary keys i am using some update statements to update some fields in the records (of 3,00,000 i will compare some 1,50,000 records with 1,50,000 another records) i am using substr function in all the select statements. whether usage of substr function will avoid the use of index
    can any one clarify?

    contains some 11 primary keys by this I suppose you mean to say the table has a composite PK on 11 columns.
    i am using substr function in all the select statementsCould you please post your SQL statement?

  • Unable to extract all the records initial run(for Datasource 0HR_PY_1).

    Hi All,
    I was trying to extract the data using 0HR_PY_1 Data Source (HR-Payroll related).  When I use Full update in BW, it extracts all the records from R/3 but when I use Init load to extract the data, it is not extracting all the records(some records are missing).
    So I dont know what exactly is happening. I also checked RSA7 and deleted the entry for this data source (this entry was created because we tried to do some test delta in the past).
    When I goto RSA3(Extractor Checker) and use update mode "F" (along with some selection criteria employee#284), it shows 550 records which is the correct number.But when I use the update mode "C"(Initialization of the delta transfer),  I just get 490 records only.
    So I am thinking is there anything I need to do to reset the initialization tables somewhere on r/3 side or do some kind of settings on r/3 by which I can extract all the records by using INIT load.

    I noticed a weird thing in RSA3,
    I tested this without any selection criteria.
    Using "F" update mode, the total number of records were 173,654
    Using "C" update mode, the total number of records were 176,205
    So, even though I was getting less number of records by using "Full" update mode, I was able to see the latest data I wanted. But When I use "C" update mode, even though the number of records is more, still I could not see the latest data (6/2007)???
    So dont know what exactly is happening!!

  • I just got my new iphone. I successfully signed in my apple account by i have an issue with my icloud. It took my email but the password is incorrect. is the apple account email just the same with the icloud email?

    I just got my new iphone. I successfully signed in my apple account by i have an issue with my icloud. It took my email but the password is incorrect. is the apple account email just the same with the icloud email?

    ckuan is right.
    also you can check you Apple ID in this website, https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/

  • Bex Hierarchy showing just the key with Attributes ????

    Hierarchy showing just the key with Attributes ????  I want the Text without attribute!
    I had created a Hierarchy manually on 0companycode characteristic, but I have some problems.
    1 u2013 Itu2019s showing just the KEY (On query Design is marked to show the text , and Iu2019m on the proper language).
    2 u2013 On the last lever that is the company code, is showing the key with all attributes like this.
    ->     CONTRY_BR
                    -> KW11 Contry Canada Chart of account 0001 Currency 01
    I want just the Text without the attributes.
    Regards
    Edited by: Marcus Coufal on Mar 4, 2011 1:53 PM

    On the caracteristic -> attribute put 0 on  "Order For"

  • How to extract the record with latest date

    in internal table i a have 10 records, in that for each record only date is changing...so,now the issue is i should extract the record which having the latest date

    try this code -
    data: begin of itab occurs 0,
          name(20),
          add(20),
          bp like sy-datum,
          end of itab.
    itab-name = 'aaa'.
    itab-add = '123'.
    itab-bp = '20061220'.
    APPEND ITAB.
    CLEAR ITAB.
    itab-name = 'bbb'.
    itab-add = '123'.
    itab-bp = '20061219'.
    APPEND ITAB.
    CLEAR ITAB.
    itab-name = 'aaa'.
    itab-add = '123'.
    itab-bp = '20061222'.
    APPEND ITAB.
    clear itab.
    sort itab descending by bp.
    read table itab index 1.
    write: itab.

  • Query to get the records with same last name

    I need to write a single sql query to get all records with duplicate last_name's. For example, if tab1 has 4 records:
    10     Amit     Kumar
    20     Kishore          Kumar
    30     Sachin     Gupta
    40     Peter     Gabriel
    then the query should return
    10     Amit     Kumar
    20     Kishore     Kumar
    id, name,L_name being the 3 columns in table
    Apprecite you help.
    Thank you
    Mary

    SQL> create table mytable (id,name,l_name)
      2  as
      3  select 10, 'Amit', 'Kumar' from dual union all
      4  select 20, 'Kishore', 'Kumar' from dual union all
      5  select 30, 'Sachin', 'Gupta' from dual union all
      6  select 40, 'Peter', 'Gabriel' from dual
      7  /
    Table created.
    SQL> select id
      2       , name
      3       , l_name
      4    from ( select t.*
      5                , count(*) over (partition by l_name) cnt
      6             from mytable t
      7         )
      8   where cnt > 1
      9  /
                                        ID NAME    L_NAME
                                        10 Amit    Kumar
                                        20 Kishore Kumar
    2 rows selected.Regards,
    Rob.

  • How to delete the records with routine Z_AFRP4_DELETE as note [418584|

    Hello Gurus,
    I don't want to transfer data into HR and want to delete the records in table AFRP4 to business complete the Maintenance Orders
    Component version- EHP7 for SAP ERP 6.0
    Component-EA-APPL
    Release-617
    how can I delete these records
    Thanks fro Help
    AM

    Hello All,
    I found the solution, I copied the code in correction instruction number 0000282352 and create the report as programme  Z_AFRP4_DELETEand the executed
    *$*$----------------------------------------------------------------$*$*
    *$ Correction Inst.         0120061532 0000282352                     $*
    *$--------------------------------------------------------------------$*
    *$ Valid for       :                                                  $*
    *$ Software Component   SAP_APPL   SAP Application                    $*
    *$  Release 40B          All Support Package Levels                   $*
    *$  Release 45B          All Support Package Levels                   $*
    *$  Release 46B          All Support Package Levels                   $*
    *$  Release 46C          All Support Package Levels                   $*
    *$  Release 470          All Support Package Levels                   $*
    *$  Release 500          All Support Package Levels                   $*
    *$  Release 600          All Support Package Levels                   $*
    *$  Release 602          All Support Package Levels                   $*
    *$  Release 603          All Support Package Levels                   $*
    *$  Release 604          All Support Package Levels                   $*
    *$  Release 605          All Support Package Levels                   $*
    *$  Release 606          All Support Package Levels                   $*
    *$--------------------------------------------------------------------$*
    *$ Changes/Objects Not Contained in Standard SAP System               $*
    *$*$----------------------------------------------------------------$*$*
    *& Object          REPS Z_AFRP4_DELETE
    *& Object Header   PROG Z_AFRP4_DELETE
    *& REPORT Z_AFRP4_DELETE
    REPORT  Z_AFRP4_DELETE .
    * This report deletes confirmation records from table AFRP4 that are
    * not longer needed. Run it without update flag first !!
       tables: afrp4.
       data: lt_afrp4 like afrp4 occurs 0,
             ls_afrp4 like afrp4.
       selection-screen begin of block order with frame.
       select-options: zorders for afrp4-aufnr.   "order number
       selection-screen end   of block order.
       parameters: update as checkbox.
       select * from afrp4 into table lt_afrp4
                    where aufnr in zorders.
       if lt_afrp4[] is initial.
         format color col_normal.
         write: 'No HR confirmation background records read.'.
         exit.
       endif.
       format color col_heading.
       write: /5 'Order', 25 'Confirmation', 45 'Counter'.
       skip.  uline.  skip.
    * show corrections
       loop at lt_afrp4 into ls_afrp4.
         format color col_normal.
         write: /5 ls_afrp4-aufnr, 25 ls_afrp4-rueck, 45 ls_afrp4-rmzhl.
       endloop.
    * update on data base table
       if not update is initial.
         skip.  uline.  skip.
         delete afrp4 from table lt_afrp4.
         if sy-subrc is initial.
           format color col_positive.
           write: 'HR-records deleted successfull'.
         else.
           format color col_negative.
           write: 'Error when trying to update data base table AFRP4.'.
         endif.
       endif.

  • How to retrive the records with in the range

    hi,
    I want to read the records from the table with in the date range.
    for example select empID,empName from EmpTable where stardat to lastdate
    please somebody help me...
    thanx in advance
    cinux

    hi,
    I want to read the records from the table with in the
    date range.
    for example select empID,empName from EmpTable where
    stardat to lastdate
    please somebody help me...
    thanx in advance
    cinuxhi ,
    Oracle provides BETWEEN ..AND.... operator for such requirement.
    SQL> select empno,ename,hiredate from emp where hiredate between to_date('03-dec-80','DD-MON-RR') and sysdate;
    EMPNO ENAME HIREDATE
    7369 SMITH 17-DEC-80
    7499 ALLEN 20-FEB-81
    7521 WARD 22-FEB-81
    7566 JONES 02-APR-81
    7654 MARTIN 28-SEP-81
    7698 BLAKE 01-MAY-81
    7782 CLARK 09-JUN-81
    7788 SCOTT 19-APR-87
    7839 KING 17-NOV-81
    7844 TURNER 08-SEP-81
    7876 ADAMS 23-MAY-87
    EMPNO ENAME HIREDATE
    7900 JAMES 03-DEC-81
    7902 FORD 03-DEC-81
    7934 MILLER 22-FEB-81
    124 johndoe 28-DEC-05
    15 rows selected.
    Hope this may help you.
    Trinath Somanchi,
    Hyderabad.

  • Finding the record with the latest date

    Post Author: sconlon
    CA Forum: General
    Hi,I am using CR 8 with an Access database which has a table that holds (multiple) sales records for each of our clients. I want to create a report that lists only the latest sale from each client.  I am thinking that I first need to group by client and then create a sub-report that prints the necessary details of sales record with the latest date of sale.  It's this last bit that I cannot figure out how to do.  Can anyone suggest a way of doing this?Many thanks,sconlon

    Post Author: Jagan
    CA Forum: General
    Charliy's suggestion if fine, and does require sorting and displaying in the group header/footer according to the sort order. In case it's not clear, when you print in the group header you are using the first record's data; when you print in the group footer you are using the last record's data (first and last within the group that is).
    Personally, I'd group on the client have a group selection formula of:
    {table.date_field} = maximum({table.date_field}, {table.client_id})
    so that there's no date sort required as you'll only get one record per client group - assuming that each record has a unique date of course. I'd probably still suppress the details section and display in the group footer, but it wouldn't matter if you use the details section either.
    I believe the benefit with the group selection formula is that any summary formulas, running totals etc. you use would only have the one record per client to work on, rather than including all of the suppressed records too.

  • Is there any function module about same record with a time phase?

    Dear Expert,
    I am developing a program to upload time data into SAP and I was asked to delete the records which coming within 5 mintues and upload the last one into SAP.
    Is there any function module about this?
    BR Wang Yichao

    HI ajay,
    1. If i am not wrong, this infotype hrp1005,
       is maintained using PP01.
    2. One method is
       using FM RH_RELATION_MAINTAIN.
    regards,
    amit m.

  • Had to reinstall iTunes after bad virus and now when I drag and drop song into custom playlist it won't added.  No green   appears, instead just the circle with slash.  What's going on?  a fix? Michael

    I had to reformat after a bad virus and reinstall iTunes.  Now when I try to drag and drop a song into a custom playlist, it won't add the song.  Instead of the green + that is supposed to appear, it just shows the circle with cross slash.  I created numerous playlist before and never ran into this problem.  Any suggestions on how to fix it?  Thanks 1ngiri

    OK, so I have now found that this is apparently normal for iTunes, to only accept mpeg 4 movie files, all the searching I did before I must have worded it wrong because I couldn't find anything about this, incredibly. Had been looking for why iTunes won't take all the files it previously did, like if it had been changed, and it hasn't, it's allegedly always taken only mpeg 4 files. Also I had been searching for why iTunes crashes every time I try and add/import anything but mpeg 4 files, and even sometimes with mpeg 4 files. That isn't normal, it's supposed to just do nothing apparently as I've just found out. So for these reasons I didn't find the answer despite my searching all over the web.
    So I guess that answers my own question now, but I'm still perplexed as to why I absolutely, definitely, without any doubt, had several hundred movies of a few different video file types loaded, accessible and playable in my iTunes library that everything here claims iTunes never accepted. It apparently shouldn't have been possible for me to have done this, but for probably 10 years it's been this way.
    Perhaps since I don't remember adding these files to iTunes anymore recently than maybe 6 or 7 years ago, the iTunes back then did accept all kinds of file types? Or could I have somehow had some video codecs or software that expanded the capability of my movie players like Quicktime Player that unwittingly also allowed iTunes to take those files as well? All I know is somehow it worked! So now my question is how did I have it working before, so that maybe I can make it work again.

  • Copy function based on the query with variables

    Hello
    Let me share the scenario I need to implement. I have a planning query with layout like shop / material / sales volume. The variables are shop number and calendar month. User opens the planning query, selects shop number and month, then sees the list of materials and puts the planned sales volume, then saves as a temporary version. Saving as a temporary version is realized by standard u201Csaveu201D function. The matter is that the user needs to have a possibility to copy this version to official one. I created the button and linked it with the copy function. The problem is that when a user clicks this button, the function asks him/her to provide variables again. I would like to have the button which copies the data with the same selection criteria as the query already has.
    Any idea?
    Arelis.

    Hi,
    I think when you add the button you specify the planning sequence name and that takes the filter of the modeler .Now when you try to call the planning sequence the filter variables are also added to the button as VAR_NAME, VAR_VALUE which prompts you for the variable again.Delete VAR_NAME,VAR_VALUE at the back of the button  manually and then save your work book.Then it will not ask for variable entry and the values that you have specified in the query filter will pass on to modeler filters.As variables are global.
    Similarly if you are using planning function then at the back of the button remove the VAR_NAME,VAR_VALUE.
    Hope this may help.
    Regards,
    Indu

  • Extract only the records exist in Table A but not in Table B

    Hi guru, I need to compare two big SAP tables and only select the records that exist in Table A but not in Table B, i.e. Exclude the records that exist in both tables. Due to the volume, left outer join is not preferred. Does anybody know any smart and quick way to do so?
    Thanks,

    Sounds like you're looking for alternatives from performance perspective, so maybe your question would be better posed in .
    As always for any performance related questions the answer is: It depends...
    I.e. you need to provide some further background: How many entries in table A, how many in table B? How are they linked (e.g. index, primary key, what fields)? On average, how many entries do you expect in your result set?
    Depending on those parameters (and possibly others) one can then evaluate other options: There's probably not many, I'd try also using [subqueries|http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_SUBQUERY.htm]. Since performance tuning always requires an analysis, it's best to try out the different variations and check what happens (e.g. how long do they run, what kind of load do they introduce on the database, etc.). Subquery versus outer join performance depends also on the used database.
    Cheers, harald

  • First time recording with digital drum kit in GB. Just got weak sound

    Hi first timer here. Just bought a usb midi interface from Roland (umg-1g). It has midi in and midi out. My drum kit is Roland td3. My problem is that i get a weird sound that doesnt sound like my drums sounds like for me when playing. It sounds weak and empty with no real punch to it. Do any one have any idea of what I should do.
    thnx !

    Sebastianp wrote:
    ut looks like GB has only one rock kit?
    correct
    Is there expansion kit for drums one have to buy ?
    the rhythm section pack has several more kits:
    http://www.bulletsandbones.com/GB/PluginsApplesJamPacks.html

Maybe you are looking for

  • Can you set up multiple Facebook users on 1 IPad 4?

    Can you set up multiple Facebook users(2) on one IPad 4?

  • How do I remove an old file from the Finder Favorites list?

    Good Afternoon. I have a shiney new MBPro with 10.7.1. On my old machine running Snow Leopard, I had two .xls files I used often that I had dragged to the left side into the favorites. The truth is, I hadn't used them in months, but hadn't bothered t

  • Can't enable wifi

    Satellite l855 I can't turn my wifi on

  • Predefined smart albums deleted

    I discovered that my predefined smart album "rejected" is gone. How can I get it back ? If I create a new smart album that contains my rejected images, how can I insert that smart album into the same position where the previous predefined smart album

  • Separate color output and blank pages

    Good morning community, I have a little question for you today. How can I output a separate color PDF with blank pages included? Unfortunately, as I choose separation in the output menu, the chance to include blank pages (usually available in the gen