Skip to Content
avatar image
Former Member

Where clause:-

Hi All,

I have a where condition as shown,

"where field1 eq var1"

now my requirement is to check for a list of values for var1.

that is,

I would like to provide a list of entries instead of var1( internal table or array of values )

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

9 Answers

  • Best Answer
    avatar image
    Former Member
    Nov 13, 2007 at 05:23 AM

    USE

    " WHERE FIELD1 IN ('A1','A2',................) " -


    >FOR ARRAY OF VALUES

    SELECT .......... FROM,,,......... FOR ALL ENTRIES IN IT_TABLE

    WHERE FIELD1 = IT_TABLE-FIELD1.

    -


    >FOR INTERNAL TABLE

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 13, 2007 at 05:20 AM

    used for all entiers.

    FOR ALL ENTRIES WHERE

    Syntax

    ... FOR ALL ENTRIES IN itab WHERE ... col operator itab-comp ...

    Effect

    If the addition FOR ALL ENTRIES is specified before the language element WHERE, then the components comp of the internal table itab can be used as operands when comparing with relational operators.

    The internal table itab must have a structured line type and the component comp must be compatible with the column col.

    The logical expression sql_cond of the WHERE condition can comprise various logical expressions by using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one Comparison with a column of the internal table itab, which can be specified either statistically or dynamically (Release 6.40 and higher). In a statement with a SELECTstatement with FOR ALL ENTRIES, the addition ORDER BY can only be used with the addition PRIMARY KEY.

    The whole logical expression sql_cond is evaluated for each individual line of the internal table itab. The resulting set of the SELECT statement is the union of the resulting sets from the individual evaluations. Duplicate lines are automatically removed from the resulting set. If the internal table itab is empty, the whole WHERE statement is ignored and all lines in the database are put in the resulting set.

    Notes

    In Release 6.10 and higher, the same internal table can be specified after FOR ALL ENTRIES and after INTO.

    The addition FOR ALL ENTRIES is only possible before WHERE conditions of the SELECT statement.

    If the additions PACKAGE SIZE or UP TO n ROWS are specified together with FOR ALL ENTRIES, they are not passed to the database system but are applied instead to the resulting set once all selected rows on the application server have been imported.

    With duplicated rows in the resulting set, the addition FOR ALL ENTRIES has the same effect as if addition DISTINCT were specified in the definition of the selection quantity. Unlike DISTINCT, the rows are not deleted from the database system but are deleted on the application server from the resulting set.

    Addition FOR ALL ENTRIES is only possible for WHERE conditions of the SELECT statement.

    Example

    Exporting all flight data for a specified departure city. The relevant airlines and flight numbers are first put in an internal table entry_tab, which is evaluated in the WHERE condition of the subsquent SELECT statement.

    PARAMETERS p_city TYPE spfli-cityfrom.

    TYPES: BEGIN OF entry_tab_type,

    carrid TYPE spfli-carrid,

    connid TYPE spfli-connid,

    END OF entry_tab_type.

    DATA: entry_tab TYPE TABLE OF entry_tab_type,

    sflight_tab TYPE SORTED TABLE OF sflight

    WITH UNIQUE KEY carrid connid fldate.

    SELECT carrid connid

    FROM spfli

    INTO CORRESPONDING FIELDS OF TABLE entry_tab

    WHERE cityfrom = p_city.

    SELECT carrid connid fldate

    FROM sflight

    INTO CORRESPONDING FIELDS OF TABLE sflight_tab

    FOR ALL ENTRIES IN entry_tab

    WHERE carrid = entry_tab-carrid AND

    connid = entry_tab-connid.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 13, 2007 at 05:21 AM

    Hi,

    Use for all entries ...

    Ex..

    DATA: T_MATNR TYPE STANDARD TABLE OF MATNR.

    DATA: T_MARA TYPE STANDARD TABLE OF MARA.

    SELECT MATNR FROM MARA

    INTO TABLE T_MATNR

    FOR ALL ENTRIES IN T_MARA

    WHERE MATNR = T_MARA-MATNR.

    Thanks

    Naren

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 13, 2007 at 05:22 AM

    Hi,

    If u have another internal table then use for all entries for that otherwise do like this

    where field1 in ( 'value1', 'value2', 'value3' ).

    Regards,

    Prashant

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 13, 2007 at 05:22 AM

    Hi

    u can use AND or OR operator for checking multiple values of field.. if static values

    or FOR ALL ENTRIES... if dynamic values..

    Hope it helps.

    Thanks & regards

    ilesh 24x7

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 13, 2007 at 05:26 AM

    Thanks A Lot

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 13, 2007 at 05:27 AM

    HI

    You can use Ranges for this.

    Populate your range ra_var with the values u want .

    Then midify ur where condition like :

    where field1 IN ra_var .

    Thanks .

    Praveen

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 13, 2007 at 05:32 AM

    Make range and enter fields values in that.

    *----


    RANGES: FLDS.

    FLDS-LOW = 'VALUE1'.

    FLDS-SIGN = 'I'.

    FLDS-OPTION = 'EQ'.

    APPEND FLDS.

    FLDS-LOW = 'VALUE2'.

    FLDS-SIGN = 'I'.

    FLDS-OPTION = 'EQ'.

    APPEND FLDS.

    SELECT * FROM ZTABLE INTO ITAB WHERE FLD IN FLDS.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 13, 2007 at 06:15 AM

    Hi...

    You can use this option...

    where filed in ( list of values ).

    ex:

    where field in ( 'hyd', 'sec' , 'banglore').

    how many entreis you want to give as list of values?.....

    Regards \

    sandeep.

    Add comment
    10|10000 characters needed characters exceeded