Control Break Statements


Control Break Statements
  • 4 types
  1. AT First.
  2. AT Last.
  3. AT new.
  4. AT end of.

AT First.

  • Inside the loop if you want to perform certain action at first  , then use At First .
  • Syntax
     AT First.
      ------------
      -----------
      -----------
   ENDAT.
Ex : Top of page.

AT Last.


  • Inside the loop if you want to perform certain action at last  , then use At Last .
  • Syntax
    AT Last.
      ------------
      -----------
      -----------
     ENDAT.
Ex : footer.

AT new.


  • Inside the  loop if you want to perform certain action on every beginning of new field  , then use At new .
  • Syntax
    AT  NEW <field-name>.
      ------------
      -----------
      -----------
    ENDAT.

AT end of

  • Inside the  loop if you want to perform certain action on every end of new field  , then use At end of .
  • Syntax
    AT  END of  <field-name>.
      ------------
      -----------
      -----------
    ENDAT.
Ex :

Steps

  1. Go to transaction code SE38.
  2. Enter the program name Z or Y<program name>.
  3. Select attribute type as Executable program.
  4. Click on Save.

Source Code


REPORT  ZTOT_SUB NO STANDARD PAGE HEADING.


TYPES BEGIN OF TY_VBRP,
        VBELN TYPE VBRP-VBELN,
        POSNR TYPE VBRP-POSNR,
        MATNR TYPE VBRP-MATNR,
        ARKTX TYPE VBRP-ARKTX,
        NETWR TYPE VBRP-NETWR,
        END OF TY_VBRP.


DATA WA_VBRP TYPE TY_VBRP,
       IT_VBRP TYPE TABLE OF TY_VBRP.

DATA TOTAL TYPE VBRP-NETWR VALUE 0.

DATA SUB TYPE VBRP-NETWR VALUE 0.
SELECT-OPTIONS S_VBELN FOR WA_VBRP-VBELN.


SELECT VBELN POSNR MATNR ARKTX   NETWR FROM VBRP INTO TABLE IT_VBRP
WHERE
  VBELN IN S_VBELN.


LOOP AT IT_VBRP INTO WA_VBRP.

AT FIRST.

  WRITE /20 'SALES ORDER ITEM DETAILS' COLOR 4.

ENDAT.

AT NEW VBELN.
  ULINE.
  WRITE 'NEW BILL DOC : ' COLOR WA_VBRP-VBELN.

ENDAT.
  WRITE / WA_VBRP-VBELN WA_VBRP-POSNR WA_VBRP-MATNR ,
WA_VBRP-ARKTX WA_VBRP-NETWR.

TOTAL  TOTAL  +  WA_VBRP-NETWR.

SUB SUB + WA_VBRP-NETWR.

AT END OF VBELN.

  WRITE /60  'SUB-TOTAL' COLOR '='SUB.
  CLEAR SUB.
ENDAT.

AT LAST.

  WRITE /50 'TOTAL' COLOR '='TOTAL.
ENDAT.

ENDLOOP.


Input

Output

Comments

Popular posts from this blog

FOR ALL ENTRIES (FAE) -4 TABLES USING ALV_GRID_DISPLAY

RADIO-BUTTONS IN BASIC REPORT

MODULE POOL -TABLE CONTROL_1: