F ABAP Report with SUM Aggregate functions. | CodeTheta

ABAP Report with SUM Aggregate functions.

November 04, 2019

Code :
REPORT ZVP_SELECT_SUM_GROUP_BY.

TYPESBEGIN OF TY_VBAP,
         VBELN TYPE VBAP-VBELN,
         CMPRE TYPE VBAP-CMPRE,
       END OF TY_VBAP.

DATAIT       TYPE TABLE OF TY_VBAP,
      WA       TYPE TY_VBAP,

      LV_VBELN TYPE VBAP-VBELN.

SELECT-OPTIONSS_VBELN FOR LV_VBELN.

SELECT VBELN
       SUMCMPRE )
  FROM VBAP INTO TABLE IT UP TO 20 ROWS WHERE VBELN IN S_VBELN GROUP BY VBELN.

IF SY-SUBRC EQ 0.
  WRITE:'VBELN''             CMPRE'.
  LOOP AT IT INTO WA.
    WRITE:/ WA-VBELN,
    WA-CMPRE.

  ENDLOOP.
ENDIF.


Output :

sum of the CMPRE values with corresponding to same VBELN values.



 

IDE Used To Test This Code : ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us.We will reply you as soon as possible.

Post a Comment