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 statements

Former Member
0 Likes
666

What are required before Control Break statements

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
619

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

5 REPLIES 5
Read only

Former Member
0 Likes
620

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

Read only

Former Member
0 Likes
619

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.

Read only

Former Member
0 Likes
619

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

Read only

0 Likes
619

1. The order of the fields in the Internal table, and

2. Sorting the Internal table.

Read only

Former Member
0 Likes
619

Control break statements is effextive only if you sort the internal table...

At new.

at first.

At end-of.

etc...

Regards,

Srini