ALV Subtotal based on specific fields
I have a requirement as follows:
In ALV Grid:
I have to display subtotal for a field(Currency) , based on two fields (document and material). When the user executes, he should be able to see the subtotals based on these two fields.
And I have to diaply grand total, based on document number.
Could you please help me out for the same.
Melih MUTLU replied
You have 2 way for this question.
First way as Rob say. But this way has one problem. if somebody has authority for change alv layout, He/She can change your layout.
Second way You can change/write your code. If This case is better for you. Please apply below code.
FORM ALV_FCAT . "write DO_SUM property endform. FORM ALV_SORT. CLEAR : SSORT, TSORT. REFRESH : TSORT. SSORT-SPOS = '1' . SSORT-FIELDNAME = 'xxx' . SSORT-UP = 'X' . "A to Z APPEND SSORT TO TSORT . SSORT-SPOS = '2' . SSORT-FIELDNAME = 'yyy' . SSORT-UP = 'X' . "A to Z SSORT-SUBTOT = 'X'. APPEND SSORT TO TSORT . ENDFORM. FORM DISPLAY_ALV . CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' " REUSE_ALV_GRID_DISPLAY Exporting ... IT_FIELDCAT = TFCAT IT_SORT = TSORT ... endform.