04-20-2006 10:24 AM
How to display a standard header of the displayed table in ALV list ?
04-20-2006 10:29 AM
hi,
From FM REUSE_ALV_FIELD_CATALOG_MERGE, we get the field catalog table populated. when we pass this to fm REUSE_ALV_LIST_DISPLAY, it displays the data with the column headings.
If you want to display similar to TOP-of-page, then we have to populate events table by fm REUSE_ALV_EVENTS_GET.
Regards,
Sailaja.
04-20-2006 10:29 AM
HI Banerjee,
hope you want to display the top of page ..
if it is so you can do like this..
FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
DATA: L_I_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = I_EVENTS.
READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO L_I_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_TOP_OF_PAGE TO L_I_EVENT-FORM.
APPEND L_I_EVENT TO I_EVENTS.
ENDIF.
pass this I_EVENTS to the ALV_*_DISPLAY function module..
now use
FORM TOP_OF_PAGE.
.....
* here you can write the required data..
ENDFORM.
regards
satesh
04-20-2006 10:33 AM
hi,
REPORT Z_TEST_ALV_EVENTS .
type-pools: slis.
data: x_fieldcat type slis_fieldcat_Alv,
it_fieldcat type slis_t_fieldcat_alv,
x_events type slis_alv_event,
it_events type SLIS_T_EVENT.
data: v_lines type i.
data: begin of itab occurs 0,
vbeln like vbak-vbeln,
posnr like vbap-posnr,
end of itab.
select vbeln
posnr
from vbap
up to 100 rows
into table itab.
x_events-name = 'TOP_OF_PAGE'.
x_events-form = 'TOP_OF_PAGE'.
append x_events to it_events.
clear x_events.
* call function 'REUSE_ALV_EVENTS_GET'
* EXPORTING
* I_LIST_TYPE = 0
* IMPORTING
* ET_EVENTS = IT_EVENTS
* EXCEPTIONS
* LIST_TYPE_WRONG = 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.
*
* read table it_events into x_events with key name = 'TOP_OF_PAGE'.
* if sy-subrc = 0.
* x_events-form = 'TOP_OF_PAGE'.
* modify it_events from x_events index sy-tabix transporting form .
* endif.
*
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = sy-repid
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = sy-repid
changing
ct_fieldcat = IT_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
describe table itab lines v_lines.
call function 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = 'STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
IT_EVENTS = IT_EVENTS
tables
t_outtab = ITAB[]
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.
FORM TOP_OF_PAGE.
"show your standard header using write statements.
*
ENDFORM.
Regards
vijay
04-20-2006 10:34 AM
HI Sab..,
You have to use form perform for this like normal ALV
and give your standard header to alv list which u want.
FORM TOP-OF-PAGE.
CLEAR header_alv.
header_alv_wa-info = <b>'Service Tax Report'</b>.
header_alv_wa-typ = 'H'.
APPEND header_alv_wa TO header_alv.
Regards,
Dhananjay
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = header_alv.
ENDFORM. "top_of_page
04-28-2006 8:00 AM
Hi,
The following code demonstrate the same.
TYPE-POOLS: slis.
DATA: BEGIN OF i_data OCCURS 0,
qmnum LIKE qmel-qmnum,
qmart LIKE qmel-qmart,
qmtxt LIKE qmel-qmtxt,
ws_row TYPE i,
ws_char(5) TYPE c,
chk,
END OF i_data.
DATA: report_id LIKE sy-repid.
DATA: ws_title TYPE lvc_title VALUE 'An ALV Report'.
DATA: i_layout TYPE slis_layout_alv.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv.
DATA: i_events TYPE slis_t_event.
DATA: i_header TYPE slis_t_listheader.
SELECT qmnum
qmart
qmtxt
INTO TABLE i_data
FROM qmel
WHERE qmnum <= '00030000010'.
LOOP AT i_data.
i_data-ws_row = sy-tabix.
i_data-ws_char = 'AAAAA'.
MODIFY i_data.
ENDLOOP.
report_id = sy-repid.
PERFORM f1000_layout_init CHANGING i_layout.
PERFORM f2000_fieldcat_init CHANGING i_fieldcat.
PERFORM f3000_build_header CHANGING i_header.
PERFORM f4000_events_init CHANGING i_events.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = report_id
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 = ws_title
I_GRID_SETTINGS =
is_layout = i_layout
it_fieldcat = i_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
i_save = 'A'
IS_VARIANT =
it_events = i_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
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = i_data
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.
&----
*& Form F1000_Layout_Init
&----
FORM f1000_layout_init USING i_layout TYPE slis_layout_alv.
CLEAR i_layout.
i_layout-colwidth_optimize = 'X'.
i_layout-edit = 'X'.
ENDFORM. " F1000_Layout_Init
&----
*& Form f2000_fieldcat_init
&----
FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv.
DATA: line_fieldcat TYPE slis_fieldcat_alv.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'QMNUM'. " The field name and the table
line_fieldcat-tabname = 'I_DATA'. " name are the two minimum req.
line_fieldcat-key = 'X'. " Specifies the column as a key (Blue)
line_fieldcat-seltext_m = 'Notification No.'. " Column Header
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'QMART'.
line_fieldcat-ref_tabname = 'I_DATA'.
line_fieldcat-hotspot = 'X'. " Shows the field as a hotspot.
line_fieldcat-seltext_m = 'Notif Type'.
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'QMTXT'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_m = 'Description'.
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'WS_ROW'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_m = 'Row Number'.
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'WS_CHAR'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_l = 'Test Character Field'.
line_fieldcat-datatype = 'CHAR'.
line_fieldcat-outputlen = '15'. " You can specify the width of a
APPEND line_fieldcat TO i_fieldcat. " column.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'CHK'.
line_fieldcat-tabname = 'I_DATA'.
line_fieldcat-seltext_l = 'Checkbox'.
line_fieldcat-checkbox = 'X'. " Display this field as a checkbox
line_fieldcat-edit = 'X'. " This option ensures that you can
" edit the checkbox. Else it will
" be protected.
APPEND line_fieldcat TO i_fieldcat.
ENDFORM. " f2000_fieldcat_init
&----
*& Form f3000_build_header
&----
FORM f3000_build_header USING i_header TYPE slis_t_listheader.
DATA: gs_line TYPE slis_listheader.
CLEAR gs_line.
gs_line-typ = 'H'.
gs_line-info = 'This is line of type HEADER'.
APPEND gs_line TO i_header.
CLEAR gs_line.
gs_line-typ = 'S'.
gs_line-key = 'STATUS 1'.
gs_line-info = 'This is line of type STATUS'.
APPEND gs_line TO i_header.
gs_line-key = 'STATUS 2'.
gs_line-info = 'This is also line of type STATUS'.
APPEND gs_line TO i_header.
CLEAR gs_line.
gs_line-typ = 'A'.
gs_line-info = 'This is line of type ACTION'.
APPEND gs_line TO i_header.
ENDFORM. " f3000_build_header
&----
*& Form f4000_events_init
&----
FORM f4000_events_init CHANGING i_events TYPE slis_t_event.
DATA: line_event TYPE slis_alv_event.
CLEAR line_event.
line_event-name = 'TOP_OF_PAGE'.
line_event-form = 'F4100_TOP_OF_PAGE'.
APPEND line_event TO i_events.
ENDFORM. " f3000_events_init
----
FORM F4100_TOP_OF_PAGE *
----
FORM f4100_top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_header.
ENDFORM.
Please reward for the same.
04-28-2006 5:32 PM
Hi Prakhar,
I am using the same code.
I need to make common header and footer for all the report out put(templet), for this I created one include and in that I kept some part of the code and have to
saved the output in internal table and passed this internal table to include,which is the one parameter
for REUSE_ALV_DISPLAY.But for field catlog when I am passing field catalogue table its not wworking.Can you
please suggest
04-28-2006 5:39 PM
Hi,
How have u passed the internal table to include..
Can u elaborate with ur code..
Regards,
Tanveer
Which of this are the contents of include file?
Message was edited by: Tanveer Shaikh
04-28-2006 6:01 PM
Here I am attaching the detailed code.
REPORT ZSAMPLE .
TABLES : MARAV.
type-pools : slis. "ALV Declarations
include YTEMPLET_INC.
*Data Declaration
*----
types: BEGIN OF t_marav,
matnr like marav-matnr,
maktx like marav-maktx,
matkl like marav-matkl,
ntgew like marav-ntgew,
gewei like marav-gewei,
END OF t_marav.
data: it_marav type STANDARD TABLE OF t_marav INITIAL SIZE 0,
wa_marav type t_marav,
g_start_time type sy-uzeit.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv,
x_events type slis_alv_event,
it_events type slis_t_event.
select-options:s_matnr for marav-matnr.
initialization.
*v_repid = sy-repid.
s_matnr-low = '1000'.
s_matnr-sign = 'I'.
s_matnr-option = 'EQ'.
S_matnr-high = '5000'.
append s_matnr.
************************************************************************
*Start-of-selection.
START-OF-SELECTION.
g_start_time = sy-uzeit.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report tables fieldcatalog
it_marav
using sy-repid
gd_layout
gt_events
gd_prntparams
wa_marav
.
&----
*& Form BUILD_FIELDCATALOG
&----
Build Fieldcatalog for ALV Report
----
form build_fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material number'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MAKTX'.
fieldcatalog-seltext_m = 'Material Des'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATKL'.
fieldcatalog-seltext_m = 'Material group '.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NTGEW'.
fieldcatalog-seltext_m = 'Net weight'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'GEWEI'.
fieldcatalog-seltext_m = 'weight unit '.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
&----
*& Form BUILD_LAYOUT
&----
Build layout for ALV grid report
----
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
endform. " BUILD_LAYOUT
&----
*& Form DATA_RETRIEVAL
&----
Retrieve data form EKPO table and populate itab it_ekko
----
form data_retrieval.
select matnr maktx matkl ntgew gewei
up to 10 rows
from marav
into table it_marav.
endform. " DATA_RETRIEVAL
----
FORM USER_COMMAND *
----
--> R_UCOMM *
--> RS_SELFIELD *
----
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
ENDFORM. "user_command
&----
*& Form BUILD_EVENTS
&----
Build events table
----
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
&----
*& Form BUILD_PRINT_PARAMS
&----
Setup print parameters
----
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
&----
*& Form END_OF_PAGE
&----
form end_of_page.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/'User :' , sy-uname.
write:/40 'Page:', sy-pagno .
endform. "end_of_page
&----
*& Form END_OF_LIST
&----
form end_of_list.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c,
v_time(10) type c.
skip.
concatenate sy-uzeit(2) '.'
sy-uzeit+2(2) '.'
sy-uzeit+4(2) INTO v_time.
write:/'User :' ,8 sy-uname, 30 'Report ID :' , 44
sy-repid ,69 'Page:',75 sy-pagno .
type-pools : slis.
*ALV data declarations
data: t_fieldcatalog type slis_t_fieldcat_alv with header line,
p_gd_tab_group type slis_t_sp_group_alv,
p_gd_layout type slis_layout_alv,
p_gd_repid like sy-repid,
p_gt_events type slis_t_event,
p_gd_prntparams type slis_print_alv,
p_x_events type slis_alv_event,
p_it_events type slis_t_event.
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
v_logo(30) type c,
ld_lines type i,
ld_linesc(10) type c,
v_data(15) type c,
v_time(15) type c,
v_title(20) type c.
data: v_space(2) value ' ',
v_head(20) value ' ',
v_head1(10) value ' '.
data: i_int_tab type standard table of rsparams initial size 0.
v_logo = 'ABAP report'.
format color COL_GROUP.
format intensified input off.
print-control font 2 lpi 5.
write:/25 v_logo color 7,
/22 sy-title .
write:/ 'Date :', sy-datum, 62 'Run Time :', sy-uzeit.
04-30-2006 8:31 PM
Hi Group,
Can any body suggest me how to show common Header and footer for all the report output.Here on the top I attahced code