Skip to Content

What is inverse of FOR ALL ENTRIES

Hi everyone!

The FOR ALL ENTRIES keyword gets the entries in a db table equal to the entries in an internal table right?

What is the inverse of that (meaning excluding the entries in an internal table)?

Thanks!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Posted on Aug 13, 2007 at 04:06 AM

    Hi,

    You can make use of ranges to achieve that as follows.Kindly reward points by clicking the star on the left of reply,if it helps.

    tables mara.

    select-options s_matnr for mara-matnr.

    ranges r_matnr for mara-matnr.

    data : itab type standard table of mara,

    wa type mara,

    itab1 type standard table of makt,

    wa1 type makt.

    select * from mara into table itab where matnr in s_matnr.

    if sy-subrc eq 0.

    loop at itab into wa.

    r_matnr-low = wa-matnr.

    r_matnr-sign = 'I'.

    r_matnr-option = 'EQ'.

    append r_matnr.

    endloop.

    endif.

    select * from makt into table itab1 where matnr not in r_matnr.

    loop at itab1 into wa1.

    write : / wa1-matnr.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 13, 2007 at 02:43 AM

    When you use FOR ALL ENTRIES there must be atleast one equality in the select statement to that of the FOR ALL ENTRIES internal table field.

    This is what i meant -

    You can use NE when you are using FOR ALL ENTRIES, but its always good to use +ve checks like = or IN where ever possible than NOT IN and <>.

    select <data> from <table> 
                  into table <itab2>
                  for all entries in <itab1>
                  where <field> NE itab1-<field>.

    Rather you can also use the way below, but is always a performance issue and is not suggested always in cases like large data.

    loop at itab.

    select <data> from <table> into <itab2> where <field> <b>NE</b> itab-<field>.

    clear : itab.

    endloop.

    Regards

    Gopi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2007 at 02:44 AM

    hi richard,

    i guess there is no direct opposite. either u have to use ur own logic or if entries are fewer u can use NOT IN {.....}.

    regards,

    sap fan

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2007 at 02:57 AM

    You can write other way :

    Let me say one example :

    i want to get material number as well Material description.

    Material number at MARA Table,Material description at MAKT Table

    you have two options like Join or for all entries.now i am not following join as well for all entries method.

    data : begin of i_mara occurs 0,

    matnr like mara-matnr,

    end of i_mara.

    • final internal table

    data : begin of i_final occurs 0,

    matnr like mara-matnr,

    maktx like makt-maktx,

    end of i_final.

    start-of-selection.

    select * from mara into table i_mara.

    loop at i_mara.

    select single maktx from makt into makt-maktx

    where matnr = i_mara-matnr

    and spras = 'E'.

    if sy-subrc eq 0.

    i_final-matnr = i_mara-matnr.

    i_final-maktx = i_makt-maktx.

    append i_final.

    endif.

    endloop

    check the above code ,i simply written select single *

    but always use for all entries ,

    Thanks

    Seshu

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 13, 2007 at 03:52 AM

    I think the simplest solution is to create a range for the field that you base your exclude on.

    For example, say you want to select from MARA, but exclude a few items, which are in local table lt_exclude.

    DATA: LT_EXCLUDE TYPE STANDARD TABLE OF MARA,

    WA_EXCLUDE TYPE MARA,

    LT_MARA TYPE STANDARD TABLE OF MARA..

    RANGES LR_MATNR FOR MARA-MATNR.

    " BUILDING THE RANGE

    LOOP AT LT_EXCLUDE INTO WA_EXCLUDE.

    LR_MATNR-SIGN = 'I'.

    LR_MATNR-OPTION = 'EQ'.

    LR_MATNR-LOW = WA_EXCLUDE-MATNR.

    LR_MATNR-HIGH = ' '.

    APPEND LR_MATNR.

    ENDLOOP.

    " THE SELECT QUERY ITSELF

    SELECT * FROM MARA INTO LR_MARA

    WHERE MATNR NOT IN LR_EXCLUDE.

    Hope this helps.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 13, 2007 at 04:03 AM

    Hi,

    Ranges have limitation of no of records. please check note 635318.

    aRs

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2007 at 09:56 AM

    hi! Ricardo Caliolio

    Can use

    SELECT <data>FROM <table> INTO TABLE <itab2> FOR ALL ENTRIES IN

    <itab1>

    WHERE NE <itab1>

    but Performance wise its not advisable.

    Regards,

    Nagulan.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.