Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

I want information of AT END OF

Former Member
0 Kudos
725

Hello all,

I want information of

AT END OF

ENDAT.

4 REPLIES 4

Former Member
0 Kudos
126

Hi

All this AT NEW, AT FIRST, AT END OF and AT LAST are called control break statements of Internal tables and are used to calculate the TOTALS based on sertain key fields in that internal table

FIrst to use these statements the ITAB has to be sorted by the key fields on whcih you need the SUM of the fields.

Some time you will get * when moving data from this int table to other table using these commands

so you have to use

READ TABLE ITAB INDEX SY-TABIX in AT..ENDAT..if you are using other fields between them

DATA: sflight_tab TYPE SORTED TABLE OF sflight

WITH UNIQUE KEY carrid connid fldate,

sflight_wa LIKE LINE OF sflight_tab.

SELECT *

FROM sflight

INTO TABLE sflight_tab.

sort sflight by carrid connid.

LOOP AT sflight_tab INTO sflight_wa.

AT NEW connid.

WRITE: / sflight_wa-carrid,

sflight_wa-connid.

ULINE.

ENDAT.

WRITE: / sflight_wa-fldate,

sflight_wa-seatsocc.

AT END OF connid.

SUM.

ULINE.

WRITE: / 'Sum',

sflight_wa-seatsocc UNDER sflight_wa-seatsocc.

SKIP.

ENDAT.

AT END OF carrid.

SUM.

ULINE.

WRITE: / 'Carrier Sum',

sflight_wa-seatsocc UNDER sflight_wa-seatsocc.

NEW-PAGE.

ENDAT.

AT LAST.

SUM.

WRITE: / 'Overall Sum',

sflight_wa-seatsocc UNDER sflight_wa-seatsocc.

ENDAT.

ENDLOOP.

Regards

Anji

Former Member
0 Kudos
126

Hi

AT END OF <fld> - ENDAT. is the event to calculate the subtotals for the perticular field(fld).

just execute the following code.then u can get some idea.


DATA: BEGIN OF ITAB OCCURS 0,
      BUKRS LIKE LFC1-BUKRS,
      UM01H LIKE LFC1-UM01H,
      UM01U LIKE LFC1-UM01U,
      END OF ITAB.

SELECT BUKRS UM01H UM01U INTO TABLE ITAB FROM LFC1.

SORT ITAB BY BUKRS.

LOOP AT ITAB.
WRITE:/ SY-VLINE,ITAB-BUKRS,SY-VLINE,ITAB-UM01H,SY-VLINE,ITAB-UM01U,SY-VLINE.

AT END OF BUKRS.
SUM.
WRITE:/(55) SY-ULINE.
WRITE:/ SY-VLINE,(4) 'SUM'COLOR 6,SY-VLINE,ITAB-UM01H COLOR 6,SY-VLINE,ITAB-UM01U COLOR 6,SY-VLINE.
WRITE:/(55) SY-ULINE.
ENDAT.

AT LAST.
SUM.
WRITE:/(55) SY-ULINE.
WRITE:/ SY-VLINE,'GRAND TOTAL' COLOR 3,SY-VLINE,19(11) ITAB-UM01H COLOR 3,SY-VLINE,ITAB-UM01U COLOR 3,SY-VLINE.
WRITE:/(55) SY-ULINE.
ENDAT.

ENDLOOP.

plz reward,if it is helpful.

Former Member
0 Kudos
126

hi

Control break statements are used to create statement blocks which process only specific table lines inside 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

You can break the sequential access of internal tables by using these statements.

SYNTAX

At first.

<statement block>

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 : / ‘all records over’.

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.

regards

sachin

Former Member
0 Kudos
126

Hi,

AT END OF

.....

....

END AT

it is a control loop statement used inside the loop. All the control break statements should be used inside a loop because they heave to operate on each record of the internal table. Mainly control break statements are used for us to give good look detailed report for us.

At end of -


mainly useful for us to get sub totals of a particular field.

for ex: u have a report with fields matnr mtart ..............menge and u want quantity totals for matnr then we will use this AT end of control statement.

for ex:

at end of menge.

sum.

write:/10 itab-menge.

end at.

........

at end of control structure works lik this. it takes previous value of filed and compares with current value and condition is satisfied then it triggers.

if useful reward some points.

with regards,

Suresh Aluri.