Example Report using control break statements in SAP ABAP

Using control break statements in ABAP programs to display totals, subtotals

+ -
Requirement: Develop a report to display list of sales orders with totals and page sub-totals for a particular date.

Selection-screen : input date.

SUM : SUM is a key word which is used to add numerical values of a field in control break statements.

REPORT ZSAPN_CONTROL_BREAK.
TYPES : BEGIN OF TY_VBAP,
        VBELN TYPE VBAP-VBELN,
        MATNR TYPE VBAP-MATNR,
        ZMENG TYPE VBAP-ZMENG,
        NETPR TYPE VBAP-NETPR,
        END OF TY_VBAP.
DATA : IT_VBAP TYPE TABLE OF TY_VBAP.
DATA : WA_VBAP TYPE TY_VBAP.
PARAMETERS : P_DATE TYPE VBAP-ERDAT .

START-OF-SELECTION.
  SELECT VBELN MATNR ZMENG NETPR
         FROM VBAP INTO TABLE IT_VBAP
         WHERE ERDAT = P_DATE.

  LOOP AT IT_VBAP INTO WA_VBAP.

    AT FIRST .
      WRITE :/2 'SALES DOC', 18 'MATRIAL', 28'QUANTITY', 40 'PRICE'.
    ENDAT.

    AT NEW VBELN.
      WRITE :/2 WA_VBAP-VBELN, 18 WA_VBAP-MATNR, 28 WA_VBAP-ZMENG, 40 WA_VBAP-NETPR.
    ENDAT.

    AT END OF VBELN.
      SUM.
      WRITE :/23 'SUB TOTAL IS :' COLOR 6, WA_VBAP-NETPR.
    ENDAT.

    AT LAST.
      SUM.
      WRITE:/23 'Total is:', WA_VBAP-NETPR .
    ENDAT.

  ENDLOOP.

Learner Questions


No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question

    Was this lesson helpful to you? Yes No 36 People out of 42 think this lesson helpful


    Lesson Navigation

    ←Previous Chapter
    Next Lesson → Enhancements in SAP