Regarding Select without Where clause

Hi
we have below code for F4HELP on invoice input field.
you can see Select statement used without Where condition to fetch records from Ztable.
and deleting the duplicating records.
SCI error says,"Large table : it has no where condition. /No field of a table index in WHERE condition.
Is this potential problem?
How to handle this generally? does where condtion is must to use in Select statement.?
AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_ZIVCNO-LOW.
* Search help setting of uFF62Invoice numberuFF63
  PERFORM F_F4HELP_RSTYP CHANGING S_ZIVCNO-LOW.
FORM F_F4HELP_RSTYP  CHANGING C_V_INVCNO TYPE ZGTSDE_ZIVCNO."Invoice number
  DATA:
*   Work area for Return the selected value
    WL_F4RETURN  TYPE DDSHRETVAL,
*   Internal table for Return the selected value
    TL_F4RETURN  TYPE STANDARD TABLE OF DDSHRETVAL,
*   Internal table for Processing result
    TL_INVOICE   TYPE TABLE OF TYP_INVOICE.
  SELECT ZIVCNO
  FROM   ZGTSDT01
  INTO   TABLE TL_INVOICE.
  CHECK TL_INVOICE[] IS NOT INITIAL.
  DELETE ADJACENT DUPLICATES FROM TL_INVOICE.
*  Search help is started
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      RETFIELD        = CG_FIELD_INVCNO   " Packing No
      VALUE_ORG       = CG_VALUE_S       " Value return
    TABLES
      VALUE_TAB       = TL_INVOICE       " Table of values
      RETURN_TAB      = TL_F4RETURN      " Return the selected value
    EXCEPTIONS
      PARAMETER_ERROR = 1
      NO_VALUES_FOUND = 2
      OTHERS          = 3.

Since your F4 help on your selection-screen is independent, create a custom search help as suggested by Keshav.
As a suggestion Instead of,
SELECT ZIVCNO
  FROM   ZGTSDT01
  INTO   TABLE TL_INVOICE.
  CHECK TL_INVOICE[] IS NOT INITIAL.
  DELETE ADJACENT DUPLICATES FROM TL_INVOICE.
use,
SELECT DISTINCT(ZIVCNO)
  FROM   ZGTSDT01
  INTO   TABLE TL_INVOICE.
BR,
Suhas

