We can help. Together we learn....

Info - For all select

by Voice | Tuesday, May 05, 2009 in |

1. Before doing a for all select, just make sure the internal table you are using for all select is not empty (INITIAL). If it is empty then for all select will fetch all the records in the database and thay may be a problem. So be careful.

2. Mechanism of for all select: SAP first fetches all the record and then it sort the records found and then it does a delete duplicates comparing all the fields. So, if you want to retrieve all the records, you MUST select all the key fields or else you will lose some records.

Try it for youself:
Check the number of records present in the database table and the number of records present in internal table.


types: begin of ty_dd02l,
         tabname type tabname,
       end of ty_dd02l,

       begin of ty_dd03l,
         tabname type tabname,
         KEYFLAG type KEYFLAG,
       end of ty_dd03l.

data: i_dd02l type standard table of ty_dd02l initial size 0,
      i_dd03l type standard table of ty_dd03l initial size 0.

data: v_tabname type dd02l-tabname.
select-options s_table for v_tabname.

select TABNAME
   from dd02l
  into table i_dd02l
  where tabname in s_table.

IF sy-subrc = 0.
  select TABNAME
    from dd03l
    into table i_dd03l
    for all entries in i_dd02l
    where tabname = i_dd02l-tabname.

  IF sy-subrc = 0.



  1. Dinesh Kumar on April 27, 2016 at 2:10 PM

    Thanks for sharing this Informative content. Well explained. Got to learn new things from your Blog on SAP SD

  2. Ramya k on June 17, 2016 at 12:22 PM

    Thanks for the great information in your blogSAP SD Training in Chennai

  3. Bhavya Kumar on September 23, 2016 at 1:29 PM

    Great place to learn about the new things and got great knowledgeSAP MM Training in Chennai