Wednesday, 1 June 2016

On change of


On change of

  • On change of similar to AT New . But it is not a control break statement.
  • It can be used within the loop or outside loop, even while , do loop also.
  • Syntax
      On change of <work_area-fieldname>.
       --------------
       ---------------
      ------- --------
     EndOn.


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.

ON CHANGE OF WA_VBRP-VBELN.

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

AT LAST.

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

ENDLOOP.

  • Save ->check -> activate->Execute.

Input


Output



No comments:

Post a Comment