Similar Messages

  • What happens u0093Updateu0094 command is used without where clause ?

    Hi
    What happens “Update” command is used without where clause ? 
    thank you

    Hi subash,
    chk this help
    UPDATE  dbtab      SET f1 ... fn. or
    UPDATE (dbtabname) SET f1 ... fn.
    Extras:
    1. ... WHERE condition
    2. ... CLIENT SPECIFIED
    3. ... CONNECTION con
    Effect
    Updates values in a database table. <b>If there is no WHERE clause, all lines (in the current client) are updated.</b> If a WHERE condition is specified, only thoserecords which satisfy the WHERE condition are updated.

  • Group by with and without where clause

    Do I need to use these two inner views to show results by group by as one line? Can I achieve the same result without typing the same select statement two times since these two SELECT statements differ only in where clause. This query is a simulation. My actual query is longer. My expectation is to make this query shorter (without inner views).
    with tmp as (
    select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual UNION ALL
    select 'COMPLETE' status, 'GERMANY' country, 1 substatus FROM dual UNION ALL
    select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual)
    select v1.status, v1.country, v1.cnt01, v2.cntIncluding0 from
    (select status, country, count(*) cnt01 from tmp tmp1 group by status, country) v1
    JOIN
    (select status, country, count(*) cntIncluding0 from tmp tmp2 where substatus=0 group by status, country) v2
    on v1.status=v2.status and v1.country=v2.country;

    totalnewby wrote:
    Do I need to use these two inner views to show results by group by as one line? Can I achieve the same result without typing the same select statement two times since these two SELECT statements differ only in where clause. This query is a simulation. My actual query is longer. My expectation is to make this query shorter (without inner views).
    with tmp as (
    select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual UNION ALL
    select 'COMPLETE' status, 'GERMANY' country, 1 substatus FROM dual UNION ALL
    select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual)
    select v1.status, v1.country, v1.cnt01, v2.cntIncluding0 from
    (select status, country, count(*) cnt01 from tmp tmp1 group by status, country) v1
    JOIN
    (select status, country, count(*) cntIncluding0 from tmp tmp2 where substatus=0 group by status, country) v2
    on v1.status=v2.status and v1.country=v2.country;
    SQL> with tmp as
      2  (
      3  select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual UNION ALL
      4  select 'COMPLETE' status, 'GERMANY' country, 1 substatus FROM dual UNION ALL
      5  select 'COMPLETE' status, 'GERMANY' country, 0 substatus FROM dual
      6  )
      7  select status,
      8         country,
      9         count(substatus) cnt01,
    10         sum(decode(substatus, 0, 1, 0)) cntincluding0
    11    from tmp
    12   group by status, country
    13  ;
    STATUS   COUNTRY      CNT01 CNTINCLUDING0
    COMPLETE GERMANY          3             2

  • PL/SQL: how to use in parameter in select sql where clause

    Hi
    in a procedure, I need to apply 'in parameter' in 'where clause' along with other table fields. Purpose is to create dynamic select querry with multiple conditions.
    select count(*) from table xx
    where y_code=2008 and v_type in ('SI', 'TI', 'DI') ;
    my requirement is replace 'and v_type in ('SI', 'TI', 'DI')' with in parameter. pls note in paramter may contain null value.
    Regards

    ... e.g. why on earth do you want to pass in a string to be appended to the WHERE clause of an SQL.I second that and I strongly advice NOT to do it. If you really want to do it, then come back and show us, how you would prevent SQL injection. This approach is too dangerous (and too complex) IMHO.
    Do it straight forward as in the article of Tom Kyte (link in the post of BluShadow above)

  • Select Statement -- Where Clause Execution Order

    What is the order of execution of the "AND" and "OR" in the WHERE clause of a Select statement?
    Are the "AND"'s executed from the top down, left to right? Is it the same for the "OR"'s execution?
    Thanks for any help...

    Not clear why you care. There is an order in which the optimizer parses the SQL (which may change from ver to ver), but this is a fairly quick operation. The order in which tables are visited and predicates evaluated is dependent on what the op[timizer does with the SQL.
    Ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Select avoiding where clause

    Hello,
    I am using JPA in my app and I am confused because of a select that is returning data as I didn't have anything in my where clause.
    Select A (with problems):
    Query q = em.createQuery(
    " Select distinct p "+
    " From Subgrupo sub,"+
    " UsuarioSubgrupo usb," +
    " Usuario u, "+
    " Grupo g, "+
    " Projeto p "+
    " where "+
    " sub.cdGrupo = g.cdGrupo and "+
    " g.cdProje = p.cdProje and "+
    " g.stAdmin = 1 and " +
    " sub.cdSubgr = usb.cdSubgr and " +
    " usb.cdUsuar = u.cdUsuar and " +
    " u.cdUsuar = 1"
    Select B (almost OK):
    Query q = em.createQuery(
    " Select p.dsProje "+ // the only difference
    " From Subgrupo sub,"+
    " UsuarioSubgrupo usb," +
    " Usuario u, "+
    " Grupo g, "+
    " Projeto p "+
    " where "+
    " sub.cdGrupo = g.cdGrupo and "+
    " g.cdProje = p.cdProje and "+
    " g.stAdmin = 1 and " +
    " sub.cdSubgr = usb.cdSubgr and " +
    " usb.cdUsuar = u.cdUsuar and " +
    " u.cdUsuar = 1"
    In the second select, I've got the rows according with where clause and I cannot understand how the fact of selecting an objetc Projeto (p) (select A) can make such a "mess" avoiding the rules of the where clause.
    Could someone give me a help about this problem?
    I'll be glad with any help!!
    []'s
    Alex
    !_Let's share ideas_!

    Hi,
    The issue is I am getting differents results from selects A and B and both have the same where clause.
    I have done this:
    Query q = em.createQuery(
    " SELECT NEW entity.Projeto (p.dsProje, p.cdProje) "+
    " From Subgrupo sub, "+
    " UsuarioSubgrupo usb," +
    " Usuario u, "+
    " Grupo g, "+
    " Projeto p "+
    " where sub.cdGrupo = g.cdGrupo "+
    " and g.cdProje = p.cdProje "+
    " and g.stAdmin = 1 "+
    " and sub.cdSubgr = usb.cdSubgr "+
    " and usb.cdUsuar = u.cdUsuar "+
    " and u.cdUsuar = " + cdUsuar
    I am getting what I need, but the reason why a simple select p does not work I don't know.
    This select is not generate by TopLink.
    Cheers!

  • Avoid repeating same logic in 'select' and 'where' clauses?

    I'll preface by saying I'm self-taught and have only been fiddling with SQL for a couple of months, so forgive me if this is a dumb question. I have a query written to pull out customers who are configured to have their products stored at the wrong warehouse, according to the first 3 digits of the zip code. Here is an extremely simplified version of a query I'm trying to run:
    select custno, custbuy_zip_cd, custbuy_prim_ship_loc_cd as Warehouse,
    case when substr(custbuy_zip_cd,1,3) in ('839','848') then '20'
    when substr(custbuy_zip_cd,1,3) in ('590','591') then '33'
    end as StdWhse
    from customers
    where case when substr(custbuy_zip_cd,1,3) in ('839','848') then '20'
    when substr(custbuy_zip_cd,1,3) in ('590','591') then '33'
    end <> custbuy_prim_ship_loc_cd
    or (case when substr(custbuy_zip_cd,1,3) in ('839','848') then '20'
    when substr(custbuy_zip_cd,1,3) in ('590','591') then '33'
    end is not null and custbuy_prim_ship_loc_cd is null)
    Now, the query works, but it seems overly convoluted and feels like there must be a way to make it simpler and faster. I'm using the same 'case when' 3 times. Originally, I had thought I could use the aliases from the 'select' clause in the 'where' clause, which would simplify things:
    select custno, custbuy_prim_ship_loc_cd as Warehouse,
    case when substr(custbuy_zip_cd,1,3) in ('839','848') then '20'
    when substr(custbuy_zip_cd,1,3) in ('590','591') then '33'
    end as StdWhse
    from customers
    where StdWhse <> custbuy_prim_ship_loc_cd
    or (StdWhse is not null and custbuy_prim_ship_loc_cd is null)
    I then found out that that caused 'invalid identifier' errors. My first attempt at a solution was to use a subquery in the 'from' clause, but that ran the 'case when' on every single customer instead of the small subset, so it wound up taking much longer even though it looked neater. Any tips on how to clean up that first query to make it run faster?
    this is Oracle 11i, I believe. As a side note, I don't have write access to the database.

    Thanks for all the tips so far - still going through them. You all respond fast! Sorry about using double angle brackets for != and not using code tags, I'll make sure to format my posts properly going forward. I think the double angle brackets messed up the appearance of my original queries a little. Here's how I probably should have pasted my first query in my first post:
    select custno, custbuy_zip_cd, custbuy_prim_ship_loc_cd as Warehouse,
        case when substr(custbuy_zip_cd,1,3) in ('839','848') then '20'
            when substr(custbuy_zip_cd,1,3) in ('590','591') then '33'
        end as StdWhse
    from customers
    where case when substr(custbuy_zip_cd,1,3) in ('839','848') then '20'
            when substr(custbuy_zip_cd,1,3) in ('590','591') then '33'
        end != custbuy_prim_ship_loc_cd
        or (case when substr(custbuy_zip_cd,1,3) in ('839','848') then '20'
            when substr(custbuy_zip_cd,1,3) in ('590','591') then '33'
        end is not null and custbuy_prim_ship_loc_cd is null)The almost unanimous opinion seems to be that I should use a subquery in one way or another, but the problem remains that the only significant logic to narrow down the results is the logic that matches the 'case when' results (which are what the warehouse number should be, based on the zip code) to the current warehouse number. Therefore, it seems like any subquery is going to return my entire list of 600k customers, and take a much longer time than my original (messy) query. At least it has in the test runs I created based on
    Satyaki's and Peter's examples. The query based on my original example takes about 2.5 minutes, and the subquery examples take about 5+ even though they look cleaner.
    to clarify what the query is trying to accomplish, I want it to pull any records where the warehouse number does not equal the correct warehouse number based on zip code (or if the warehouse number is null when it shouldn't be).
    I'll try to create some sample data and sample results. Customers table:
    custno   custbuy_zip_cd  custbuy_prim_ship_loc_cd
    1        59024           20
    2        59024           33desired results:
    custno   custbuy_zip_cd   warehouse   StdWhse
    1        59024            20          33If I could create a table to hold the standard warehouses to join on, the whole thing would be much easier. The full version of the query really has hundreds of zip code prefixes and 5 different warehouses and each account has 4 alternate warehouses as well. However, I'm stuck with read only access so everything has to go right in the query. It wouldn't be the end of the world to just stick with my original query since it's not like it takes hours, and I'll only be running it weekly. I just wanted to make sure there wasn't some other solution that wasn't just cleaner but was also faster.

  • Dynamic page with multiple select in where clause

    Hi,
    I have a dynamic page and in the where-clause, i have a bind variable. In a report i use for instance
    and rtrim((to_char(date_time5,'DAY'))) IN :v_day
    That works ok in a report. But it does not work in a dynamic page.
    what code is needed to work with a multiple select box on the customize screen for a dynamic page?
    Thanks.

    Hi.
    I have a dynamic page, with a bind variable :v_day. On the customization screen the user can select one or more days of the week, or all days. I use this also in a report and then it works ok. In the where clause i use:
    and rtrim((to_char(date_time,'DAY'))) IN :v_day
    Date_time is a tablecolumn (date).
    When i add this line in the select script from the dynamic page, i get error:
    : ORA-06550: line 1, column 2443:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    The symbol "(" was substituted for "" to continue.
    ORA-06550: line 1, column 2606:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    . ( ) , * @ % & - + / at mod rem <an exponent (**)> and or ||
    The symbol ")" was substituted for ";" to continue.
    ORA-06550: line 1, column 3236:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    The symbol (WWV-11230)
    Critical Error in wwerr_api_error.get_errors! SQL Error Message: ORA-06502: PL/SQL: numeric or value error: character string buffer too small (WWV-)
    Thanks.

  • Offset operation in select statements where clause

    dear experts,
        if i use offset operation in select query , syntactically giving
        me a warning message.
        how to avoid warning message
        without using another internal table populated with  only  jtab+0(10).  
       ex:
              select field1 field2
                        into table   itab
                        from ztable1
                        for all entries in jtab
                        where field =  jtab+0(10).
    thanks in advance.

    No need to populate another internal table...
    when populating jtab from database select ur field twice
    structure for jtab..
    types: begin of ty_jtab,
              field type ...
              field1 type char10,
            end of ty_jtab.
    populate the field twice..
       select ...
                 field
                 field
    into table jtab
    Now u can use the field field1 in the next select
    select field1 field2
    into table itab
    from ztable1
    for all entries in jtab
    where field = jtab-field1.

  • Select statment - where clause

    Hello experts,
    I want to write a select statment,
    e.g.
    select * from pa0001 where ename like '%Rahul%'.
    so this stamemt will give me all DB rows in which ename contains Rahul but i also want rows those are having rahul or rAhul or raHul or RAhul or RAHul or RaHul like wise....
    can u plz help me on this ???

    Hi
    Find the below code which may be useful for your requirement
    ranges:r_sel for lfa1-name1.
    data:v_name(5) type c value 'laxmi'.
    data:len type i,
    v_num type i,
    v_num1 type i,
    v_num2 type i,
    v_name1(5) type c,
    v_name2(5) type c,
    v_name_final(7) type c,
    v_char type c.
    len = strlen( v_name ).
    clear:v_name1,v_name2,v_name_final,v_num,v_num1,v_num2.
    v_num1 = len.
    do len times.
      v_num1 = v_num1 - 1.
      v_char = v_name+v_num(1).
      v_num2 = v_num.
      v_num = v_num + 1.
      if v_num1 is initial.
        clear:v_name1.
      else.
        v_name1 = v_name+v_num(v_num1).
      endif.
      if v_num2 is not initial.
        v_name2 = v_name+0(v_num2).
      endif.
      translate v_char to upper case.
      concatenate '' v_name2 v_char v_name1 '' into v_name_final.
      r_sel-option =  'CP'.
      r_sel-sign = 'I'.
      r_sel-low = v_name_final.
      clear:r_sel-high.
      append r_sel.
      translate v_char to lower case.
      concatenate '' v_name2 v_char v_name1 '' into v_name_final.
      r_sel-option =  'CP'.
      r_sel-sign = 'I'.
      r_sel-low = v_name_final.
      clear:r_sel-high.
      append r_sel.
    enddo.
    Use range parameter in your select statement.
    Regards
    Sripal

  • Slow Select Query - Where clause contains Seconday index field +other flds

    Hi friends,
    The below query is taking about an Hour to execute in production server when there are about 6 Million records in PLAF table. I have verified the trace in ST05 and the correct secondary index (Material Matnr + Plant Plwrk) is being selected.
    SELECT plnum
                 matnr
                 plwrk
                 pedtr
                 dispo
                 rsnum  FROM  plaf
                INTO TABLE it_orders
                WHERE ( ( matnr  IN r_mat1 )  OR
                                 matnr IN r_mat2  AND dispo IN s_mrp1 ) AND
                 pedtr IN s_date AND   
                 obart = '1'.
    Will it be a good idea to have only MATNR (secondary index field) in the where condition of the select query and delete the internal table entries for the other where conditions ?
    Edited by: Shruthi Seth on Feb 1, 2009 10:10 AM

    Hello.
    Creating a range r_mat = r_mat1 + r_mat2, I would do something like:
    READ TABLE s_mrp1 TRANSPORTING NO FIELDS INDEX 1.
    IF sy-subrc EQ 0.
      SELECT plnum matnr plwrk pedtr dispo rsnum
        FROM plaf
        INTO wa_orders
       WHERE matnr IN r_mat
         AND pedtr IN s_date
         AND obart = '1'.
        IF wa_orders-matnr IN r_mat2.
          CHECK wa_orders-dispo IN s_mrp1.
        ENDIF.
        APPEND wa_orders TO it_orders.
      ENDSELECT.
    ELSE.
      SELECT plnum matnr plwrk pedtr dispo rsnum
        FROM plaf
        INTO TABLE it_orders
       WHERE matnr IN r_mat1
         AND pedtr IN s_date
         AND obart = '1'.
    ENDIF.
    Regards,
    Valter Oliveira.

  • SELECT with WHERE clause for MSAccess from JDBC

    Hi,
    I am new user of MSAccess.I am getting exception: Invalid user type when i was trying the following code:
    String name1=nameTextfield.getText().trim();
    String query="SELECT ID from Suppliers WHERE name=name1;"
    Statement stmt=con.createStatement();
    ResultSet rs=stmt.executeQuery(query);
    while(rs.next())
    String id1=rs.getInt(1);
    System.out.println(id1);
    nameTextField is JTextField in my GUI.
    ID id auto field in table Suppliers.
    I am using MSAccess 97.
    I came to know that the JDBC SQL queries will be different for Access.
    Any body help me how to write SELECT statement?
    Thanks in advance,
    Sai Ram

    name or ID might be reserved words in access. Either change the name of the column or put [] around them. Also, you ar looking for a record where fields name and name1 are equal. You probably don't have a name1 field.
    String name1=nameTextfield.getText().trim();
    String query="SELECT [ID] from Suppliers WHERE [name]='"+name1+"';"
    Pay attention to the single and double quotes I have.

  • Using select in where clause

    I have 3 tables: contact2ext, contact2bnp, ext2bnp. contact2ext and contact2bnp both have a primary key called key. ext2bnp has 2 foreigns key, bnp and ext referencing these 2 primary keys.
    I want to use select to do the following:
    select nom from contact2ext where key = (select ext from ext2bnp where bnp=21);
    any idea about how to do this ?
    thanx
    null

    Hi,
    The query you have placed is right.
    Would appreciate if you give more clear idea about the data which wanted to be queried.
    This is another form of the same query.
    select nom from contact2ext where key IN(select ext from ext2bnp where bnp=21);
    In which even if the internal query returns more than one record , it would work.
    Best wishes.
    Rajesh
    null

  • JPA - Select with where clause

    Hi
    I have 2 classes:
    -Class A
    -Class B with a member which holds a reference to an object of Class A --> unidirectional one-to-one relation. The mapping is the following:
                   <one-to-one name="a">
                        target-entity="domain.A" fetch="LAZY"
                        optional="false">
                        <join-column name="ID" table="A" />
                   </one-to-one>
    Now i want to find all objects of B which have a certain instance of A. I tried this, but it doesn't work:
         <named-query name="findBsByA">
              <query>select b from B b where b.a = ?1</query>
         </named-query>
    Any suggestions?
    Thanks for help
    Michael

    name or ID might be reserved words in access. Either change the name of the column or put [] around them. Also, you ar looking for a record where fields name and name1 are equal. You probably don't have a name1 field.
    String name1=nameTextfield.getText().trim();
    String query="SELECT [ID] from Suppliers WHERE [name]='"+name1+"';"
    Pay attention to the single and double quotes I have.

  • Select and where clause

    Hi
    I want to write a select statement and in where condition
    1.I want to retrieve the fields which contains a string 'ABAP'
    2.I want to retreive the fields which is equal to space.
    eg;
    SELECT FLD1 FLD2 FLD3 FROM TABLE1 WHERE
       WHERE
       fld1 contains string 'ABAP'
    and fld2 is equal to space.

    Hi
    Yes you can, but you should use the language in the selection on MAKT:
    SELECT MARA~MATNR
    MAKT~MAKTX
    MCH1~CHARG
    MCH1~VFDAT INTO CORRESPONDING FIELDS OF TABLE GT_MATERIALS
    FROM MARA
    INNER JOIN MAKT
    ON MARAMATNR = MAKTMATNR
    INNER JOIN MCH1
    ON MAKTMATNR = MCH1MATNR
    INNER JOIN MVKE
    ON MVKEMATNR = MAKTMATNR
    WHERE MARA~MTART = 'ZDRU'
    AND MARA~LVORM = SPACE
    <b>  AND MAKT~MAKTG LIKE '%DISCONTINUE%'
      AND MAKT~SPRAS  = SY-LANGU "or EN</b>
    AND MVKE~VKORG = 'PUSA'
    AND MVKE~VTWEG = 'SPART'
    AND MVKE~MVGR4 = 92
    AND MCH1~CHARG IN S_CHARG.
    Max

Maybe you are looking for

  • Where did my iTunes go?

    Where did my iTunes go? I upgraded my iphone4 and it removed my iTunes and other apps too. What happend and how can I get iTunes back on my iphone4..? Also a photo album from my iPhoto on my computer sync with my iPhone and I cant figure out how to d

  • Enterprise manager sometimes can not be accessed?

    Dear contributors, I am a newbie and curious that my both laptops sometime can not acces the enterprise manager page. OS1 is Windows Vista Ultimate DB1 is Oracle 10gR2 for Windows Vista OS2 is Windows XP Home SP1 DB2 is Oracle 10gR2 for Windows My ma

  • HTML links in Adobe Bridge CS66

    Is it possible to incorporate a web address returning the viewer of the gallery created in Adobe Bridge CS6 back to my home page?

  • Installing Orcale DB System under Windows

    hi, I'm going to install Netweaver04 SR1 . My question how is oracle installed ? Through Sapinst or manually or does SAPINST require that Oracle is just installed before the Web AS Installation is done through SAPINST. It might be a simple question ,

  • Need Oracle DataBase For XI Installation????????

    Hi Experts, Should we Install ORACLE DataBase  While Xi Installation???????? With Oracle also Can We do the Installation???????? Here What is the Use of ORACLE Installation?????????????/ Please Let Me Know All the Details............ Regards Khanna