Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

ALV Subtotal based on specific fields

Hi,

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.

Thanks,

Sandeep

Former Member
Former Member replied

Hi Sandeep;

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.

Best regards.

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.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question