Application Development and Automation 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: 
Read only

CONTROL BREAK PROBLEM

Former Member
0 Likes
415

hi experts,

I have a classical report that shows record from many Plants. I have sorted the Internal table by plant and now want to display the data acording to plant. It has to first show the plant name then below that it shows all data related to that plant and then Total of that plant. For that I used control breal statement ( On change of ) to display plant. But what could I use to display total at end of every plant data. I tried ( at end of ) but it shows total after every line. Plz help.

thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
395

HI Khan,

for this you should slightly modify the declaration of your internal table.

let the plant field be the first field in your internal table.like,

data: begin of itab occurs 0,

werks type t001w-werks,

-


-


-


end of itab.

now in the loop,

loop at itab.

at new werks.

write:/ itab-werks.

endat.

write:/ ...............( all table fields)

at end of werks.

sum.

write:/ itab- ( all the qty & currency fields)

endat.

endloop.

2 REPLIES 2
Read only

Former Member
0 Likes
395

Hi

See this sample doc and code and write the report accordingly

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 mopving 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.

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.

Reward if helpful.

Regards,

Harini.S

Read only

Former Member
0 Likes
396

HI Khan,

for this you should slightly modify the declaration of your internal table.

let the plant field be the first field in your internal table.like,

data: begin of itab occurs 0,

werks type t001w-werks,

-


-


-


end of itab.

now in the loop,

loop at itab.

at new werks.

write:/ itab-werks.

endat.

write:/ ...............( all table fields)

at end of werks.

sum.

write:/ itab- ( all the qty & currency fields)

endat.

endloop.