Not Like in Select Statement

Hi All,
My requirement is not to select the entries for the T024 table where the eknam is either starts with 'NOT VALID' or blank.
For that, I have written the select statement using NOT LIKE,
Will this negation in the select statement cause extra execution tiem?
If so, can you give some hint for alternative statement.
SELECT EKGRP EKNAM FROM T024 INTO TABLE IT_T024
IT_PURC WHERE EKGRP = S_EKGRP AND EKNAM NOT LIKE 'NOT VALID%' AND EKNAM NOT LIKE ' '.
Thanks,
Kal Chand

Hello,
For the first condition: not starting with 'NOT VALID' , I don't know other way apart from yours: EKNAM NOT LIKE 'NOT VALID%'.
For the second one, not starting with blank: EKNAM NOT LIKE ' '. Does it work? I think it compares if EKNAM is different from blank which can be done using:  EKNAM NE ' '.
I hope it will help you.

Similar Messages

  • Bind variables are not used in select statement

    Hello all of you,
    I have two parameters in Report 6i.
    1) Department
    2) Section
    There are many section in a single department. Both parameters are selected from list. The list for department name is as follows -
    select deptname from department_master order by deptname
    It works very well. The value is stored in :p_dept_name.
    I want to display section of selected department only using following code :-
    select sectname from section_master a, department_master b where a.deptcode = b.deptcode and b.deptname = :p_dept_name
    The value is stored in :p_sect_name.
    But it does not work. bind variables are not allowed in select statement, then how can I do this???
    Please suggest me.
    Thanx,
    Regards,

    Vikas,
    the forum is full of threads about that.
    Dependent Parameters in Reports are possible out-of-the-box in Reports.
    If you're running your report on the web, have a look at Metalink Note:185951.1
    Regards
    Rainer

  • Insert statement will not work if select statement has less number of colum

    Hi,
    One of my thread is already resolved on the following URL : unable to insert rows into the table
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
    DECLARE
    S VARCHAR2(200);
    STMT VARCHAR2(500);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    STMT := 'INSERT INTO TEMP SELECT * FROM ';
    STMT:=STMT || C.TABLE_NAME;
    EXECUTE IMMEDIATE STMT;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
    Please let me know , how can i execute proper way.
    Thanks.
    Best Regards
    Arshad

    user13360241 wrote:
    Hi,
    One of my thread is already resolved on the following URL : unable to insert rows into the table
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
    DECLARE
    S VARCHAR2(200);
    STMT VARCHAR2(500);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    STMT := 'INSERT INTO TEMP SELECT * FROM ';
    STMT:=STMT || C.TABLE_NAME;
    EXECUTE IMMEDIATE STMT;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
    Please let me know , how can i execute proper way.
    Thanks.
    Best Regards
    Arshadmore often than not "TEMP" tables are NOT required & are highly inefficient in Oracle.
    Either only specify explicit column in TEMP to get data,
    or provide value for "extra" column in TEMP

  • Bind Variables are not allowed in select statement

    I created a lov to one parameter field in a report using select statement.
    select distinct mtrl_group||' - '||grup_desc
    from mtrl_mast a , grup_mast b
    where financial_year||financial_month = :P_cutofff_period)
    and a.mtrl_group = b.grup_code
    this is my select statement & i got the above error.
    how can i fix bind variables in this.
    Pls help me......

    Hi,
    have a look at Metalink-Note 185951.1     
    SAMPLE - How to create a parameter LOV based on another parameter value?
    Regards
    Rainer

  • Order by column not in select statement

    Want to select multiple columns from a single table, and order by a column on the same table, but that is not in the select statement, or simply not shown in the output of the statement..
    Any help appreciated..

    Hi,
    In most cases, you can ORDER BY any column in the table(s) used, whether it is in the result set or not.
    Otherwise, include the column. Your front-end tool may be able to suppress the display, if you really don't want to see it.
    For example, in SQL*Plus
    COLUMN  dont_show  NOPRINTcauses any column named (or aliased) dont_show not to appear in the output.
    In Oracle9 (and up) sub-queries with ORDER BY return their results in order, so you can say things like:
    SELECT  col_a
    ,       col_b
    FROM    (
            SELECT    col_a
            ,         col_b
            ,         col_x   -- Not included in final output
            ORDER BY  col_x
            );

  • Regarding this select statement

    hi,
    i am not getting value i write like this select statement
    plz check error in this code.
    TABLES: VBAK,
    vbrk.
    TYPES: BEGIN OF TYP_VBAK,
          VBELN TYPE VBELN_VA,
          VBTYP TYPE VBTYP,
          VGBEL TYPE VGBEL,
          END OF TYP_VBAK,
           BEGIN OF TYP_VBRK,
              VBELN TYPE VBELN,
              WAERK TYPE WAERK,
              VKORG TYPE VKORG,
              KNUMV TYPE KNUMV ,
              FKDAT TYPE FKDAT,
              LAND1 TYPE LLAND,
              NETWR TYPE NETWR,
              KUNRG TYPE KUNRG,
              EXNUM TYPE EXNUM,
              MWSBK TYPE MWSBP,
              END OF TYP_VBRK.
    DATA: GT_VBAK TYPE TABLE OF TYP_VBAK,
          IT_VBRK TYPE standard TABLE OF TYP_VBRK WITH HEADER LINE.
         LS_VBRK TYPE TYP_VBRK,
      SELECT VBELN
             WAERK
             VKORG
             KNUMV
             FKDAT
             LAND1
             NETWR
             KUNRG
             EXNUM
             FROM VBRK INTO CORRESPONDING FIELDS OF TABLE IT_VBRK
             WHERE VBELN = '0090060045'.

    Check from SE16 whether vbeln = 0090060045 is present in VBRK or not.
    Regards,
    Joy.

  • Using LIKE in SELECT ..... WHERE

    Hi,
        I need to do pattern matching during SELECT so that a table field contains or is the same as an input variable. How can I accomplish this?
    Regards,
    Nanditha

    Here is the "help" for the syntax of LIKE in SELECT statement.
    <i>
    f [NOT] LIKE g
    Addition:
    ... ESCAPE h
    Effect
    The condition is met for a table entry if the statement "f (does not) equal the pattern in g" is true for the values of f and g. f must always be a field descriptor, and g an ABAP field. If f has the value NULL, then the result of the check for the statement is unknown. Within a pattern, there are two special characters:
    '_' (underscore) stands for any single character.
    '%' (percentage sign) stands for any sequence of characters, including an empty string.
    Examples
    Example to select all customers whose name begins with 'M':
    TABLES SCUSTOM.
    SELECT ID NAME FROM SCUSTOM
           INTO CORRESPONDING FIELDS OF SCUSTOM
           WHERE NAME LIKE 'M%'.
      WRITE: / SCUSTOM-ID, SCUSTOM-NAME.
    ENDSELECT.
    Example to select all customers whose name contains 'huber':
    TABLES SCUSTOM.
    SELECT ID NAME FROM SCUSTOM
           INTO CORRESPONDING FIELDS OF SCUSTOM
           WHERE NAME LIKE '%huber%'.
      WRITE: / SCUSTOM-ID, SCUSTOM-NAME.
    ENDSELECT.
    Example to select all customers whose name does not contain 'n' as the second character:
    TABLES SCUSTOM.
    SELECT ID NAME FROM SCUSTOM
           INTO CORRESPONDING FIELDS OF SCUSTOM
           WHERE NAME NOT LIKE '_n%'.
      WRITE: / SCUSTOM-ID, SCUSTOM-NAME.
    ENDSELECT.
    Notes
    LIKE can only be used for alphanumeric database fields. In other words, table field f must have Dictionary type ACCP, CHAR, CLNT, CUKY, LCHR, NUMC, UNIT, VARC, TIMS or DATS. The comparison field g must always have type C.
    The maximum length of the pattern is 2n - 1 characters, where n is the length of field f.
    Trailing spaces are ignored in comparison field g. If a pattern contains trailing spaces, you must enclose it in single inverted commas ('). If your pattern is enclosed in inverted commas and you also want to include inverted commas as part of the pattern, the inverted commas in the pattern must be doubled.
    You cannot use this variant in the ON addition to the FROM clause.
    </i>
    Regards,
    Rich Heilman

  • Need help in logic change to avoid select statement inside loop .

    Hello all ,
    Please see the below code . Here i got the shipment number in internal table  IT_VTTK . So For this shipment number i want to get the details from Vekp table in to internal table  IT_VEKP  . There is no need for me to use For all entries . I have passed the value of it_vekp into work area wa_vekp and getting the details in to IT_vekp using loop.
    But since we should not use the select statement inside the loop , Can anybody please tell me how to achieve this functionality .
    Instead of passing into work area wa_vttk if i directly use the internal table I'm getting the following error .
    "IT_VTTK" is a table without a header line and therefore has no component called "TKNUM".
    Hence i have used select statement inside a loop . Please tell me is there any other way to avoid this ?
    types:begin of ty_likp,
            vbeln type likp-vbeln,
           end of ty_likp,
           begin of ty_vttk,
            tknum type vttk-tknum,
            end of ty_vttk.
    DATA: IT_VEKP TYPE STANDARD TABLE OF TY_VEKP,
          WA_VEKP TYPE TY_VEKP.
      data:it_likp type standard table of ty_likp,
           wa_likp type ty_likp,
           it_likp1 type standard table of ty_likp,
           it_vttk type standard table of ty_vttk,
           wa_vttk type ty_vttk.
      data:w_tknum type vttk-tknum.
    if not it_likp is initial .
        select vbeln
                from
                 vbfa
          into table it_vttk
           for all entries in it_likp where vbelv = it_likp-vbeln and vbtyp_n = '8'.
      endif .
    IF IT_VTTK[] IS NOT INiTIAL.
        loop at it_vttk into wa_vttk.
        SELECT venum
               EXIDV
               EXIDV2
               BRGEW
               NTGEW
               GEWEI
               TARAG
               GEWEI
               VHART
               INHALT
             FROM VEKP INTO TABLE IT_VEKP where VPOBJKEY = wa_vttk-tknum  and vpobj = '4'.
          endloop.
          endif.

    Hello,
    Why would you not like to use FOR ALL ENTRIES in the second select? Is it becasue of the length or type mismatch error between the fields VPOBJKEY and wa_vttk-tknum ?
    Vikranth

  • Can we use is null in our select statement in ABAP program

    hi,
    I want to use 'is nul' or 'not null' in select statement of my ABAP program for any field. I have written below query but I am getting sy-subrc = 4 and getting no data. Can anyone resolve this.

    Hi,
    I think you've posted your question on the wrong forum. This is the SAP Business One development forum which is not part of ERP and doesn't include any ABAP or Netweaver programming.
    For a list of forums please see here:
    http://forums.sdn.sap.com/index.jspa
    Kind Regards,
    Owen

  • How to use  'is null' in select statement of ABAP program

    hi,
    I want to use 'is nul' or 'not null' in select statement of my ABAP program for any field. I have written below query but I am getting sy-subrc = 4 and getting no data.
    SELECT * FROM mara INTO TABLE it_mara
          WHERE volum IS NULL .
    Can anyone resolve this.

    Hi PKB,
    Check the below thread for NULL and Space value in ABAP . It will help you
    NULL and Space value in ABAP
    Regards,
    Pawan

  • Re: Select statement in the report

    Hi Experts,
    In my selection-screen contains ernam as a parameter.
    If it balnk in the selection-screen,
    the select statement is not working.
    if it is not blank ,the select statement is  working fine.
    TABLES: vbak.
    TYPES: BEGIN OF ty_vbak,
            vbeln TYPE vbeln,
            knumv TYPE knumv,
           END OF ty_vbak.
    DATA: v_vkorg TYPE vkorg,
          v_vtweg TYPE vtweg,
          v_erdat TYPE erdat.
    DATA: i_vbak  TYPE STANDARD TABLE OF ty_vbak.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS:     p_ernam TYPE ernam .
    SELECT-OPTIONS: s_vkorg FOR v_vkorg,
                    s_vtweg FOR v_vtweg,
                    s_erdat FOR v_erdat.
    PARAMETERS:     p_kvgr4 TYPE tvv4-kvgr4 OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    START-OF-SELECTION.
      SELECT vbeln
             knumv
      FROM vbak
      INTO TABLE i_vbak
      WHERE erdat IN s_erdat
      AND   ernam = p_ernam
      AND   vkorg IN s_vkorg
      AND   vtweg IN s_vtweg
      AND   kvgr4 = p_kvgr4.
      IF sy-subrc = 0.
        WRITE:/ 'HI'.
      ENDIF.
    Thank's in Advance,
    Harsha.

    report .
    TABLES: vbak.
    TYPES: BEGIN OF ty_vbak,
    vbeln TYPE vbeln,
    knumv TYPE knumv,
    END OF ty_vbak.
    DATA: v_vkorg TYPE vkorg,
    v_vtweg TYPE vtweg,
    v_erdat TYPE erdat.
    DATA: i_vbak TYPE STANDARD TABLE OF ty_vbak with header line.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    select-options: s_ernam for  vbak-ernam .
    SELECT-OPTIONS: s_vkorg FOR v_vkorg,
    s_vtweg FOR v_vtweg,
    s_erdat FOR v_erdat.
    PARAMETERS: p_kvgr4 TYPE tvv4-kvgr4 .
    SELECTION-SCREEN END OF BLOCK b1.
    START-OF-SELECTION.
    SELECT vbeln
    knumv
    FROM vbak
    INTO TABLE i_vbak
    WHERE erdat IN s_erdat
    AND ernam in s_ernam
    AND vkorg IN s_vkorg
    AND vtweg IN s_vtweg
    AND kvgr4 = p_kvgr4.
    IF sy-subrc = 0.
    loop at i_vbak.
    write:/ i_vbak-vbeln.
    endloop.
    ENDIF.

  • Doing a Trace on the ARXADLMT Approval Limits form No Select statement i

    Hi I want to see the all the SQL statements executed when I open the AR Approval Limits form(ARXADLMT). So I enabled the TRACE from the Menu(supplying password) , then opened then form and did a Query-> Execute. (The base table for the block is AR_APPROVAL_USER_LIMITS.Then I turned off the trace exited applications and went to the USER_DUMP_DEST directory of the database. From here tkprofed the latest trace file .When I look at the output file I cant see any Select statements at all. At least I should be seeing a select on the base table AR_APPROVAL_USER_LIMITS. Maybe I havent understood this process well enough- what am I doing wrong.Why is the trace not containing the select statement?
    Edited by: [email protected] on 13/06/2010 03:18

    >
    ... From here tkprofed the latest trace file ...
    >
    Pl post details of your OS and EBS versions. The latest trace file may not be the correct one. Pl search the trace files for "AR_APPROVAL_USER_LIMITS" to find the right trace file.
    How To Trace From Form, Report, Program And Others In Oracle Applications (Doc ID 130182.1)
    https://supporthtml.oracle.com/ep/faces/secure/km/DocumentDisplay.jspx?id=130182.1&h=Y
    HTH
    Srini

  • Use of LIKE in where clause of select statement for multiple records

    Hi Experts,
    I have a account number field which is uploaded from a file. Now this account numbers uploaded does not match fully with sap table account numbers but it contains all of the numbers provided in the file mostly in the upright positions.
    For example in file we have account number as 2ARS1 while in sap table the value is 002ARS1.
    And i want to fetch data from sap table based on account number uploaded. So, i am trying to use LIKE with for all entries but its not working as mentioned below but LIKE is not working with FOR ALL ENTRIES.
    data : begin of t_dda occurs 0,
            dda(19) type c,
           end of t_dda.
    data : begin of t_bukrs occurs 0,
            bukrs type t012k-bukrs,
           end of t_bukrs.
    data : dda type t012k-bankn,
           w_dda type t012k-bankn.
    CONCATENATE '%'
                             '2ARS1'
                     INTO  W_DDA.
    MOVE W_DDA TO T_DDA-DDA.
    APPEND T_DDA.
    CLEAR T_DDA.
    free t_bukrs.
    SELECT BUKRS
      FROM T012K
      into TABLE t_bukrs
        for all entries in t_dda
    WHERE BANKN like t_dda-dda.
    Can anybody suggest what should i use to get the data for multiple account numbers using one select statement only instead on using SELECT UP TO 1 ROWS in LOOP....ENDLOOP ?
    Thanks in advance,
    Akash

    Hi,
    yes, For All entries won't work for LIKE with '%  '.
    I think the other alternative is go for Native SQL by writing sub-query
    sample code is here:
    data: begin of i_mara occurs 0,
              matnr like mara-matnr,
              matkl like mara-matkl,
           end of i_mara.
    exec sql.
    select matnr, matkl from mara where matnr in (select matnr from marc) and matnr like '%ma' into :i_mara
    endexec.
    loop at i_mara.
    write:/ i_mara-matnr, i_mara-matkl.
    endloop.
    hope u got it.
    regards
    Mahesh
    Edited by: Mahesh Reddy on Jan 21, 2009 2:32 PM

  • If I want to order by dateAdded to I have to include it in the select statement like

    If I do this:
    <cfquery name="chart" datasource="#datasource#">
    select behaviourID,score, dateAdded2 = convert(varchar,
    dateAdded , 101)
    from staff_charts_data
    where userID =
    <cfqueryparam value="#arguments.userID#"
    cfsqltype="cf_sql_integer"> AND
    NOT score = 5
    </cfquery>
    If I want to order by dateAdded to I have to include it in
    the select statement like so:
    <cfquery name="chart" datasource="#datasource#">
    select behaviourID,score, dateAdded2 = convert(varchar,
    dateAdded , 101),dateAdded
    from staff_charts_data
    where userID =
    <cfqueryparam value="#arguments.userID#"
    cfsqltype="cf_sql_integer"> AND
    NOT score = 5
    </cfquery>

    you should be able to order by dateAdded without it being in
    the select clause. The only time the order by field has to be in
    the select clause is when your query has an aggregate and group by
    clause, like this:
    select field1, field2, max(field3) as youralias
    from sometables
    where whatever
    group by field1, field2
    order by ???
    You can only order field1, field2, max(field3) or youralias.
    You can't order by field4.

  • A trouble with "LIKE" in a select statement

    Hi!
    I'm having trouble with "LIKE" in a select statement...
    With Access I can make the following and everything works well:
    SELECT name, birthday
    FROM client
    WHERE birthday LIKE '*/02/*';
    but if try to do it in my application (it uses Access), it doesn't work - I just can't understand that!!!
    In my application the "month" is always the currently month taken from the "System". Look what I'm doing...
    String query1 = "SELECT name, birthday " +
              "FROM client " +
              "WHERE birthday " +
              "LIKE '*/" +
              pMonth +
              "/*' " +
              "ORDER BY birthday ASC ";
    ResultSet rs = statement1.executeQuery(consulta1);
    boolean moreRecords = rs.next();
    The variable "moreRecords" is always "false", the query returns nothing although the table "client" has records that attend the query.
    Please, anyone can help me?! It's a little bit urgent.
    Thanks,
    Katia.

    Hi Katia,
    I'll bet the problem lies with the characters you're using to escape the LIKE clause. You're using the ones that Access likes to see, but that's not necessarily what's built into the JDBC-ODBC driver class.
    You can find out what the correct escape wildcard characters are from the java.sql.DatabaseMetaData.getSearchStringEscape() method. It'll tell you what to use in the LIKE clause.
    I'm not 100% sure about your code. It doesn't use query1 anywhere. I'd do this:
    String query = "SELECT name, birthday FROM client WHERE birthday LIKE ? ORDER BY birthday ASC";
    PreparedStatement statement = connection.createStatement(query);
    String escape = connection.getMetaData().getSearchStringEscape();
    String test = escape + '/' + pMonth + '/' + escape;
    statement.setString(1, test);
    ResultSet rs = statement.executeQuery();
    while (rs.hasNext())
    // load your data into a data structure to pass back.
    rs.close();
    statement.close();Let me know if that works. - MOD

Maybe you are looking for