ABAP FOR ALL ENTRIES SELECT command in SAP
The ABAP select command has a number of options which allow you to fine tune your database selection. One such
addition is the 'FOR ALL ENTRIES' statement which allows you to build an internal table and then restrict the
database select to only get entries contained in it.
Below is a simple example of how to select data using the 'FOR ALL ENTRIES' addition! It basically builds and internal table containing a list of purchase order numbers(EBELN) from table EKKO, it then only retrieves entries from EKPO where the PO number exists in the internal table.
REPORT ZSELECTCOMMAND. *Select FOR ALL ENTRIES command data: it_ekko type STANDARD TABLE OF ekko, wa_ekko like line of it_ekko, it_ekpo type standard table of ekpo, wa_ekpo like line of it_ekpo. SELECT * UP TO 10 ROWS "only return first 10 hits FROM ekko INTO TABLE it_ekko. loop at it_ekko into wa_ekko. write:/ wa_ekko-ebeln. endloop. IF sy-subrc EQ 0. * The FOR ALL ENTRIES comand only retrieves data which matches * entries within a particular internal table. SELECT * FROM ekpo INTO TABLE it_ekpo FOR ALL ENTRIES IN it_ekko WHERE ebeln EQ it_ekko-ebeln. write:/ 'FOR ALL ENTRIES comand '. loop at it_ekpo into wa_ekpo. write:/ wa_ekpo-ebeln, wa_ekpo-ebelp. endloop. ENDIF.