Order data as in IN clause

Hi,
Is there a way to order the result set to display in the same order as data supplied in IN clause
example:
select * from t_cu where cno IN (
220,
120,
900,
350,
99,
1,
34
);I would like to display the data in the same order as
220,
120,
900,
350,
99,
1,
34I know this can be done using UNION ALL, however if 50+ records are there in the IN clause, then it is quite a task.
Thanks

Example of one possible method..
SQL> ed
Wrote file afiedt.buf
  1  with req as (select '7844,7698,7782,7499' as en from dual)
  2      ,ord as (select REGEXP_SUBSTR (en, '[^,]+', 1, level) en, rownum rn
  3               from req
  4               connect by level <= length(regexp_replace(en,'[^,]*'))+1)
  5  --
  6  select emp.*
  7  from emp join ord on (emp.empno = ord.en)
  8* order by ord.rn
SQL> /
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
      7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
      7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
SQL>This takes a comma seperated string that specifies the required values in order, breaks that string up into individual values giving them an associated order number (rn) and then uses those values to restrict the main query and the order values to order the results.

Similar Messages

  • How to get CRM service order data in R/3

    Hi,
    I want to retrieve service order data from CRM system to R/3, is there any FM for this. Please help as i am new to CRM
    Thanks
    Bobby

    Hi Bobby,
    It is very much possible to upload CRM service orders to SAP R/3 or SAP ECC via standard CRM middleware.
    Please refer to the below SAP help document for complete list of configuration activities for service order upload.
    http://help.sap.com/saphelp_crm50/helpdata/en/f0/5d583c65399965e10000000a114084/frameset.htm
    <b>Do not forget to reward if it helps</b>
    Regards,
    Paul Kondaveeti

  • Need info on Standard Web services to pull Order data in CRM from external applications

    Hi Gurus,
    I have a requirement to pull Order data in CRM from external non-sap application using Web services. Are there any standard SAP provided web services to pull order data based on some input? If yes, can you provide me any kind of documentation related to this?
    Appreciate your help on this.
    Thanks
    Lakshman

    Hi Lakshman,
    I have checked further.
    Please review below link of the SAP Help documentation :
    http://help.sap.com/saphelp_nw70/helpdata/en/47/3a989cbcef2f35e10000000a1553f6/content.htm?frameset=/en/46/97218e79f115eae10000000a114a6b/frameset.htm&current_toc=/en/d1/802cfc454211d189710000e8322d00/plain.htm&node_id=439&show_children=false
    and also the link :
    –http://esworkplace.sap.com/socoview(bD1lbiZjPTAwMSZkPW1pbg==)/render.asp?packageid=DE0426DD9B0249F19515001A64D3F462&id=347DD31EB5AB4BC592BD8B29C0981A1B
    Hoping that this will be helpful.
    Best regards - Christophe

  • Doubt in uploading purchase order data using BDC

    Hi friends,
    how to upload purchase order data.
    1) In both BDC and BAPI which one is preferable?
    2) for suppose if it is through BDC,  how to use? what are the transactions that we can use(SHDB, ME21N,ME21)?
    3) To execute the job in background, is it possible for both call transaction and session method.
    Thanks in advance
    Sreenivas k

    It really depends on the number of records you have. Still for a set of 5,000 records my answer to your questions will be:
    1) In both BDC and BAPI which one is preferable?  - <b>Go with BDC</b>
    2) for suppose if it is through BDC, how to use? what are the transactions that we can use(SHDB, ME21N,ME21)? - <b>Yes, its SHDB for recording, SE38 for abap program and ME21 for PO. Avoid SAP Enjoy transactions for recording as you may end up having problems wiht it.</b>
    3) To execute the job in background, is it possible for both call transaction and session method. - <b>If you use call transaction method then you have to schedule the job to run in background or simply run it through F9 instead of F8. In case of session method you can chose to process the session in background. However  I would suggest you go with BDC Session method for this.</b>
    - Guru
    Reward points for helpful answers

  • Open Sales order data

    Hi,
       Can any one please help on identifying the table used for retrieving Open sales order data for a particular period, My requirement is to take the Volume of open sales order for Data migration volume assessment
      Please help on this
    Thanks
    Rajesh.R

    hello, friend.
    a standard transaction is VA05 or VA05n to check on open orders. 
    if you need to check the database tables, you can check sales order status/header thru table VBUK.  for item level, use VBUP.  you will find fields such as reference status, delivery status, etc.
    regards.
    jy

  • Report for displaying the order number & order date..

    HI ALL,
    can any body help me for displaying the order number,customer name,material name & order date..in report
    i dnt know the which are the table i need to use...
    can anybody tell me which are table do i need to use and fields in tables
    input to report from the user are cutomer number,purchase order numbervendor number & sales number
    waiting for positive reply form u people.....
    thanks
    Zabeerulla
    Moderator message: "spec dumping", please work yourself first on your requirement, do some research, talk to a functional consultant near you.
    Edited by: Thomas Zloch on Feb 28, 2011 2:14 PM

    Thx  dharma raj  ...
    problem is ,input to report from the user are cutomer number,purchase order number,vendor number & sales number
    report should contain
    customer name
    order date
    order #
    vendor name
    material name
    can u please tell me which are the table do i need to use...
    i have ,please look into it...let me know if am incorrect
    customer name -> kna1_name where kna1_kunnr=knagv_kunnr
    order date -> vbak_audat
    order nunber->vbak_vbeln
    vendor name -> LFA1_NAME where LFA1_LIFNR=MEPO_TOPLINE(superfileld)
    material # -> VBAP_ARKTX where VBAP_VBELN=VBAK_VBELN
    HELP ME OUT...
    THX
    ZABEER

  • Performance with dates in the where clause

    Performance with dates in the where clause
    CREATE TABLE TEST_DATA
    FNUMBER NUMBER,
    FSTRING VARCHAR2(4000 BYTE),
    FDATE DATE
    create index t_indx on test_data(fdata);
    query 1: select count(*) from TEST_DATA where trunc(fdate) = trunc(sysdate);
    query 2: select count(*) from TEST_DATA where fdate between trunc(sysdate) and trunc(SYSDATE) + .99999;
    query 3: select count(*) from TEST_DATA where fdate between to_date('21-APR-10', 'dd-MON-yy') and to_date('21-APR-10 23:59:59', 'DD-MON-YY hh24:mi:ss');
    My questions:
    1) Why isn't the index t_indx used in Execution plan 1?
    2) From the execution plan, I see that query 2 & 3 is better than query 1. I do not see any difference between execution plan 2 & 3. Which one is better?
    3) I read somewhere - "Always check the Access Predicates and Filter Predicates of Explain Plan carefully to determine which columns are contributing to a Range Scan and which columns are merely filtering the returned rows. Be sceptical if the same clause is shown in both."
    Is that true for Execution plan 2 & 3?
    3) Could some one explain what the filter & access predicate mean here?
    Thanks in advance.
    Execution Plan 1:
    SQL> select count(*) from TEST_DATA where trunc(fdate) = trunc(sysdate);
    COUNT(*)
    283
    Execution Plan
    Plan hash value: 1486387033
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 9 | 517 (20)| 00:00:07 |
    | 1 | SORT AGGREGATE | | 1 | 9 | | |
    |* 2 | TABLE ACCESS FULL| TEST_DATA | 341 | 3069 | 517 (20)| 00:00:07 |
    Predicate Information (identified by operation id):
    2 - filter(TRUNC(INTERNAL_FUNCTION("FDATE"))=TRUNC(SYSDATE@!))
    Note
    - dynamic sampling used for this statement
    Statistics
    4 recursive calls
    0 db block gets
    1610 consistent gets
    0 physical reads
    0 redo size
    412 bytes sent via SQL*Net to client
    380 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed
    Execution Plan 2:
    SQL> select count(*) from TEST_DATA where fdate between trunc(sysdate) and trunc(SYSDATE) + .99999;
    COUNT(*)
    283
    Execution Plan
    Plan hash value: 1687886199
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 9 | 3 (0)| 00:00:01 |
    | 1 | SORT AGGREGATE | | 1 | 9 | | |
    |* 2 | FILTER | | | | | |
    |* 3 | INDEX RANGE SCAN| T_INDX | 283 | 2547 | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter(TRUNC(SYSDATE@!)<=TRUNC(SYSDATE@!)+.9999884259259259259259
    259259259259259259)
    3 - access("FDATE">=TRUNC(SYSDATE@!) AND
    "FDATE"<=TRUNC(SYSDATE@!)+.999988425925925925925925925925925925925
    9)
    Note
    - dynamic sampling used for this statement
    Statistics
    7 recursive calls
    0 db block gets
    76 consistent gets
    0 physical reads
    0 redo size
    412 bytes sent via SQL*Net to client
    380 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows
    Execution Plan 3:
    SQL> select count(*) from TEST_DATA where fdate between to_date('21-APR-10', 'dd-MON-yy') and to_dat
    e('21-APR-10 23:59:59', 'DD-MON-YY hh24:mi:ss');
    COUNT(*)
    283
    Execution Plan
    Plan hash value: 1687886199
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 9 | 3 (0)| 00:00:01 |
    | 1 | SORT AGGREGATE | | 1 | 9 | | |
    |* 2 | FILTER | | | | | |
    |* 3 | INDEX RANGE SCAN| T_INDX | 283 | 2547 | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter(TO_DATE('21-APR-10','dd-MON-yy')<=TO_DATE('21-APR-10
    23:59:59','DD-MON-YY hh24:mi:ss'))
    3 - access("FDATE">=TO_DATE('21-APR-10','dd-MON-yy') AND
    "FDATE"<=TO_DATE('21-APR-10 23:59:59','DD-MON-YY hh24:mi:ss'))
    Note
    - dynamic sampling used for this statement
    Statistics
    7 recursive calls
    0 db block gets
    76 consistent gets
    0 physical reads
    0 redo size
    412 bytes sent via SQL*Net to client
    380 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed

    Hi,
    user10541890 wrote:
    Performance with dates in the where clause
    CREATE TABLE TEST_DATA
    FNUMBER NUMBER,
    FSTRING VARCHAR2(4000 BYTE),
    FDATE DATE
    create index t_indx on test_data(fdata);Did you mean fdat<b>e</b> (ending in e)?
    Be careful; post the code you're actually running.
    query 1: select count(*) from TEST_DATA where trunc(fdate) = trunc(sysdate);
    query 2: select count(*) from TEST_DATA where fdate between trunc(sysdate) and trunc(SYSDATE) + .99999;
    query 3: select count(*) from TEST_DATA where fdate between to_date('21-APR-10', 'dd-MON-yy') and to_date('21-APR-10 23:59:59', 'DD-MON-YY hh24:mi:ss');
    My questions:
    1) Why isn't the index t_indx used in Execution plan 1?To use an index, the indexed column must stand alone as one of the operands. If you had a function-based index on TRUNC (fdate), then it might be used in Query 1, because the left operand of = is TRUNC (fdate).
    2) From the execution plan, I see that query 2 & 3 is better than query 1. I do not see any difference between execution plan 2 & 3. Which one is better?That depends on what you mean by "better".
    If "better" means faster, you've already shown that one is about as good as the other.
    Queries 2 and 3 are doing different things. Assuming the table stays the same, Query 2 may give different results every day, but the results of Query 3 will never change.
    For clarity, I prefer:
    WHERE     fdate >= TRUNC (SYSDATE)
    AND     fdate <  TRUNC (SYSDATE) + 1(or replace SYSDATE with a TO_DATE expression, depending on the requirements).
    3) I read somewhere - "Always check the Access Predicates and Filter Predicates of Explain Plan carefully to determine which columns are contributing to a Range Scan and which columns are merely filtering the returned rows. Be sceptical if the same clause is shown in both."
    Is that true for Execution plan 2 & 3?
    3) Could some one explain what the filter & access predicate mean here?Sorry, I can't.

  • How to trace planned order data after it has been converted into production

    Hi, There,
    The planned order has been converted into production order.
    However, I need to trace if this planned order is generated by MRP
    run or created manually. I can't get any planned order info from
    table PLAF. Any input?
    Regards,
    Nancy

    Hi,
    Once fully converted, the Planned Order data will not be available in the Table : PLAF.
    If it is available, then You can have the details with the Time Stamp and User data from PLAF.
    But, the refrence will be available in the Production Order.
    You want to make a Track of the Planned Order details and the Quanity, then you need to have/create Z tables so that the data will be availabe.
    This is how most of the Organizations keep a track of the Planned order data.
    Hope this helps..
    Regards,
    Siva

  • Sale order date determination

    hi friends,
    kindly explain,how the sale order date is determined.
    on what criteia it is determined?

    Hi Divya,
    Go to TCODE VOV8--in the functionality of sales document go to Requested Delivery date/Pricing Date/Purchase order date.
    in it there is a field called "Propose PO Date".if we chk this the system will take current date as the PO date.
    Rgds,
    Raj..

  • HOW to retrieve PURCHASE ORDER DATA from archieve file and print a report

    Dear all
    1) I have retrieve purchase order data from archived files.
    2)  print purchase order data and created pdf file.
    VIJ.............
    Moderator message - Please ask a specific question - post locked
    Edited by: Rob Burbank on Apr 28, 2009 12:00 PM

    Dear all
    1) I have retrieve purchase order data from archived files.
    2)  print purchase order data and created pdf file.
    VIJ.............
    Moderator message - Please ask a specific question - post locked
    Edited by: Rob Burbank on Apr 28, 2009 12:00 PM

  • Table for  the PO Date and Stock Transfer Order Date of a material no

    Hello Everyone!
    I am having a requirement where I want both the Purchase Order Date and Stock Transfer Order Date of a perticular material no.
    On the basis of difference of these two dates I want to find out the period for which the material was present in supplying plant.
    I am not getting the table through which I can get these two dates for a material.
    Please help me out.
    Its urgent.

    hi,
    see these tables:
         EKKO – Purchase Order Header Table
         EKPO – Purchase Order Item  Table
         EKBE – PO History table.
    reward if its useful

  • Is there a way to automatically add text to video; the text gleaned from order data?

    is there a way to automatically add text to video; the text gleaned from order data?

    What is "order data"?

  • Confirmed date in sales order influenced by planned order dates

    Hi,
    My requirement is that the after the MRP is carried out and planned order is generated, the changes in the dates of the planned order, when carried out, shall accordingly influence the confirmed date of the sales order line item when the availability check is carried out in the sales order.
    Say, the sales order has confirmed a line item for 25.05.2009. Once the MRP is carried out and planned order is generated and owing to unavailablility of a component, the planned order date (finish date) is manually re-scheduled to say 28.05.2009. My requirement is that the sales order confirmed date shall accordingly be re-scheduled when the availability check is carried out.
    Additional Info : Strategy Group - 20,
                           Make-to Order scenario is employed,
                           Standard Item category TAN,
                           Requirement Class - 040.
    Is this possible in standard SAP? If not, please suggest any custom developments that may be required. Looking forward for helpful replies.
    Do revert back if more info required.
    Regards,
    Anil Kumar

    Hi Anil,
    As Suggested in Above reply to your question.
    If Materail component was not available and due to that you had to reshedule the planned order date manually, that definately will affect the material availability date, but i think if material availability will be run once again in Sales Order it will determine the new material availability date, and i dont think there is any need to carry out any enhancement.
    Guru's Please correct me if I am wrong.
    regards,
    Paresh

  • How to transfer Sales order data from R/3 to APO!!

    Hi Techies,
    I am in the process of moving some sales order data for a particular mat/loc combination in cfm1 after creating a integration model iam even activating even in R/3 but after doing this iam not able to view those sales orders in RRP3 t-code IN APO side.
    Kindly let me know what is the procedure to transfer transactional data from R/3 to APO and to do enhancement in CIF which carries Transactional data .
    Problem solving answers would be rewarded duly !!.
    +PKP.

    Hi PKP,
    The field SPEC_STOCK has the description "Key for Special Stock Section" and is linked to schedule line of the PO. This seems to be something linked to special stock, but I am not very sure about the relevance of this field.
    I do not see any related field when I check the order in RRP3 or in RRP2. In standard SAP, you would only be able to use the fields that are already visible in APO. Otherwise you need to add the field to the standard SAP t-code display (read the value from SOMEWHERE and then display it in RRP3. This is possible using Badi /SAPAPO/RRP_IO_COL). Then only you can see the values which you have populated.
    If this field SPEC_STOCK already has some functionality (which it should have, though I am not sure what it is), you might not be able to use it for other purposes (since system does some validations for certain fields).
    You are updating the value for this field in IT_OUTPUT internal table, you also need to add an X in the corresponding field in the internal table IT_OUTPUTX.
    You could try putting this X, so that your changes are considered in CIF, but I am not sure what the impact may be, and you could get a dump also possibly. Even otherwise, since this field doesn't seem to be visible against a PO in APO, I am not sure if this would be helpful for you.
    As far as I could see, I did not find any standard field which could be helpful for you.
    May be if you open a fresh thread and ask for advice on how to send any custom comments for PO to APO, someone could provide some inputs.
    Thanks - Pawan

  • Regarding Goods issue date and order date.

    Hi All,
    Could you please tell me from where we can fetch Goods issue date and Order date.
    Waiting for your reply.

    Preeti,
    Goods issue date/order date of what ?
    Goods can be issued in a number of ways, in reference to many types of documents.  In each case, the GI date and order date are found in different places.
    Please elaborate your request.
    Best Regards,
    DB49

