Control Break Statements
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 1 , 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 4 , '=', SUB.
CLEAR SUB.
ENDAT.
AT LAST.
WRITE : /50 'TOTAL' COLOR 3 , '=', TOTAL.
ENDAT.
ENDLOOP.
- 4 types
- AT First.
- AT Last.
- AT new.
- 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
- Go to transaction code SE38.
- Enter the program name Z or Y<program name>.
- Select attribute type as Executable program.
- 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 1 , 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 4 , '=', SUB.
CLEAR SUB.
ENDAT.
AT LAST.
WRITE : /50 'TOTAL' COLOR 3 , '=', TOTAL.
ENDAT.
ENDLOOP.
No comments:
Post a Comment