Need help from ALV experts

Question:
Please upload this program and tell me why the text for totals and subtotals is not showing.
I have them defined in the layout structure, but it's not working...
Thanks.
REPORT Z_ALV_PAGE_HEADERS
* NO STANDARD PAGE HEADING
* LINE-COUNT 40
LINE-SIZE 132.
*include Z_STD_HEADING.
TYPE-POOLS: kkblo,
slis,
sdydo.
TABLES: vbak, kna1, vbap.
DATA: BEGIN OF wkrec OCCURS 0,
* box type c,
vbeln LIKE vbak-vbeln,
auart LIKE vbak-auart,
kunnr LIKE vbak-kunnr,
netwr LIKE vbak-netwr,
c_name(35),
END OF wkrec.
DATA: fieldcat TYPE slis_t_fieldcat_alv,
fieldcat_ln LIKE LINE OF fieldcat,
sortcat TYPE slis_t_sortinfo_alv,
sortcat_ln LIKE LINE OF sortcat,
layout TYPE slis_layout_alv,
print TYPE slis_print_alv,
GT_XEVENTS TYPE SLIS_T_EVENT,
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
XS_EVENT TYPE SLIS_ALV_EVENT,
* layout_ln like line of layout,
keyinfo TYPE slis_keyinfo_alv,
col_pos LIKE sy-cucol,
pgm LIKE sy-repid.
*include rpr_alv_data.
CONSTANTS:
c_true TYPE c VALUE 'X', "Value for true
c_false TYPE c VALUE ' ', "Value for false
c_title_1(30) TYPE C VALUE 'Report Header',
c_title_2(30) TYPE C VALUE 'using ALV'.
SELECT-OPTIONS: doc FOR vbak-vbeln.
INITIALIZATION.
PERFORM append_report_titles. "Print Report Titles
START-OF-SELECTION.
SELECT vbeln auart kunnr netwr from vbak
INTO (wkrec-vbeln, wkrec-auart, wkrec-kunnr, wkrec-netwr)
where vbeln IN doc.
SELECT SINGLE name1 FROM kna1
INTO wkrec-c_name
where kunnr = wkrec-kunnr.
APPEND wkrec.
ENDSELECT.
* Start building catalog entries.
* Col_pos will determine the order across the screen.
* fieldname is the internal table field name
* ref_tabname is the structure that contains the field name
* reptext_ddic will override the column heading
ADD 1 TO col_pos.
fieldcat_ln-row_pos = 1.
fieldcat_ln-fieldname = 'VBELN'.
fieldcat_ln-ref_tabname = 'VBAK'.
fieldcat_ln-tabname = 'WKREC'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-hotspot = 'X'.
APPEND fieldcat_ln TO fieldcat.
CLEAR fieldcat_ln-hotspot.
ADD 1 TO col_pos.
fieldcat_ln-fieldname = 'C_NAME'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-outputlen = 83.
fieldcat_ln-seltext_l = 'Customer Name'.
APPEND fieldcat_ln TO fieldcat.
CLEAR fieldcat_ln-seltext_l.
CLEAR fieldcat_ln-outputlen.
ADD 1 TO col_pos.
fieldcat_ln-fieldname = 'AUART'.
fieldcat_ln-col_pos = col_pos.
fieldcat_ln-reptext_ddic = 'Order Type'.
APPEND fieldcat_ln TO fieldcat.
CLEAR fieldcat_ln-reptext_ddic.
ADD 1 TO col_pos.
fieldcat_ln-fieldname = 'KUNNR'.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln TO fieldcat.
ADD 1 TO col_pos.
fieldcat_ln-fieldname = 'NETWR'.
fieldcat_ln-col_pos = col_pos.
APPEND fieldcat_ln TO fieldcat.
* Start building the sort criteria
* ln_spos is the topmost sort field
* fieldname is the field to sort on
* up is sorting ascending
sortcat_ln-spos = '1'.
sortcat_ln-fieldname = 'C_NAME'.
sortcat_ln-up = 'X'.
APPEND sortcat_ln TO sortcat.
* Fill the variables of the ALV-grid.
PERFORM SET_LAYOUT USING LAYOUT. "Change layout-settings
PERFORM SET_EVENTS USING GT_XEVENTS[]."Set the events (top-page etc)
PERFORM COMMENT_BUILD USING GT_LIST_TOP_OF_PAGE[].
print-no_coverpage = 'X'.
print-no_change_print_params = 'X'.
print-no_print_listinfos = 'X'.
data: l_text type sdydo_text_element.
l_text = 'Screen header'.
export l_text to memory id 'ZHEAD'.
pgm = sy-repid.
PERFORM grid_display.
*---------------------------------------------------------------------*
* FORM grid_display *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM grid_display.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_BUFFER_ACTIVE =
* I_INTERFACE_CHECK = ' '
i_callback_program = pgm
* I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = 'BRANCH'
* I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_HTML_TOP_OF_PAGE = 'HTML_TOP_OF_PAGE'
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
is_layout = layout
it_fieldcat = fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
it_sort = sortcat
* IT_FILTER =
* IS_SEL_HIDE =
i_default = 'X'
i_save = 'U'
* IS_VARIANT =
IT_EVENTS = GT_XEVENTS
* IT_EVENT_EXIT =
IS_PRINT = print
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = wkrec
EXCEPTIONS
program_error = 1
OTHERS = 2.
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
* FORM branch *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> r_comm *
* --> rs_selfield *
*---------------------------------------------------------------------*
FORM branch USING r_comm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
case r_comm.
when '&IC1'.
if rs_selfield-fieldname = 'VBELN'
and rs_selfield-value ne space.
SET PARAMETER ID 'AUN' FIELD rs_selfield-value.
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
endif.
endcase.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form append_report_titles
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM append_report_titles.
* i_titles = c_title_1.
* append i_titles.
* i_titles = c_title_2.
* append i_titles.
ENDFORM. " append_report_titles
*&---------------------------------------------------------------------*
*& Form SET_LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LAYOUT text
*----------------------------------------------------------------------*
FORM SET_LAYOUT USING P_LAYOUT TYPE SLIS_LAYOUT_ALV.
* Minimize the columnwidth
P_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
* Give the table a striped pattern
P_LAYOUT-ZEBRA = 'X'.
* Set the text of the line with totals
P_LAYOUT-TOTALS_TEXT = 'Total:'.
* Set the text of the line with subtotals
P_LAYOUT-SUBTOTALS_TEXT = 'Subtotal:'.
* p_layout-box_fieldname = 'BOX'.
* p_layout-box_tabname = 'WKREC'.
p_layout-min_linesize = sy-linsz.
p_layout-colwidth_optimize = 'X'.
ENDFORM. " SET_LAYOUT
*&---------------------------------------------------------------------*
*& Form SET_EVENTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_XEVENTS text
*----------------------------------------------------------------------*
FORM SET_EVENTS USING P_GT_XEVENTS TYPE SLIS_T_EVENT.
* XS_EVENT-NAME = SLIS_EV_TOP_OF_LIST.
* XS_EVENT-FORM = 'XTOP_OF_LIST'.
* APPEND XS_EVENT TO P_GT_XEVENTS.
* XS_EVENT-NAME = SLIS_EV_END_OF_LIST.
* XS_EVENT-FORM = 'XEND_OF_LIST'.
* APPEND XS_EVENT TO P_GT_XEVENTS.
* XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.
* XS_EVENT-FORM = 'TOP_OF_PAGE'.
* APPEND XS_EVENT TO P_GT_XEVENTS.
* XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.
* XS_EVENT-FORM = 'XTOP_OF_PAGE'.
* APPEND XS_EVENT TO P_GT_XEVENTS.
* XS_EVENT-NAME = SLIS_EV_END_OF_PAGE.
* XS_EVENT-FORM = 'XEND_OF_PAGE'.
* APPEND XS_EVENT TO P_GT_XEVENTS.
DATA: ls_event TYPE slis_alv_event.
*
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = P_GT_XEVENTS.
READ TABLE P_GT_XEVENTS WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE 'TOP_OF_PAGE' TO ls_event-form.
APPEND ls_event TO P_GT_XEVENTS.
ENDIF.
ENDFORM. " SET_EVENTS
*&---------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&---------------------------------------------------------------------*
FORM TOP_OF_PAGE.
*write: / 'my page header'.
*write: / sy-pagno.
* PERFORM REPORT_HEADER TABLES i_titles.
*()*Here your selection-criteria can be printed
* CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
* EXPORTING
* I_LOGO = 'ENJOYSAP_LOGO'
* IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
ENDFORM. "top-of-page
*&---------------------------------------------------------------------*
*& Form COMMENT_BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GT_LIST_TOP_OF_PAGE[] text
*----------------------------------------------------------------------*
FORM COMMENT_BUILD USING LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: LS_LINE TYPE SLIS_LISTHEADER.
* LIST HEADING LINE: TYPE H
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
* LS_LINE-KEY: NOT USED FOR THIS TYPE
LS_LINE-INFO = 'Company Name'.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
* STATUS LINE: TYPE S
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Pgm:'.
LS_LINE-INFO = sy-repid.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Date/Time'.
concatenate sy-datum sy-uzeit into ls_line-info.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'User and System'.
APPEND LS_LINE TO LT_TOP_OF_PAGE.
CLEAR LS_LINE.
* ACTION LINE: TYPE A
**CLEAR LS_LINE.
**LS_LINE-TYP = 'A'.
* LS_LINE-KEY: NOT USED FOR THIS TYPE
**LS_LINE-INFO = 'DATA'..
**APPEND LS_LINE TO LT_TOP_OF_PAGE.
ENDFORM. " COMMENT_BUILD
Answer:
you have to put some fields in the field catalog with DO_SUM = 'X'
then in the sorting table put some fields with SUBTOT = 'X'
Answer:
The summing works fine when you click on the Total button.
The text on the total/subtotal line doesn't show up.
Hey, but now I know how to get the sum to show up initially!

More Articles:

SM36 and steps?
Selection-Infos automatically in ALV-Header?
Difference between 'Parameter' and 'Parameters'?
Download Report into Excel?
hello Mr. Korolev?
From 3.1i to 4.6c: abap editor shock!?