Select for all entries in SAP ABAP

Select for all entries in SAP ABAP, What are the advantages of select for all entries in SAP ABAP programming

+ -
SELECT FOR ALL ENTRIES is the best alternative for SELECT WITH JOINS, this statement is very helpful for reading data from more than 2 tables.
The load on database will be very less.
Syntax : 

SELECT  FROM  INTO TABLE 
WHERE .
SELECT  FROM  INTO  FOR ALL ENTRIES IN 
WHERE  = -FIELD1.
**HERE WE ARE READING DATA 2 DATABASE TABLES, SEE WHERE CONDITIONS OF SECOND SELECT STATEMENT

Ensure before using SELECT FOR ALL ENTRIES

  • Parent internal table must not be empty ( If it is empty, where condition fails and it will get all records from database).
  • Remove all duplicate entries in parent internal table.

Here is the example of using SELECT FOR ALL ENTRIES in real-time applications

**DATA DECLARATIONS
DATA : IT_MARA TYPE TABLE OF MARA.
DATA : IT_MAKT TYPE TABLE OF MAKT .
**GET DATA FROM MARA TABLE
SELECT * FROM MARA INTO TABLE IT_MARA
 WHERE MATNR = '0001'.
**SORT MARA TABLE, TO DELETE ADJACENT DUPLICATES THE TABLE MUST BE SORTED IN ASCENDING ORDER
SORT IT_MARA ASCENDING .
**DELETE ADJACENT DUPLICATES FROM IT_MARA COMPARING ALL FIELDS
DELETE ADJACENT DUPLICATES FROM IT_MARA COMPARING ALL FIELDS.

**TO USE SELECT FOR ALL ENTRIES, THE PARENT INTERNAL TABLE MUST NOT BE EMPTY SO CHECK IT
IF IT_MARA IS NOT INITIAL. "CHECK PARENT INTERNAL TABLE 
**SECOND SELECT STATEMENT TO GET DATA FROM MAKT (MATERIAL DESCRIPTIONS), HERE WE ARE GETTING DATA
**FROM MAKT FOR ALL THE RECORDS IN IT_MARA, SEE WHERE CONDITION SHOULD BE PARENT INTERNAL TABLE 
SELECT * FROM MAKT INTO TABLE IT_MAKT
 FOR ALL ENTRIES IN IT_MARA
 WHERE MATNR = IT_MARA-MATNR.
ENDIF.

Please Sign in to ask a question

Was this lesson helpful to you? Yes No 68 People out of 72 think this lesson helpful


Lesson Navigation

←Previous Chapter
Next Chapter →