Skip to Content
0
Former Member
Nov 27, 2012 at 06:53 AM

Having Same table in FOR ALL ENTRIES IN and INTO clause

2833 Views

Hi Experts,

When I query a database table with a refernce table, can I go head and fill the reference table also in the same SELECT query, instead of taking the trouble to loop over it again and filling it ?

The scenario is:

I have an internal table i_table of the below structure,

wrkst TYPE mara-wrkst,

matnr TYPE mara-matnr,

aufnr TYPE caufv-aufnr,

Before the query, my table is filled with matnr and aufnr.

Now would it be wrong or would it give any unexpected errors in future if I query like this:

SELECT wrkst matnr

FROM mara

INTO TABLE i_table

FOR ALL ENTRIES IN i_table

WHERE matnr EQ i_table-matnr.

Note: I tested it and it worked fine. But I wanted to be sure to avoid any dangers of using such a code.