Vous êtes sur la page 1sur 5

In AT FIRST and AT LAST event blocks the numeric values in the work area contains zeros.

SUM statement calculates the totals of numeric fields and places the totals in the corresponding fields of work area. In AT NEW and AT END OF event blocks SUM statement finds all the rows within the control level and calculates the totals of numeric fields that are right to the control level and places the totals in the corresponding fields of work area. ** * DATA: gwa_spfli TYPE spfli. DATA: gt_spfli TYPE TABLE OF spfli. *Data Declaration *

SELECT * UP TO 5 ROWS FROM spfli INTO TABLE gt_spfli.

LOOP AT gt_spfli INTO gwa_spfli. AT FIRST. WRITE:/ 'Flight Details'. WRITE:/ 'Airline Code' COLOR 5,14 'Connection No.' COLOR 5, 29 'Departure City' COLOR 5, 44 'Arival City' COLOR 5, 58 'Distance' COLOR 5. ULINE. ENDAT. AT NEW carrid. WRITE:/ gwa_spfli-carrid, ' : New Airline'. ULINE. ENDAT.

WRITE:/14 gwa_spfli-connid,29 gwa_spfli-cityfrom, 44 gwa_spfli-cityto,58 gwa_spfli-distance. AT END OF carrid. ULINE. SUM. WRITE:/ gwa_spfli-carrid,58 gwa_spfli-distance. ULINE. ENDAT. AT LAST. SUM. WRITE:/ 'Total',58 gwa_spfli-distance. WRITE:/ 'End of Loop'. ENDAT. ENDLOOP. Output

ON CHANGE OF behaves similar to AT NEW. The syntax is as follows. ON CHANGE OF <control level1> [or <control level2> . .]. [ELSE.] ENDON. ** * DATA: gwa_spfli TYPE spfli. DATA: gt_spfli TYPE TABLE OF spfli. *Data Declaration *

SELECT * UP TO 5 ROWS FROM spfli INTO TABLE gt_spfli.

LOOP AT gt_spfli INTO gwa_spfli.

AT FIRST. WRITE:/ 'Flight Details'. WRITE:/ 'Airline Code' COLOR 5,14 'Connection No.' COLOR 5, 29 'Departure City' COLOR 5, 44 'Arival City' COLOR 5, 58 'Distance' COLOR 5. ULINE. ENDAT. ON CHANGE OF gwa_spfli-carrid. WRITE:/ gwa_spfli-carrid, : New Airline. ULINE. ENDON. WRITE:/14 gwa_spfli-connid,29 gwa_spfli-cityfrom, 44 gwa_spfli-cityto,58 gwa_spfli-distance.

ENDLOOP. Output

Below table summarizes the differences between AT NEW and ON CHANGE OF statements. AT NEW ON CHANGE OF

It can be used only in AT LOOP statement.

It can be used in any loop like SELECT, DO etc..

Only one control field can be Multiple control fields separated used. by OR can be used.

AT NEW is triggered when a ON CHANGE OF is not triggered field left to control level when a field left to control level changes. Values in the fields to the right of values. be ELSE addition can be used. changes. Values in the fields to the asterisks and zeros. ELSE used. Changes to work area with Changes to work area with ON AT NEW will be lost. CHANGE OF will not be lost. addition cannot

right of control level contains control level contains original

Vous aimerez peut-être aussi