This video tutorial explains the use of the “FOR ALL ENTRIES IN” clause in SAP ABAP. The instructor demonstrates this concept with an example where data is fetched from two different tables, and the data from the second table is fetched based on the entries in the first table. The video also emphasizes the importance of handling cases where the first table has no records to prevent fetching all data from the second table.

Key topics covered in the video session:

  1. Introduction to “FOR ALL ENTRIES IN” Clause: The instructor introduces the “FOR ALL ENTRIES IN” clause, which is an important keyword to learn while using the SELECT statement in SAP ABAP. This clause is used when the required information is available in two tables, not in one. It allows you to create a dependency between the two tables.
  2. Example Scenario: The instructor uses an example where he refers to two database tables, RSD_IOBJ and RSD_IOBJT. The requirement is to fetch the info object names, data type, field name, and their descriptions, which are in active state. The info object names and data type are fetched from the RSD_IOBJ table, and the descriptions are fetched from the RSD_IOBJT table.
  3. Writing the SELECT Statement: The instructor demonstrates how to write the SELECT statement to fetch data from the RSD_IOBJ table. He uses inline declaration to store the fetched data into an internal table. He also uses the WHERE clause to fetch only the active version of the info objects.
  4. Using “FOR ALL ENTRIES IN” Clause: The instructor then uses the “FOR ALL ENTRIES IN” clause in the second SELECT statement to fetch data from the RSD_IOBJT table. This clause is used to fetch data based on the entries in the first internal table. The instructor emphasizes that the “FOR ALL ENTRIES IN” clause is used to minimize the data set coming from the second table.
  5. Reading Data from the Internal Table: The instructor demonstrates how to use the READ statement to fetch data from the internal table. He explains that the READ statement retrieves only one record that satisfies the condition specified in the WITH KEY clause. He also explains the importance of using the SY-SUBRC system field to check if the READ statement was successful.
  6. Handling Cases with No Records in the First Table: The instructor explains a crucial point about the “FOR ALL ENTRIES IN” clause. If the first internal table contains no records, the SELECT statement with the “FOR ALL ENTRIES IN” clause fetches all data from the second table. To handle this, the instructor suggests using an IF statement to check if the first internal table is not initial (not empty) before executing the SELECT statement.
  7. Final Output: The instructor demonstrates the final output of the program, which displays the info object name, description, status, field name, and key data type for all the active info objects. He reiterates the importance of handling the “FOR ALL ENTRIES IN” clause correctly to prevent unnecessary data fetching and potential memory allocation issues in real-time projects.

Leave your comment

Your email address will not be published. Required fields are marked *