Google Search - Blog...........

ABAP - AT First / At New / At End Of / At Last - Syntax & Example.

Control break statements are used to create statement blocks which process only specific table lines the LOOP – ENDLOOP block.

You open such a statement block with the control level statement AT and close it with the control level statement ENDAT. The syntax is as follows:

Table should be sorted when you use control-break statements
You can break the sequential access of internal tables by using these statements.
Syntax:
At first.

Endat.

This is the first statement to get executed inside the loop (remember control break statements are applicable only inside the loop)

So in this block you can write or process those statements which you want to get executed when the loop starts.

At New carrid.
Write:/ carrid.
Endat.
In this case whenever the new carrid is reached, carrid will be written.

At End of carrid.
Uline.
Endat.

In this case whenever the end of carrid is reached, a line will be drawn.

At Last.
Write:/ ‘Last Record is reached’.
Endat.

Processing of statements within this block is done when entire processing of entire internal table is over. Usually used to display grand totals.

You can use either all or one of the above control break statements with in the loop for processing internal table.

At end of carrid.
Sum.
Endat.

In above case the statement SUM (applicable only within AT-ENDAT) will sum up all the numeric fields in internal table and result is stored in same internal table variable.

No comments:

Post a Comment