‎2006 Dec 12 4:52 AM
‎2006 Dec 12 4:56 AM
Hi,
The field position is important for the fields that are using in the control break statements..Also SORT internal table is required..
DATA: BEGIN OF ITAB OCCURS 0,
MATNR TYPE MATNR,
WERKS TYPE WERKS_D,
VALUE TYPE NETPR,
END OF ITAB.
ITAB-MATNR = 'ABC'.
ITAB-WERKS = '0100'.
ITAB-VALUE = '10.00'.
APPEND ITAB.
ITAB-MATNR = '1ABC'.
ITAB-WERKS = '0100'.
ITAB-VALUE = '10.00'.
APPEND ITAB.
SORT ITAB BY MATNR WERKS.
LOOP AT ITAB.
AT END OF MATNR.
SUM.
WRITE: / ITAB-MATNR, 'MATERIAL TOTAL - ', ITAB-VALUE.
ENDAT.
AT END OF WERKS.
SUM.
WRITE: / ITAB-WERKS, 'PLANT TOTAL - ', ITAB-VALUE.
ENDAT.
ENDLOOP.
Thanks,
Naren
‎2006 Dec 12 4:56 AM
Hi,
The field position is important for the fields that are using in the control break statements..Also SORT internal table is required..
DATA: BEGIN OF ITAB OCCURS 0,
MATNR TYPE MATNR,
WERKS TYPE WERKS_D,
VALUE TYPE NETPR,
END OF ITAB.
ITAB-MATNR = 'ABC'.
ITAB-WERKS = '0100'.
ITAB-VALUE = '10.00'.
APPEND ITAB.
ITAB-MATNR = '1ABC'.
ITAB-WERKS = '0100'.
ITAB-VALUE = '10.00'.
APPEND ITAB.
SORT ITAB BY MATNR WERKS.
LOOP AT ITAB.
AT END OF MATNR.
SUM.
WRITE: / ITAB-MATNR, 'MATERIAL TOTAL - ', ITAB-VALUE.
ENDAT.
AT END OF WERKS.
SUM.
WRITE: / ITAB-WERKS, 'PLANT TOTAL - ', ITAB-VALUE.
ENDAT.
ENDLOOP.
Thanks,
Naren
‎2006 Dec 12 5:04 AM
HI
BEFORE USING CONTROL BREAK STATEMENT AND LOOP
YOU HAVE TO SORT THE INTERNAL TABLE.
THAT IS
SORT ITAB BY FNAME.
LOOP AT ITAB.
AT FIRST
AT NEW
AT LAST
ON CHANGE OF
ENDLOOP.
‎2006 Dec 12 5:06 AM
Hi Sarath,
It is important to sort the internal table prior to perform control break.
SORT ITAB.
LOOP AT ITAB.
AT FIRST.
...
AT NEW.
...
AT LAST.
...
ENDLOOP.
Hope this will help.
Regards,
Ferry Lianto
‎2006 Dec 12 5:11 AM
1. The order of the fields in the Internal table, and
2. Sorting the Internal table.
‎2006 Dec 12 5:08 AM
Control break statements is effextive only if you sort the internal table...
At new.
at first.
At end-of.
etc...
Regards,
Srini