Code :
REPORT ZVP_SELECT_SUM_GROUP_BY.
TYPES: BEGIN OF TY_VBAP,
VBELN TYPE VBAP-VBELN,
CMPRE TYPE VBAP-CMPRE,
END OF TY_VBAP.
DATA: IT TYPE TABLE OF TY_VBAP,
WA TYPE TY_VBAP,
LV_VBELN TYPE VBAP-VBELN.
SELECT-OPTIONS: S_VBELN FOR LV_VBELN.
SELECT VBELN
SUM( CMPRE )
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 :
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.
REPORT ZVP_SELECT_SUM_GROUP_BY.
TYPES: BEGIN OF TY_VBAP,
VBELN TYPE VBAP-VBELN,
CMPRE TYPE VBAP-CMPRE,
END OF TY_VBAP.
DATA: IT TYPE TABLE OF TY_VBAP,
WA TYPE TY_VBAP,
LV_VBELN TYPE VBAP-VBELN.
SELECT-OPTIONS: S_VBELN FOR LV_VBELN.
SELECT VBELN
SUM( CMPRE )
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