2007 Jul 10 7:04 AM
Hi,
I am trying to calculate the totals of netwr and fkimg in a report but the following coding cannot giv me the right answer so if there is anyone with the solution for this problem may you please help me out and how can i display the date on my report......here is my coding:
REPORT Z_DAILY_STOCK_NEW.
TYPE-POOLS: SLIS.
----
TABLES
----
TABLES: vbrk, kna1,vbrp,vbap,vbak, sflight.
----
ALV FIELDS
----
DATA: it_fieldcat TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
wa_fieldcat TYPE slis_fieldcat_alv.
DATA: w_cnt LIKE sy-tabix.
total ref to data.
t_alv LIKE TABLE OF s_error WITH HEADER LINE.
DATA: gr_layout TYPE slis_layout_alv,
gr_tab_group TYPE slis_t_sp_group_alv,
gr_repid LIKE sy-repid,
gr_events TYPE slis_t_event,
gr_print TYPE slis_print_alv,
gr_user TYPE slis_formname VALUE 'USER_COMMAND'.
----
SELECTION SCREEN
----
SELECT-OPTIONS:
s_werks FOR vbrp-werks,
s_auart FOR vbak-auart.
----
DEFINITION OF AN INTERNAL TABLE
----
DATA: begin of i_stocktab occurs 0,
kunag LIKE vbrk-kunag,
name1 LIKE kna1-name1,
ort01 LIKE kna1-ort01,
inco1 LIKE vbrk-inco1,
vkgrp LIKE vbrp-vkgrp,
fkimg LIKE vbrp-fkimg,
netwr LIKE vbrk-netwr,
end of i_stocktab.
----
START OF SELECTION
----
SELECT vbrkkunag kna1name1 kna1ort01 vbrkinco1 vbrp~vkgrp
vbrpfkimg vbrknetwr
FROM kna1 inner join vbrk on kna1kunnr EQ vbrkkunrg
inner join vbak on kna1kunnr EQ vbakkunnr
inner join vbrp on vbrkvbeln EQ vbrpvbeln
INTO i_stocktab
WHERE vbrp~werks IN s_werks
AND vbak~auart IN s_auart.
APPEND i_stocktab.
ENDSELECT.
*DATA tb_alv TYPE i_stocktab WITH HEADER LINE.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM build_event.
PERFORM build_print.
PERFORM calc_total.
PERFORM display_alv_report.
&----
FORM build_fieldcatalog.
&----
w_cnt = 1.
it_fieldcat-fieldname = 'KUNAG'.
it_fieldcat-seltext_m = 'Soldtp'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
it_fieldcat-key = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'NAME1'.
it_fieldcat-seltext_m = 'Name'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'ORT01'.
it_fieldcat-seltext_m = 'City'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'INC01'.
it_fieldcat-seltext_m = 'Incoterms'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'VKGRP'.
it_fieldcat-seltext_m = 'Sales Group'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'FKIMG'.
it_fieldcat-seltext_m = 'Invoiced Qty'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
*it_fieldcat-do_sum = 'x'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'NETWR'.
it_fieldcat-seltext_m = 'Invoiced Value'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
it_fieldcat-do_sum = 'x'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
ENDFORM.
&----
FORM build_layout.
&----
gr_layout-no_input = 'X'.
gr_layout-colwidth_optimize = 'X'.
gr_layout-totals_text = 'Totals: '(201).
gr_layout-detail_popup = 'X'.
ENDFORM.
&----
FORM build_event.
&----
DATA i_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = gr_events[].
READ TABLE gr_events WITH KEY name = slis_ev_user_command
INTO i_event.
if sy-subrc = 0.
MOVE gr_user TO i_event-form.
APPEND i_event TO gr_events.
endif.
ENDFORM.
&----
*FORM calc_total.
&----
LOOP AT it_fieldcat into wa_fieldcat
WHERE fieldname EQ 'FKIMG' OR
fieldname EQ 'NETWR'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-datatype = 'QUAT'.
modify it_fieldcat from wa_fieldcat.
ENDLOOP.
*ENDFORM.
FORM build_print.
gr_print-reserve_lines = '2'.
gr_print-no_coverpage = 'X'.
ENDFORM.
----
FORM calc_total.
----
DATA: total type ref to data,
subtotal1 type ref to data.
field-symbols <fkimg> like sflight.
field-symbols <netwr> like sflight.
call method grid1-> get_subtotals
importing
ep_collect00 = subtotal
ep_collect01 = total.
assign total to <fkimg>.
assign total to <netwr>.
ENDFORM.
&----
*& FUNCTION ALV DISPLAY
&----
FORM display_alv_report.
gr_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = gr_repid
I_CALLBACK_USER_COMMAND = slis_ev_user_command
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE' " see FORM
IS_LAYOUT = gr_layout
IT_FIELDCAT = it_fieldcat[]
IT_SPECIAL_GROUPS = gr_tab_group
I_SAVE = 'X'
IT_EVENTS = gr_events
IS_PRINT = gr_print
TABLES
t_outtab = i_stocktab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
&----
FORM top-of-page.
&----
*ALV Header deaclarations
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
t_line LIKE wa_header-info,
ld_lines TYPE i,
ld_linesc TYPE c.
*Title
wa_header-typ = 'H'.
wa_header-info = 'Report for daily Stock Returns'.
APPEND wa_header TO t_header.
CLEAR wa_header.
*Total No. Records Selected
DESCRIBE TABLE i_stocktab LINES ld_lines.
ld_linesc = ld_lines.
CONCATENATE 'Total No. of Records Selected:' ld_linesc
INTO t_line SEPARATED BY space.
wa_header-typ = 'A'.
wa_header-info = t_line.
APPEND wa_header TO t_header.
CLEAR: wa_header, t_line.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
ENDFORM.
2007 Jul 10 7:27 AM
Try This
REPORT z_daily_stock_new.
TYPE-POOLS: slis.
*----------------------------------------------------------------------*
* TABLES
*----------------------------------------------------------------------*
TABLES: vbrk, kna1,vbrp,vbap,vbak, sflight.
*-----------------------------------------------------------------------
*
* ALV FIELDS
*-----------------------------------------------------------------------
*
DATA: it_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
wa_fieldcat TYPE slis_fieldcat_alv.
DATA: w_cnt LIKE sy-tabix.
* total ref to data.
* t_alv LIKE TABLE OF s_error WITH HEADER LINE.
DATA: gr_layout TYPE slis_layout_alv,
gr_tab_group TYPE slis_t_sp_group_alv,
gr_repid LIKE sy-repid,
gr_events TYPE slis_t_event,
gr_print TYPE slis_print_alv,
gr_user TYPE slis_formname VALUE 'USER_COMMAND'.
*-----------------------------------------------------------------------
*
* SELECTION SCREEN
*-----------------------------------------------------------------------
*
SELECT-OPTIONS:
s_werks FOR vbrp-werks,
s_auart FOR vbak-auart.
*-----------------------------------------------------------------------
*
* DEFINITION OF AN INTERNAL TABLE
*-----------------------------------------------------------------------
*
DATA: BEGIN OF i_stocktab OCCURS 0,
kunag LIKE vbrk-kunag,
name1 LIKE kna1-name1,
ort01 LIKE kna1-ort01,
inco1 LIKE vbrk-inco1,
vkgrp LIKE vbrp-vkgrp,
fkimg LIKE vbrp-fkimg,
netwr LIKE vbrk-netwr,
END OF i_stocktab.
*-----------------------------------------------------------------------
*
* START OF SELECTION
*-----------------------------------------------------------------------
*
SELECT vbrk~kunag kna1~name1 kna1~ort01 vbrk~inco1 vbrp~vkgrp
vbrp~fkimg vbrk~netwr
FROM kna1 INNER JOIN vbrk ON kna1~kunnr EQ vbrk~kunrg
INNER JOIN vbak ON kna1~kunnr EQ vbak~kunnr
INNER JOIN vbrp ON vbrk~vbeln EQ vbrp~vbeln
INTO i_stocktab
WHERE vbrp~werks IN s_werks
AND vbak~auart IN s_auart.
APPEND i_stocktab.
ENDSELECT.
*DATA tb_alv TYPE i_stocktab WITH HEADER LINE.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM build_event.
PERFORM build_print.
PERFORM calc_total.
PERFORM display_alv_report.
*---------------------------------------------------------------------*
* FORM build_fieldcatalog *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM build_fieldcatalog.
w_cnt = 1.
it_fieldcat-fieldname = 'KUNAG'.
it_fieldcat-seltext_m = 'Soldtp'.
it_fieldcat-emphasize = 'X'.
it_fieldcat-key = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'NAME1'.
it_fieldcat-seltext_m = 'Name'.
it_fieldcat-emphasize = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'ORT01'.
it_fieldcat-seltext_m = 'City'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
* w_cnt = w_cnt + 1.
* it_fieldcat-fieldname = 'INC01'.
* it_fieldcat-seltext_m = 'Incoterms'.
* it_fieldcat-emphasize = 'X'.
* APPEND it_fieldcat TO it_fieldcat.
* CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'VKGRP'.
it_fieldcat-seltext_m = 'Sales Group'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'FKIMG'.
it_fieldcat-seltext_m = 'Invoiced Qty'.
it_fieldcat-emphasize = 'X'.
it_fieldcat-ref_tabname = 'VBRP' .
it_fieldcat-ref_fieldname = 'FKIMG' .
it_fieldcat-do_sum = 'X' .
* *it_fieldcat-do_sum = 'x'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
clear it_fieldcat .
it_fieldcat-fieldname = 'NETWR'.
it_fieldcat-seltext_m = 'Invoiced Value'.
it_fieldcat-emphasize = 'X'.
it_fieldcat-ref_tabname = 'VBRP' .
it_fieldcat-ref_fieldname = 'NETWR' .
it_fieldcat-do_sum = 'X' .
* it_fieldcat-do_sum = 'x'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
ENDFORM.
*---------------------------------------------------------------------*
* FORM build_layout *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM build_layout.
gr_layout-no_input = 'X'.
gr_layout-colwidth_optimize = 'X'.
gr_layout-totals_text = 'Totals: '(201).
gr_layout-detail_popup = 'X'.
ENDFORM.
*---------------------------------------------------------------------*
* FORM build_event *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM build_event.
DATA i_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = gr_events[].
READ TABLE gr_events WITH KEY name = slis_ev_user_command
INTO i_event.
IF sy-subrc = 0.
MOVE gr_user TO i_event-form.
APPEND i_event TO gr_events.
ENDIF.
ENDFORM.
*FORM calc_total.
* LOOP AT it_fieldcat into wa_fieldcat
* WHERE fieldname EQ 'FKIMG' OR
* fieldname EQ 'NETWR'.
* wa_fieldcat-do_sum = 'X'.
* wa_fieldcat-datatype = 'QUAT'.
* modify it_fieldcat from wa_fieldcat.
* ENDLOOP.
*ENDFORM.
FORM build_print.
gr_print-reserve_lines = '2'.
gr_print-no_coverpage = 'X'.
ENDFORM.
*---------------------------------------------------------------------*
* FORM calc_total *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM calc_total.
DATA: total TYPE REF TO data,
subtotal1 TYPE REF TO data.
* FIELD-SYMBOLS <fkimg> LIKE sflight.
* FIELD-SYMBOLS <netwr> LIKE sflight.
* CALL METHOD grid1-> get_subtotals
* IMPORTING
* ep_collect00 = subtotal
* ep_collect01 = total.
* ASSIGN total TO <fkimg>.
* ASSIGN total TO <netwr>.
ENDFORM.
*& FUNCTION ALV DISPLAY
FORM display_alv_report.
gr_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gr_repid
i_callback_user_command = slis_ev_user_command
i_callback_top_of_page = 'TOP-OF-PAGE' " see FORM
is_layout = gr_layout
it_fieldcat = it_fieldcat[]
it_special_groups = gr_tab_group
i_save = 'X'
it_events = gr_events
is_print = gr_print
TABLES
t_outtab = i_stocktab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
* FORM top-of-page *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM top-of-page.
*ALV Header deaclarations
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
t_line LIKE wa_header-info,
ld_lines TYPE i,
ld_linesc TYPE c.
*Title
wa_header-typ = 'H'.
wa_header-info = 'Report for daily Stock Returns'.
APPEND wa_header TO t_header.
CLEAR wa_header.
*Total No. Records Selected
DESCRIBE TABLE i_stocktab LINES ld_lines.
ld_linesc = ld_lines.
CONCATENATE 'Total No. of Records Selected:' ld_linesc
INTO t_line SEPARATED BY space.
wa_header-typ = 'A'.
wa_header-info = t_line.
APPEND wa_header TO t_header.
CLEAR: wa_header, t_line.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
ENDFORM.
2007 Jul 10 7:05 AM
Hi,
Add this to fieldcatalog and checkout if it works
lt_fieldcat-datatype = 'QUAN' or 'CURR'
chk this blog
/people/community.user/blog/2007/05/07/alignment-of-data-in-top-of-page-in-alv-grid
<b>
Reward points if useful</b>
Regards
Ashu
2007 Jul 10 7:17 AM
Hi Fred
To display the date, you can use the system variable sy-datum
use the following code:
<b>write:/ sy-datum</b>
This will display the system date on your screen.
<b>
Ps: Reward points if useful.</b>
Thanks & regards
Ravish Garg
2007 Jul 10 7:27 AM
Try This
REPORT z_daily_stock_new.
TYPE-POOLS: slis.
*----------------------------------------------------------------------*
* TABLES
*----------------------------------------------------------------------*
TABLES: vbrk, kna1,vbrp,vbap,vbak, sflight.
*-----------------------------------------------------------------------
*
* ALV FIELDS
*-----------------------------------------------------------------------
*
DATA: it_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
wa_fieldcat TYPE slis_fieldcat_alv.
DATA: w_cnt LIKE sy-tabix.
* total ref to data.
* t_alv LIKE TABLE OF s_error WITH HEADER LINE.
DATA: gr_layout TYPE slis_layout_alv,
gr_tab_group TYPE slis_t_sp_group_alv,
gr_repid LIKE sy-repid,
gr_events TYPE slis_t_event,
gr_print TYPE slis_print_alv,
gr_user TYPE slis_formname VALUE 'USER_COMMAND'.
*-----------------------------------------------------------------------
*
* SELECTION SCREEN
*-----------------------------------------------------------------------
*
SELECT-OPTIONS:
s_werks FOR vbrp-werks,
s_auart FOR vbak-auart.
*-----------------------------------------------------------------------
*
* DEFINITION OF AN INTERNAL TABLE
*-----------------------------------------------------------------------
*
DATA: BEGIN OF i_stocktab OCCURS 0,
kunag LIKE vbrk-kunag,
name1 LIKE kna1-name1,
ort01 LIKE kna1-ort01,
inco1 LIKE vbrk-inco1,
vkgrp LIKE vbrp-vkgrp,
fkimg LIKE vbrp-fkimg,
netwr LIKE vbrk-netwr,
END OF i_stocktab.
*-----------------------------------------------------------------------
*
* START OF SELECTION
*-----------------------------------------------------------------------
*
SELECT vbrk~kunag kna1~name1 kna1~ort01 vbrk~inco1 vbrp~vkgrp
vbrp~fkimg vbrk~netwr
FROM kna1 INNER JOIN vbrk ON kna1~kunnr EQ vbrk~kunrg
INNER JOIN vbak ON kna1~kunnr EQ vbak~kunnr
INNER JOIN vbrp ON vbrk~vbeln EQ vbrp~vbeln
INTO i_stocktab
WHERE vbrp~werks IN s_werks
AND vbak~auart IN s_auart.
APPEND i_stocktab.
ENDSELECT.
*DATA tb_alv TYPE i_stocktab WITH HEADER LINE.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM build_event.
PERFORM build_print.
PERFORM calc_total.
PERFORM display_alv_report.
*---------------------------------------------------------------------*
* FORM build_fieldcatalog *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM build_fieldcatalog.
w_cnt = 1.
it_fieldcat-fieldname = 'KUNAG'.
it_fieldcat-seltext_m = 'Soldtp'.
it_fieldcat-emphasize = 'X'.
it_fieldcat-key = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'NAME1'.
it_fieldcat-seltext_m = 'Name'.
it_fieldcat-emphasize = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'ORT01'.
it_fieldcat-seltext_m = 'City'.
it_fieldcat-col_pos = w_cnt.
it_fieldcat-emphasize = 'X'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
* w_cnt = w_cnt + 1.
* it_fieldcat-fieldname = 'INC01'.
* it_fieldcat-seltext_m = 'Incoterms'.
* it_fieldcat-emphasize = 'X'.
* APPEND it_fieldcat TO it_fieldcat.
* CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'VKGRP'.
it_fieldcat-seltext_m = 'Sales Group'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
it_fieldcat-fieldname = 'FKIMG'.
it_fieldcat-seltext_m = 'Invoiced Qty'.
it_fieldcat-emphasize = 'X'.
it_fieldcat-ref_tabname = 'VBRP' .
it_fieldcat-ref_fieldname = 'FKIMG' .
it_fieldcat-do_sum = 'X' .
* *it_fieldcat-do_sum = 'x'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
w_cnt = w_cnt + 1.
clear it_fieldcat .
it_fieldcat-fieldname = 'NETWR'.
it_fieldcat-seltext_m = 'Invoiced Value'.
it_fieldcat-emphasize = 'X'.
it_fieldcat-ref_tabname = 'VBRP' .
it_fieldcat-ref_fieldname = 'NETWR' .
it_fieldcat-do_sum = 'X' .
* it_fieldcat-do_sum = 'x'.
APPEND it_fieldcat TO it_fieldcat.
CLEAR it_fieldcat.
ENDFORM.
*---------------------------------------------------------------------*
* FORM build_layout *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM build_layout.
gr_layout-no_input = 'X'.
gr_layout-colwidth_optimize = 'X'.
gr_layout-totals_text = 'Totals: '(201).
gr_layout-detail_popup = 'X'.
ENDFORM.
*---------------------------------------------------------------------*
* FORM build_event *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM build_event.
DATA i_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = gr_events[].
READ TABLE gr_events WITH KEY name = slis_ev_user_command
INTO i_event.
IF sy-subrc = 0.
MOVE gr_user TO i_event-form.
APPEND i_event TO gr_events.
ENDIF.
ENDFORM.
*FORM calc_total.
* LOOP AT it_fieldcat into wa_fieldcat
* WHERE fieldname EQ 'FKIMG' OR
* fieldname EQ 'NETWR'.
* wa_fieldcat-do_sum = 'X'.
* wa_fieldcat-datatype = 'QUAT'.
* modify it_fieldcat from wa_fieldcat.
* ENDLOOP.
*ENDFORM.
FORM build_print.
gr_print-reserve_lines = '2'.
gr_print-no_coverpage = 'X'.
ENDFORM.
*---------------------------------------------------------------------*
* FORM calc_total *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM calc_total.
DATA: total TYPE REF TO data,
subtotal1 TYPE REF TO data.
* FIELD-SYMBOLS <fkimg> LIKE sflight.
* FIELD-SYMBOLS <netwr> LIKE sflight.
* CALL METHOD grid1-> get_subtotals
* IMPORTING
* ep_collect00 = subtotal
* ep_collect01 = total.
* ASSIGN total TO <fkimg>.
* ASSIGN total TO <netwr>.
ENDFORM.
*& FUNCTION ALV DISPLAY
FORM display_alv_report.
gr_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gr_repid
i_callback_user_command = slis_ev_user_command
i_callback_top_of_page = 'TOP-OF-PAGE' " see FORM
is_layout = gr_layout
it_fieldcat = it_fieldcat[]
it_special_groups = gr_tab_group
i_save = 'X'
it_events = gr_events
is_print = gr_print
TABLES
t_outtab = i_stocktab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ENDFORM.
*---------------------------------------------------------------------*
* FORM top-of-page *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM top-of-page.
*ALV Header deaclarations
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
t_line LIKE wa_header-info,
ld_lines TYPE i,
ld_linesc TYPE c.
*Title
wa_header-typ = 'H'.
wa_header-info = 'Report for daily Stock Returns'.
APPEND wa_header TO t_header.
CLEAR wa_header.
*Total No. Records Selected
DESCRIBE TABLE i_stocktab LINES ld_lines.
ld_linesc = ld_lines.
CONCATENATE 'Total No. of Records Selected:' ld_linesc
INTO t_line SEPARATED BY space.
wa_header-typ = 'A'.
wa_header-info = t_line.
APPEND wa_header TO t_header.
CLEAR: wa_header, t_line.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
ENDFORM.