abap at new
时间: 2023-10-28 17:24:25 浏览: 113
ABAP (Advanced Business Application Programming) is a programming language developed by SAP for building business applications. The "AT NEW" statement in ABAP is used to trigger certain actions when a new value is encountered in a specific field while processing a set of data records.
For example, let's say we have a table of employees with fields such as employee ID, name, and department. If we want to perform some actions whenever a new department is encountered while processing the records, we can use "AT NEW" in ABAP.
Here's an example:
```
DATA: lv_previous_department TYPE string,
lv_current_department TYPE string.
LOOP AT employees INTO DATA(ls_employee).
lv_current_department = ls_employee-department.
IF lv_current_department <> lv_previous_department.
WRITE: / 'New Department:', lv_current_department.
" Perform some actions here
ENDIF.
" Update the previous department
lv_previous_department = lv_current_department.
ENDLOOP.
```
In this example, whenever a new department is encountered while looping through the employees table, it will display the new department and perform some actions.
阅读全文