Maybe you are looking for

  • SECess for Import Purchase

    Dear Gurus, I am using Taxinn procedure. Also At the time of import purchase I am calculating SECess 1 % with the help of Condition JESH . I have assigned this condition at AP AT2 cond. in taxinn and also in prising procedure for import as in import

  • System.Web.Services.Protocols.SoapException: CX_INVALID_TRANSFORMATION

    Hi all, i have a problem with a service. In the "old" systems WITHOUT Soamanager the service works fine. Now the service throws the following exception: System.Web.Services.Protocols.SoapException: CX_INVALID_TRANSFORMATION:An exception with the type

  • Keynote freezes when pasting text

    Keynote freezes every time I try to paste text into a text box, whether I use Command V, Edit>Paste, Edit>Paste-and-Match-Style. This happens whether I am copying normal text from Word or from an identical text box on the same slide. I've filed about

  • SD Order confirmation. PRinting sales order texts.

    Hi, I am Developing a smartform for sd order confirmation. I have a requirement to print the sales order header texts(header text and ship/fwd inst).I have included them as an include text but i also need to print the phrase 'header info' before head

  • No Sound using Quicktime

    I am using an iMac G5, 10.4.8, with Quicktime 7.1.3 and for some reason I cannot hear any quicktime movies played. The video portion works fine, just not the sound. I've gone into all of the sound system files and my microphone and speakers work fine