SAP OO OBS ITAB AT 1

Get Example source ABAP code based on a different SAP table
  


ABAP Code Snippet
ARTICLE

Compatible Work Area When Processing Control Levels
The work area must be compatible with the table line type when processing control levels in an internal table.

In ABAP Objects, and as of release 7.0 also outside of classes, the following statement causes an error message:

DATA: itab LIKE TABLE OF line,
wa(255) TYPE x.

SORT itab by col1.
LOOP AT itab INTO wa.
AT NEW col1.
ENDAT.
ENDLOOP.
Correct syntax:

DATA: itab LIKE TABLE OF line,
wa LIKE LINE OF itab.
SORT itab by col1.
LOOP AT itab INTO wa.
AT NEW col1.
ENDAT.
ENDLOOP.
Cause:

Control level processing is based on the line structure of the internal table. The system evaluates the work area when it wants to change the control level, which means that the work area must have the same structure as the line of the table.