Urgent :  Query on select statement!!

Hi All,
i am trying to get the customer number from VBPA table into my work area based on vbeln and parvw values. but it is giving me an sysubrc value is 4.
here is my code :
  select single kunnr into wa_i_vbpa
                      from vbpa
                      where vbeln = p_i_vbeln
                      and   parvw = 'SP'.
Kindly check and let me know whether this is correct or not? if not, please correct it and send it to me back.
Thanks in advance.

Hi,
Please try this instead.
select single kunnr into wa_i_vbpa
from vbpa
where vbeln = p_i_vbeln
and parvw = 'AG'.
Regards,
Ferry Lianto

Similar Messages

  • Urgent: regarding sub select statement

    I making a report in which i have to display the STOCK and i want to do the sum in a select statement of the value coming from the field AFRU-GMNGA so that i can do calculation of the value of 1st field to be subtracted from the last value of the same field .
    can anybody provide me example of it as i am currently using dis select statement:-
    SELECT AMATNR ALGORT BGMNGA BVORNR C~MEINS FROM AFPO AS A
      INNER JOIN AFRU AS B ON AAUFNR = BAUFNR
        INNER JOIN MARA AS C ON AMATNR = CMATNR
          INTO TABLE ITAB
          WHERE MTART IN MAT_TYPE AND A~MATNR IN P_MATNR .
    plzz help me out as it is really urgent to me.

    Hi,
    Go thr the below select query.
    select tvkwzwerks a350kschl a350vkorg konpkbetr
           from tvkwz inner join a350 on tvkwzvkorg = a350vkorg inner join konp
           on a350knumh = konpknumh into table itab where  tvkwz~werks = '1003'
           and a350~kschl = 'ZCPA'.
    Regards,
    vijay

  • Query in SELECT statement!!!!

    Hi all,
              I have a SELECT statement as follows:
      SELECT aguid_hi bpartner_no
      FROM crmd_link AS a
      INNER JOIN crmd_partner AS b ON bguid EQ aguid_set
      INTO TABLE p_partners
      FOR ALL ENTRIES IN i_sub_contracts
      WHERE a~guid_hi     EQ i_sub_contracts-guid
        AND a~objtype_hi  EQ '05'
        AND b~partner_fct EQ p_partner_fct.
    Please tell me if I can create a view for the above.
    Once I create a view for the above will it really boost the performance.
    Kindly reply immediately as this is bit urgent.
    Regards,
    Vijay

    hi,
    As said above view is nothing but an inner join between tables which you are already doing it in your program ... So i don't think there will be any improvement in the performance of the program ...
    Regards,
    Santosh

  • Query on Select Statement

    Dear All,
            I have a small query on the Select Statement. If there are 2 identical rows and if i am retrieving them using the Select Statement, then will the select statement retrieves both the rows which are identical or only the first possible occurence? Pls help me out in this.
    Thanks,
    Sirisha.

    Hi,
         That depends on the statement u use. If u use, 'SELECT' statment, u can retrieve all the records which are identical with one or few fields. For that, u need to put the output INTO A TABLE.
    Ex. 1
    data : int_ekko type table of ekko with header line,
             fs_ekko type ekko.
    select * from ekko into table int_ekko where ebeln = '6361003191'.
    Here, int_ekko is an internal table contains all records whose EBELN = 63610003191.
    2)  If u use 'SELECT  SINGLE', then it will retrieve only the first record out of all the records who satisfy the condition EBELN = 6361003191.
    Ex 2:
    select single * from ekko into fs where ebeln = '63610003191'.
    'fs' is not a table, just of type structure. so contains only one record.
    Hope it help u..
    Kindly reward points if hepful
    Regards,
    Shanthi.
    Edited by: Shanthi on Mar 4, 2008 8:17 AM

  • Query for select statement

    Dear all
    is there any option in select statement to automatically generate serial number respect of data.
    for eg.
    1 101100110  shetal trade
    2 1110001178 CHEMICAL SOAP WORKS
    3..
    4..
    i don't  want to use loop (sy-tabix) ..
    thanks,
    Abhi

    Hi ,
    i don't want to use loop (sy-tabix) ..
    any particular reason for this ?
    as u cannot automatically generate serial number, u have to go for loop....endloop.
    Thanks
    Karthik

  • How to get all rows that are returned in inner sub query of select statemen

    If a sub query in select statement returns more than one row than how to get all those returned rows in the final
    output of the query .It will be all right if all column's value repeat and that multiple output of inner query comes
    in another column .
    How to get that ?

    As Frank said, you likely want a join, and likely an outer join to replicate the select in the projection. Something like:
    SELECT id,stat, section, USER_ID concerned_person
    FROM table_all,
      left join table2
        on room_id = sectoion and
           sur_role = 'r001'
    WHERE section IN (SELECT code
                      FROM t_area
                      WHERE dept= 'p002')An alternative, depending on where and how you are using the statement would be something like:
    SQL> WITH t AS (
      2    select 1 id from dual union all
      3    select 2 id from dual),
      4  t1 as (
      5    select 1 id, 'One' descr from dual union all
      6    select 1, 'Un' from dual union all
      7    select 1, 'Une' from dual)
      8  SELECT t.id, CURSOR(SELECT t1.id, t1.descr from t1
      9                      WHERE t1.id = t.id)
    10  FROM t;
                      ID CURSOR(SELECTT1.ID,T
                       1 CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
                      ID DESCR
                       1 One
                       1 Un
                       1 Une
                       2 CURSOR STATEMENT : 2
    CURSOR STATEMENT : 2
    no rows selectedJohn

  • Combine two select statements in one SQL statements

    I have the following two queries that I need to combine into one query, where it updates a single row at the same time.
    SELECT count(*) FROM database.USAGE WHERE SERVICE_TYPE = 'C' AND ACCOUNT = "4837"
    SELECT sum(minutes) FROM database.USAGE WHERE SERVICE_TYPE = 'DA' AND ACCOUNT = "4837"
    I want to insert the values of each select statement into two columns of the same row, as well as insert the account number from the select statement.
    After the query has been executed, the database row will look like this:
    ACCOUNT COUNT SUM
    4837 354 1039202
    I am looking for suggestions on how to:
    - either combine the two into one query
    - simply update each column with the value from each query by updating the row with the account value
    I am a SQL newbie - so I appreciate any assistance.
    Thanks,
    Tony

    Hi, Tony,
    When you're talking about changing the data in tables, "INSERT" means to add a new row, and you'll cause a lot of confusion if you use it to mean something else. So don't say
    "I want to insert the values of each select statement into two columns..."; use some other word, like:
    "I want to put the values of each select statement into two columns ..."
    If you happened to know that those two numbers were 354 and 1039202, you might say:
    UPDATE  table_x
    SET     a_count = 354
    ,       a_sum = 1039202
    WHERE   account = 4837;But you don't know the numbers; you want to have the query figure out what they are.
    In most places where you can use a literal (like 354 or 1039202), you can also use a scalar sub-query, a SELECT statement, enclosed in parentheses, that produces one column and (at most) one row.
    In your case, you can say:
    UPDATE  table_x
    SET     a_count = (SELECT count(*) FROM database.USAGE WHERE SERVICE_TYPE = 'C' AND ACCOUNT = 4837)
    ,       a_sum = (SELECT sum(minutes) FROM database.USAGE WHERE SERVICE_TYPE = 'DA' AND ACCOUNT = 4837
    WHERE   account = 4837;or, to make it more readable:
    UPDATE  table_x
    SET     a_count =
    ( SELECT count (*)
    FROM database.USAGE
    WHERE SERVICE_TYPE = 'C'
    AND ACCOUNT = 4837
    ,       a_sum =
    ( SELECT sum (minutes)
    FROM database.USAGE
    WHERE SERVICE_TYPE = 'DA'
    AND ACCOUNT = 4837
    WHERE   account = 4837;By the way, why are you using double-quotes around 4837? If it's a string, enclose it in single quotes. If it's a number (which I'm assuming in my code), don't enclose it in anything.
    WARNING: scalar sub-queries are somewhat like duct tape: they're extremely useful in certain places, and those places account for about 1% of their use. The other 99% of the time, there's a better way to do things, though the better way may require more expertise.

  • Urgent, SELECT statement results in error

    hi all, this is very urgent, could you guys have a look at my SELECT statement?
      SELECT vk~kunnr         "customer no
              vk~vbeln         "sales order no
              vk~audat         "date
              vk~vbtyp         "SD DOCUMENT CATEGORY
              vk~knumv         "lwk
              vp~kwmeng        "qty
              vp~matnr         "material no
              vp~posnr         "LINE ITEM
              vd~bstkd         "PURCHASE ORDER NO
    *          kv~kwert         "lwk
              FROM  vbak AS vk
              INNER JOIN vbap AS vp
              ON vk~vbeln = vp~vbeln
              INNER JOIN vbkd AS vd
              ON vk~vbeln = vd~vbeln
    *          INNER JOIN konv AS kv
    *          ON kv~knumv = vk~knumv
              INTO CORRESPONDING FIELDS OF TABLE it_so
              WHERE vk~vkorg IN s_vkorg
              AND vk~audat IN s_date
              AND vk~kunnr IN s_kunnr
              AND vp~matnr IN s_matnr
              AND vd~bstkd IN s_bstkd
              AND vk~vbeln IN s_vbeln
    *          AND kv~kschl = 'ZP00'
              AND vk~vbtyp = 'C'.
    The commented lines are the new additions that i want to add to the SELECT statement. But when i un-comment them, i get an error while activating my program. Error is as follows:
    For pooled tables, cluster tables, and project views, JOIN is not allowed: "KONV".
    Is there a way i can go around it?

    Hi,
    look at this SAP note : 550043
    Symptom
    KEPM: dump 'MESSAGE_TYPE_X' during automatic planning method execution.
    Other terms
    KEPM MESSAGE_TYPE_X transform characteristic value
    Reason and Prerequisites
    This note is related only to cases, if dump 'MESSAGE_TYPE_X' is raising
    during execution of planning method, for which is possible to define
    transformation of characteristics values i.e. Copy, Forecast, Top-Down
    distribution, Ratios and Customer Enhancement.
    Dump is raising in case, if there was defined transformation of char.
    values in parameter set definition for some characteristic. Later on,
    this characteristic was removed from planning level definition but
    characteristic wasn't removed from relevant customizing of transform
    characteristic values before.
    Solution
    Please apply attached program correction.
    Regards,
    GSR.

  • Using plsql tables in select statement of report query

    Hi
    Anyone have experience to use plsql table to select statement to create a report. In otherwords, How to run report using flat file (xx.txt) information like 10 records in flat files and use this 10 records to the report and run pdf files.
    thanks in advance
    suresh

    hi,
    u can use the utl_file package to do that using a ref cursor query in the data model and u can have this code to read data from a flat file
    declare
    ur_file utl_file.file_type;
    my_result varchar2(250);
    begin
    ur_file := UTL_FILE.FOPEN ('&directory', '&filename', 'r') ;
    utl_file.get_line(ur_file, my_result);
    dbms_output.put_line(my_result);
    utl_file.fclose(ur_file);
    end;
    make sure u have an entry in ur init.ora saying that your
    utl_file_dir = '\your directory where ur files reside'
    cheers!
    [email protected]

  • Slow query results for simple select statement on Exadata

    I have a table with 30+ million rows in it which I'm trying to develop a cube around. When the cube processes (sql analysis), it queries back 10k rows every 6 seconds or so. I ran the same query SQL Analysis runs to grab the data in toad and exported results, and the timing is the same, 10k every 6 seconds or so. r
    I ran an execution plan it returns just this:
    Plan
    SELECT STATEMENT  ALL_ROWSCost: 136,019  Bytes: 4,954,594,096  Cardinality: 33,935,576       
         1 TABLE ACCESS STORAGE FULL TABLE DMSN.DS3R_FH_1XRTT_FA_LVL_KPI Cost: 136,019  Bytes: 4,954,594,096  Cardinality: 33,935,576  I'm not sure if there is a setting in oracle (new to the oracle environment) which can limit performance by connection or user, but if there is, what should I look for and how can I check it.
    The Oracle version I'm using is 11.2.0.3.0 and the server is quite large as well (exadata platform). I'm curious because I've seen SQL Server return 100k rows ever 10 seconds before, I would assume an exadata system should return rows a lot quicker. How can I check where the bottle neck is?
    Edited by: k1ng87 on Apr 24, 2013 7:58 AM

    k1ng87 wrote:
    I've notice the same querying speed using Toad (export to CSV)That's not really a good way to test performance. Doing that through Toad, you are getting the database to read the data from it's disks (you don't have a choice in that) shifting bulk amounts of data over your network (that could be a considerable bottleneck) and then letting Toad format the data into CSV format (process the data adding a little bottleneck) and then write the data to another hard disk (more disk I/O = more bottleneck).
    I don't know exedata but I imagine it doesn't quite incorporate all those bottlenecks.
    and during cube processing via SQL Analysis. How can I check to see if its my network speed thats effecting it?Speak to your technical/networking team, who should be able to trace network activity/packets and see what's happening in that respect.
    Is that even possible as our system resides off site, so the traffic is going through multiple networks.Ouch... yes, that could certainly be responsible.
    I don't think its the network though because when I run both at the same time, they both are still querying at about 10k rows every 6 seconds.I don't think your performance measuring is accurate. What happens if you actually do the cube in exedata rather than using Toad or SQL Analysis (which I assume is on your client machine?)

  • How to edit the records value fetched by select statement query in sqldever

    How to edit the records value fetched by select statement query in sqldever 2.1.1.
    EX-
    SELECT * FROM emp WHERE ename like 'Jaga%'
    Edited by: user9372056 on Aug 31, 2010 2:16 AM

    Hi,
    Although some forum members may be using that tool, there is still a dedicated forum for SQL Developer.
    SQL Developer
    Maybe your chances are better there.
    Regards
    Peter

  • Select query and Insert statement performance

    Hi all,
    Can anyone plz guide us on below problem I am facing ?
    1) One of the simple Insert statement runs very slow..What might be the reason? Its simple table without any LOBs ,LONG or so. Everything else in the DB works fine.
    2) one of the SELECT statement runs very slow. It selects all records (around 1000) from a table..How can i improve its performance?
    3)Which columns in the Master and its detail tables should be indexed to improve Query performance on them.
    Many Thanks
    Regards
    sandeep

    To get an answer to your questions you have to post some informations about your system:
    1. operating system
    2. RAM
    3. oracle version
    4. init.ora
    Thomas

  • Select Statement to query smallest ID

    <My_Table>
    ID
    PHOENIX005
    PHOENIX006
    PHOENIX007
    PHOENIX008
    TUCSON001
    TUCSON002
    TUCSON003
    TEMPE010
    TEMPE011
    TEMPE002
    CHANDLER030
    CHANDLER031
    CHANDLER032
    Whats the best way to write a select statement that would only bring back the IDs with the smallest numerical value? I ultimately want my Query to display:
    ID
    PHOENIX005
    TUCSON001
    TEMPE010
    CHANDLER030

    Or may be like this...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (
      2             select 'PHOENIX005' id from dual union all
      3             select 'PHOENIX006' from dual union all
      4             select 'PHOENIX007' from dual union all
      5             select 'PHOENIX008' from dual union all
      6             select 'TUCSON001' from dual union all
      7             select 'TUCSON002' from dual union all
      8             select 'TUCSON003' from dual union all
      9             select 'TEMPE010' from dual union all
    10             select 'TEMPE011' from dual union all
    11             select 'TEMPE002' from dual union all
    12             select 'CHANDLER030' from dual union all
    13             select 'CHANDLER031' from dual union all
    14             select 'CHANDLER032' from dual
    15            )
    16  select *
    17  from
    18  (
    19     select id, row_number()over(partition by trim(translate(id,'0123456789', rpad(' ',10))) order by
    20     to_number(trim(translate(id,'ABCDEFGHIJKLMNOPQRSTUVWXYZ', rpad(' ',26)))) ) as rno
    21     from t
    22* ) where rno=1
    SQL> /
    ID                 RNO
    CHANDLER030          1
    PHOENIX005           1
    TEMPE002             1
    TUCSON001            1
    SQL>

  • Select statement issue--urgent

    Hi All,
    i need information regarding below select statement.
    SELECT ebelp
               ebeln
               vgabe
               SUM( menge ) AS menge
               shkzg
          FROM ekbe
          INTO TABLE t_ekbe
         WHERE ebeln EQ t_documents-ebeln
           AND ebelp EQ t_documents-ebelp
           AND ( vgabe EQ c_1
            OR   vgabe EQ c_2 )
         GROUP by ebelp ebeln vgabe shkzg.
    I am working 4.5b version now.All the data declartion is correct.This select statement goes to Dump .when ever data is selected before the select statment.
    let me any other choices to do same.its urgent.
    Thanks,
    Arnald

    Hi...Arnald..
    Try this way... Runtime error may be bcoz of the Order of fields....
    types : begin of st_ekbe,
                 EBELN TYPE EKBE-EBELN,
                 EBELPTYPE EKBE-EBELP,
                 VGABE TYPE EKBE-VGABE,
                 SHKZG TYPE EKBE-SHKZG,
                 MENGE TYPE EKBE-MENGE,
               end of st_ekbe.
    DATA: T_EKBE TYPE TABLE OF ST_EKBE.
    SELECT
    ebeln
    ebelp
    vgabe
    shkzg
    SUM( menge )
    FROM ekbe
    INTO TABLE t_ekbe
    WHERE ebeln EQ t_documents-ebeln
    AND ebelp EQ t_documents-ebelp
    AND ( vgabe EQ c_1
    OR vgabe EQ c_2 )
    GROUP by  ebeln  ebelp vgabe shkzg.
    <b>Reward if Helpful</b>

  • Need help with select statement or query

    Not familiar with what to call it, but here is what i need...
    To give our analyst a better idea of warranty on some of our
    equipment, i
    would like to add to the page a column that displays if the
    device is still
    under warranty
    I currently capture the date the equipment was returned from
    repair, so what
    could i use within my select statement or query to display a
    warranty
    expiration date or display on the page...
    example :
    Returned from repair 10/20/2006 warranty expires on
    11/20/2006
    each equipment has different warranties, so i need a formula
    or something to
    say... device #1 has 60 day warranty ( so 10/20/2006 + 60days
    =
    12/19/2006 )
    I would imagine this to be a query
    Table 1 would contain the equipment type and warranty time
    Table 2 would contain the current status of the equipment
    Query would take the back from repair date + warranty =
    expiration date

    Simple. Join the two tables and create a derived column for
    the expiration date. The exact syntax is dependant on your DBMS, so
    check the manual for whichever you are using and look at the date
    functions. There will be a function that will allow you to add a
    number of date units (day, month, year, etc) to a date
    field.

Maybe you are looking for