‎2007 Feb 26 2:25 PM
HELLO ALL,
i have written a report program. where should i place the control break statements. is it in the loop which i used to retrieve the data using select statements or in the loop used to wrie the output into the basic list??
thanks & regards,
seenu
‎2007 Feb 26 2:26 PM
<b>keep it in the loop used to write the output into the basic list</b>
‎2007 Feb 26 2:26 PM
YOu should use the control break statements at internal table level for performance reasons.
Refer demo progs: DEMO_INT_TABLES_AT_1 and DEMO_INT_TABLES_AT_2.
‎2007 Feb 26 2:26 PM
<b>keep it in the loop used to write the output into the basic list</b>
‎2007 Feb 26 2:28 PM
Hello,
Control break stmt should be always in the LOOP ... ENDLOOP.
Check this example:
AT END OF f.
Effect
f is a sub-field of an internal table or extract dataset (EXTRACT) which is being processed with LOOP, i.e. the variants 1 and 2 only make sense within a LOOP.
Both "AT NEW f." and "AT END OF f. " introduce processing blocks which are concluded by " ENDAT.".
These processing blocks are processed whenever the contents of a field f or a sub-field defined before f change as a result of processing with LOOP. "AT NEW f." begins a new group of (table) lines with the same contents as the field f while "AT END OF f." concludes such a group.
Within the AT ... ENDAT processing of internal tables, all argument fields following f are filled with "*".
Examples
1. AT for sub-fields of an internal table
DATA: BEGIN OF COMPANIES OCCURS 20,
NAME(30),
PRODUCT(20),
SALES TYPE I,
END OF COMPANIES.
...
LOOP AT COMPANIES.
AT NEW NAME.
NEW-PAGE.
WRITE / COMPANIES-NAME.
ENDAT.
WRITE: / COMPANIES-PRODUCT, COMPANIES-SALES.
AT END OF NAME.
SUM.
WRITE: / COMPANIES-NAME, COMPANIES-SALES.
ENDAT.
ENDLOOP.
‎2007 Feb 26 2:28 PM
hi seenu,
u need to use it inside LOOP AT ITAB... ENDLOOP.
when u r using control brk stmts..dont forget to sort the table.
regards,
priya.
‎2007 Feb 26 2:33 PM
hi,
control break stmts are used twhile displaying o/ps either to calc totals or to group the fields and count the rows rtc.
so u shud use it in the loop used to write the o/p.
check the simple ex prog using control breaks.
DATA:BEGIN OF ITAB OCCURS 0,
A1(10) TYPE C,
A3(10) TYPE C,
A2 TYPE I,
END OF ITAB.
DATA:TOT TYPE I,count TYPE I,i type i.
ITAB-A1 = 'char1'.
ITAB-A3 = 'abc'.
ITAB-A2 = '10'.
APPEND ITAB.
ITAB-A1 = 'char1'.
ITAB-A3 = 'def'.
ITAB-A2 = '20'.
APPEND ITAB.
ITAB-A1 = 'char1'.
ITAB-A3 = 'abc'.
ITAB-A2 = '30'.
APPEND ITAB.
ITAB-A1 = 'char2'.
ITAB-A3 = 'abc'.
ITAB-A2 = '10'.
APPEND ITAB.
ITAB-A1 = 'char2'.
ITAB-A3 = 'abc'.
ITAB-A2 = '20'.
APPEND ITAB.
<b>SORT ITAB BY A1 a3.</b>
<b>loop at itab.</b>
<b>at new a1.</b>
write:/ itab-a1.
clear i.
<b>endat.</b>
<b>at new a3.</b>
if i > 0.
write:/10 itab-a3.
else.
write:10 itab-a3.
endif.
clear count.
<b>endat.</b>
count = count + 1.
i = i + 1.
<b>at end of a3.</b>
write:20 count.
<b>endat.</b>
<b>endloop.</b>
o/p :
<b>char1 abc 2
def 1
char2 abc 2 </b>
NOTE: don't forget to sort the table before using control breaks.
regards,
*reward points for all helpful answers