2007 Oct 25 11:10 AM
Dear All
How to Write heading in ALV report
Thanks and Regards
Suresh
Dear All
How to Write heading in ALV report
Thanks and Regards
Suresh
2007 Oct 25 11:14 AM
Hi suresh
use the following code..
first pass the form name to it_event table and then write that form.
*build events for ALV to handle user command
PERFORM build_event USING v_alv_events.
FORM build_event USING p_v_alv_events TYPE slis_t_event.
DATA: t_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = p_v_alv_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.
CLEAR t_event.
READ TABLE p_v_alv_events
WITH KEY name = slis_ev_top_of_page
INTO t_event.
IF sy-subrc = 0.
MOVE c_top_of_page TO t_event-form.
MODIFY p_v_alv_events FROM t_event INDEX sy-tabix TRANSPORTING form.
ENDIF.
HEADER FOR ALV
PERFORM build_comment CHANGING v_header.
FORM build_comment CHANGING rs_header TYPE slis_t_listheader.
*DATA DECLARATION**
DATA: htext TYPE slis_listheader.
**ASSIGNING VALUES**
*Heading
CLEAR htext.
htext-typ = 'H'. "H = Header,S = Selection,A = Action
FORMAT COLOR 3.
htext-info = text-025.
APPEND htext TO rs_header.
Date
CLEAR htext.
htext-typ = 'S'. "H = Header,S = Selection,A = Action
FORMAT COLOR 3.
htext-key = text-026.
WRITE sy-datum TO htext-info.
APPEND htext TO rs_header.
ENDFORM. " build_comment
2007 Oct 25 11:14 AM
Hi,
Use this code
&----
*& Form sub_top_of_page *
&----
This form is to build the Page Header *
----
FORM sub_top_of_page .
*--Local Variable
DATA : lv_title(120) TYPE c, " Title
lv_month(30) TYPE c,
lv_mont(30) TYPE c,
lv_bud(16) TYPE c.
*--Local Work Area
DATA : lwa_line TYPE slis_listheader. " Hold list header
CONCATENATE p_month 'to' s_hmonth INTO lv_month SEPARATED BY space.
IF NOT s_hmonth IS INITIAL.
lv_mont = lv_month.
ELSE.
lv_mont = p_month.
ENDIF.
*--Title Display
lwa_line-typ = 'H'. " header
lv_title = sy-title.
lwa_line-info = lv_title.
APPEND lwa_line TO it_header.
CLEAR lwa_line.
*--Month Display
lwa_line-typ = 'S'. " Item
WRITE: lv_mont TO lv_month.
lwa_line-key = text-024.
lwa_line-info = lv_month.
APPEND lwa_line TO it_header.
*--Budget Display
lwa_line-typ = 'S'. " Item
WRITE: p_bud TO lv_bud.
lwa_line-key = text-025.
lwa_line-info = lv_bud.
APPEND lwa_line TO it_header.
CLEAR: lwa_line,
lv_mont.
*--This funcation module will display the top of the page
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_header.
*--Free
FREE : it_header.
ENDFORM. "sub_top_of_page
&----
*& Form sub_create_events *
&----
This form will display the ALV Events *
----
FORM sub_create_events .
*--Local Work Area
DATA: lwa_event TYPE slis_alv_event. "Work area for Events
*--Call Function to display the events for the ALV
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 1
IMPORTING
et_events = it_events.
*--Sort by Name
SORT it_events BY name.
*--Clear
CLEAR lwa_event.
READ TABLE it_events INTO lwa_event WITH KEY name =
slis_ev_top_of_page
BINARY SEARCH.
IF sy-subrc = 0.
MOVE c_top_of_page TO lwa_event-form.
MODIFY it_events FROM lwa_event TRANSPORTING form WHERE
name = slis_ev_top_of_page.
ENDIF.
*--Clear
CLEAR : lwa_event.
ENDFORM. "sub_create_events
*--Call the function module to display the ALV report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = wa_layout
it_fieldcat = i_fieldcat
i_default = c_chk
i_save = c_save
is_variant = wa_variant
it_events = i_events
is_print = wa_print
it_sort = li_sort
TABLES
t_outtab = i_final
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.
Regards,
Prashant
2007 Oct 25 11:14 AM
hi suresh,
go through this link :
http://www.sap-img.com/abap/sample-alv-heading-in-alv.htm
reward if useful..
2007 Oct 25 11:15 AM
Hi Suresh,
*ALV Header declarations
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader.
* Title
wa_header-typ = 'H'.
wa_header-info = <report description>.
APPEND wa_header TO t_header.
CLEAR wa_header.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.<b>Reward points for helpful answers</b>
Satish
2007 Oct 25 11:16 AM
Hi suresh,
chk if this blog can help u
/people/community.user/blog/2007/05/07/alignment-of-data-in-top-of-page-in-alv-grid
2007 Oct 25 11:19 AM
Hi,
1. declare
i_events TYPE SLIS_T_EVENT WITH HEADER LINE.2. fill the event table
CONSTANTS ca_topofpage LIKE i_events-name VALUE 'TOP_OF_PAGE'.
i_events-name = ca_topofpage. "anche (SLIS_EV_TOP_OF_PAGE).
i_events-form = ca_topofpage.
append i_events.
clear i_events.3. Create a form called 'TOP_OF_PAGE' like this:
FORM top_of_page .
write 'Number is...'.
ENDFORM. " top_of_page4. Pass the event table to your alv function module
....
IT_EVENTS = i_events[]
...That's all
rgs
2007 Oct 25 3:42 PM
2007 Oct 26 11:14 AM
Hi suresh
just follow the code
FORM TOP_OF_PAGE.
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
WA_HEADER TYPE SLIS_LISTHEADER.
WA_HEADER-TYP = 'H'.
WA_HEADER-INFO = 'THIS IS MY FIRST ALV'.
APPEND WA_HEADER TO T_HEADER.
WA_HEADER-TYP = 'H'.
WA_HEADER-INFO = 'THIS IS SECOND'.
APPEND WA_HEADER TO T_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = T_HEADER
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
.
ENDFORM.
and activate " I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE' "
in function module REUSE_ALV_GRID_DISPLAY.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |