Загрузка...

32 FOR ALL ENTRIES and ON CHANGE OF events

In SAP ABAP, the FOR ALL ENTRIES clause is used in a SELECT statement to retrieve data from a database table based on a list of criteria stored in an internal table. It is primarily used to replace nested SELECT loops or complex joins that might cause performance issues.

Core Functionality
----------------------
When you use FOR ALL ENTRIES, the system evaluates the logical expression in the WHERE clause for every single row of the specified internal table. The final result is a union of all these individual selections.

Essential Rules for Usage
Check for Empty Tables: You must always check if the internal table is empty before the SELECT statement. If the table is initial (empty), the WHERE condition is ignored, and the system will fetch all entries from the database table, which can lead to severe performance degradation or runtime errors.
Duplicate Removal: This clause automatically removes duplicate rows from the final result set. For this reason, it is critical to include the primary key fields of the target table in your SELECT list to ensure you don't lose unique records.
Sort for Performance: It is a best practice to sort the internal table and remove duplicates within it before using it in a FOR ALL ENTRIES statement to optimize the database query
The ON CHANGE OF statement in SAP ABAP is a control break statement used to execute a block of code only when the content of a specific field (or multiple fields) changes. While often compared to AT NEW, it has broader flexibility and different technical behaviors.

Key Characteristics
-----------------------
Location Flexibility: Unlike AT NEW, which is restricted to LOOP...ENDLOOP blocks for internal tables, ON CHANGE OF can be used anywhere in a program, including inside SELECT...ENDSELECT, DO, WHILE, and even outside of loops.
Multiple Fields: You can trigger the block based on changes in multiple fields by separating them with OR (e.g., ON CHANGE OF f1 OR f2).
Field Data Availability: Within an ON CHANGE OF block, all fields of a structure remain accessible with their current values. In contrast, AT NEW often masks fields to the right of the trigger field with asterisks (*).
Execution Trigger: It triggers the first time it is reached (unless the field is initial) and every time the field's value differs from its value during the previous execution

Видео 32 FOR ALL ENTRIES and ON CHANGE OF events канала SAP Full Stack Custom Development
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять