Hi Experts
I've done subtotal in ALV. I'm getting below output. But i want net value subtotal should come by adding to its previous subtotal.
Ex : 4969 02.01.1997 CURA 5.500
4970 03.01.1997 CURA 38.338 (32.838 + 5.500)
My code :
type-pools slis.
data : BEGIN OF ty_vbak OCCURS 0,
VBELN like vbak-vbeln,
erdat like vbak-erdat,
ernam like vbak-ernam,
netwr like vbak-netwr,
END OF ty_vbak.
DATA : it_fcat type SLIS_T_FIELDCAT_ALV,
WA_FCAT TYPE SLIS_FIELDCAT_ALV,
IT_SORT TYPE SLIS_T_SORTINFO_ALV,
WA_SORT TYPE SLIS_SORTINFO_ALV,
G_VBELN TYPE VBAK-VBELN.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'TY_VBAK'
* I_STRUCTURE_NAME =
* I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = SY-REPID
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = it_fcat.
SELECT-OPTIONS S_VBELN FOR G_VBELN.
SELECT VBELN ERDAT ernam NETWR
FROM VBAK INTO TABLE ty_vbak WHERE VBELN IN S_VBELN.
* WA_FCAT-FIELDNAME = 'VBELN'.
* WA_FCAT-SELTEXT_M = 'Sales Document'.
* WA_FCAT-OUTPUTLEN = 20.
* APPEND WA_FCAT TO IT_FCAT.
*
* WA_FCAT-FIELDNAME = 'ERDAT'.
* WA_FCAT-SELTEXT_M = 'DATE'.
* APPEND WA_FCAT TO IT_FCAT.
*
*
* WA_FCAT-FIELDNAME = 'NETWR'.
* WA_FCAT-SELTEXT_M = 'NET PRICE'.
* WA_FCAT-DO_SUM = 'X'.
* WA_FCAT-OUTPUTLEN = 40.
* APPEND WA_FCAT TO IT_FCAT.
* CLEAR WA_FCAT.
READ TABLE IT_FCAT INTO WA_FCAT WITH KEY FIELDNAME = 'NETWR'.
WA_SORT-FIELDNAME = 'ERDAT'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
WA_FCAT-FIELDNAME = ' '.
WA_FCAT-DO_SUM = 'X'.
MODIFY IT_FCAT FROM WA_FCAT TRANSPORTING
DO_SUM KEY WHERE FIELDNAME = 'NETWR'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = IT_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
IT_SORT = IT_SORT
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ty_vbak
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.