‎2007 Jun 13 6:44 AM
Hi friends,
I want to display some information in my ALV header, can you please tell me how to display that information.
Regards,
Line
‎2007 Jun 13 6:46 AM
Hi Line,
Chk my blog
/people/community.user/blog/2007/05/07/alignment-of-data-in-top-of-page-in-alv-grid
‎2007 Jun 13 6:46 AM
Hi,
This is an excellent blog on displaying data in ALV header.
/people/ravishankar.rajan/blog/2007/01/05/using-the-document-class-to-display-the-contents-of-an-internal-table
/people/community.user/blog/2006/11/26/alv-fast-display-class
Best regards,
Prashant
‎2007 Jun 13 6:48 AM
hi
u can use..reuse_alv_commentary_write..FM
check these....
http://www.sapfans.com/forums/viewtopic.php?t=58775
‎2007 Jun 13 6:50 AM
hi,
we are having a FM to display header information....... on top of alv.
<b>REUSE_ALV_COMMENTARY_WRITE</b> is the FM used to display the header info for ALV.
List header information is output according to its type. The output information is put in an internal table. Output attributes are assigned to each line via the TYP field.
This module outputs formatted simple header information at TOP-OF-PAGE.
Example
List <-- Type 'H'
Currency DEM Controlling area currency <-- Type 'S'
Material FGS_TEST Test material <-- Type 'S'
Action info <-- Type 'A'
-
Column headers -
-
List -
reward points if helpful,
Regard's
Raghunath.S
‎2007 Jun 13 6:51 AM
Hi Line ,
With reference to your previous post , you can have an header for an alv , of a max of 255 chars , but for this the ALV needs to be implemented using ABAP Objects.
Regards
Arun
‎2007 Jun 13 6:51 AM
*DATA DECLARATION
*Declaration for ALV
DATA : g_custom_container1 TYPE REF TO cl_gui_custom_container,
grid1 TYPE REF TO cl_gui_alv_grid,
it_cat TYPE lvc_t_fcat,
wa_cat TYPE lvc_s_fcat,
g_repid LIKE sy-repid,
event_receiver TYPE REF TO lcl_event_receiver,
l_conv_lifnr(20) TYPE c, " Converted Vendor Number
gt_sort TYPE table of LVC_S_SORT,
gs_sort TYPE slis_t_sortinfo_alv.
gs_sort like line of gt_sort,
gt_toolbar TYPE ui_functions,
gs_toolbar TYPE ui_func.
DATA:
gt_events TYPE slis_t_event,
gt_list_top_of_page TYPE slis_t_listheader,
g_status_set TYPE slis_formname VALUE 'PF_STATUS_SET',
g_user_command TYPE slis_formname VALUE 'USER_COMMAND',
g_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',
g_top_of_list TYPE slis_formname VALUE 'TOP_OF_LIST',
g_end_of_list TYPE slis_formname VALUE 'END_OF_LIST'.
DATA: gs_layout TYPE slis_layout_alv.
*Declaration for ALV Header
DATA:
Reference to document
dg_dyndoc_id TYPE REF TO cl_dd_document,
dg_dyndoc_id1 TYPE REF TO cl_dd_document, "a++
Reference to split container
dg_splitter TYPE REF TO cl_gui_splitter_container,
dg_splitter1 TYPE REF TO cl_gui_splitter_container, "a++
Reference to grid container
dg_parent_grid TYPE REF TO cl_gui_container,
Reference to html container
dg_html_cntrl TYPE REF TO cl_gui_html_viewer,
dg_html_cntrl1 TYPE REF TO cl_gui_html_viewer, "a++
Reference to html container
dg_parent_html TYPE REF TO cl_gui_container,
dg_parent_html1 TYPE REF TO cl_gui_container, "a++
dg_parent_html2 TYPE REF TO cl_gui_container. "a++
****************************************************************
LOCAL CLASSES: Definition
****************************************************************
*===============================================================
class lcl_event_receiver: local class to
define and handle own functions.
*
Definition:
~~~~~~~~~~~
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
For ALV Header Display
top_of_page FOR EVENT top_of_page "event handler
OF cl_gui_alv_grid
IMPORTING e_dyndoc_id.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
****************************************************************
LOCAL CLASSES: Implementation
****************************************************************
*===============================================================
class lcl_event_receiver (Implementation)
*
*
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
METHOD top_of_page. "implementation
Top-of-page event
PERFORM event_top_of_page USING dg_dyndoc_id.
ENDMETHOD. "top_of_page
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*
lcl_event_receiver (Implementation)
*===================================================================
*
lcl_event_receiver (Definition)
*==========================================================
*for creatin ALV Grid
IF g_custom_container1 IS INITIAL.
CREATE OBJECT g_custom_container1
EXPORTING container_name = 'ALV_REPORT'.
Create TOP-Document
CREATE OBJECT dg_dyndoc_id
EXPORTING style = 'ALV_GRID'.
Create Splitter for custom_container
CREATE OBJECT dg_splitter
EXPORTING parent = g_custom_container1
rows = 2
columns = 1.
Assigning the html container as parent container to 1st split
CALL METHOD dg_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = dg_parent_html.
Assigning the grid container as parent container to 2nd split
CALL METHOD dg_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = dg_parent_grid.
Setting the height of 1st split
CALL METHOD dg_splitter->set_row_height
EXPORTING
id = 1
height = 15.
Creating the grid object.
CREATE OBJECT grid1
EXPORTING i_parent = dg_parent_grid.
Registering the grid events
CALL METHOD grid1->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
Creating the event receiver for handling the grid eevnts.
CREATE OBJECT event_receiver.
Setting the events for event receiver object
SET HANDLER event_receiver->top_of_page FOR grid1.
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid1.
Setting the grid for first display
CALL METHOD grid1->set_table_for_first_display
EXPORTING
it_toolbar_excluding = gt_toolbar
CHANGING
it_outtab = it_result[]
it_fieldcatalog = it_cat[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Initializing document
CALL METHOD dg_dyndoc_id->initialize_document.
Processing events
CALL METHOD grid1->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = dg_dyndoc_id.
endif
&----
*& Form EVENT_TOP_OF_PAGE
&----
text
----
-->P_DG_DYNDOC_ID text
----
FORM event_top_of_page USING dg_dyndoc_id TYPE REF TO cl_dd_document.
DATA : dl_text(255) TYPE c. "Text
Create TOP-Document
CREATE OBJECT dg_dyndoc_id1
EXPORTING style = 'ALV_GRID'.
CREATE OBJECT dg_splitter1
EXPORTING parent = dg_parent_html
rows = 1
columns = 2.
CALL METHOD dg_splitter1->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = dg_parent_html1.
CALL METHOD dg_splitter1->set_border
EXPORTING
border = space.
CALL METHOD dg_splitter1->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = dg_parent_html2.
Populating header to top-of-page
CALL METHOD dg_dyndoc_id->add_text
EXPORTING
text = 'Primary MTO'
sap_style = cl_dd_area=>heading.
Initializing document
CALL METHOD dg_dyndoc_id1->initialize_document.
Populating header to top-of-page
CALL METHOD dg_dyndoc_id1->add_text
EXPORTING
text = 'Secondary MTO'
sap_style = cl_dd_area=>heading.
DATA : dl_length TYPE i, " Length
dl_background_id TYPE sdydo_key VALUE space. " Background_id
Creating html control
IF dg_html_cntrl IS INITIAL.
CREATE OBJECT dg_html_cntrl
EXPORTING
parent = dg_parent_html1.
ENDIF.
----------------------------------------------------------------
Creating html control
IF dg_html_cntrl1 IS INITIAL.
CREATE OBJECT dg_html_cntrl1
EXPORTING
parent = dg_parent_html2.
ENDIF.
----------------------------------------------------------------
Reuse_alv_grid_commentary_set
CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
EXPORTING
document = dg_dyndoc_id
bottom = space
IMPORTING
length = dl_length.
Get TOP->HTML_TABLE ready
CALL METHOD dg_dyndoc_id->merge_document.
Set wallpaper
CALL METHOD dg_dyndoc_id->set_document_background
EXPORTING
picture_id = dl_background_id.
Connect TOP document to HTML-Control
dg_dyndoc_id->html_control = dg_html_cntrl.
Display TOP document
CALL METHOD dg_dyndoc_id->display_document
EXPORTING
reuse_control = 'X'
parent = dg_parent_html1
EXCEPTIONS
html_display_error = 1.
IF sy-subrc NE 0.
MESSAGE i000(38) WITH 'Error in displaying top-of-page'(036).
ENDIF.
-----------------------------------------------------------------------
Reuse_alv_grid_commentary_set
CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
EXPORTING
document = dg_dyndoc_id1
bottom = space
IMPORTING
length = dl_length.
Get TOP->HTML_TABLE ready
CALL METHOD dg_dyndoc_id1->merge_document.
Set wallpaper
CALL METHOD dg_dyndoc_id1->set_document_background
EXPORTING
picture_id = dl_background_id.
Connect TOP document to HTML-Control
dg_dyndoc_id1->html_control = dg_html_cntrl1.
Display TOP document
CALL METHOD dg_dyndoc_id1->display_document
EXPORTING
reuse_control = 'X'
parent = dg_parent_html2
EXCEPTIONS
html_display_error = 1.
IF sy-subrc NE 0.
MESSAGE i000(38) WITH 'Error in displaying top-of-page'(036).
ENDIF.
-----------------------------------------------------------------------
ENDFORM. " EVENT_TOP_OF_PAGE
refre to this code.............
‎2007 Jun 13 6:51 AM
hi,
Chk this link.
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_rephead.htm
Code is there
Rgds
Anversha
‎2007 Jun 13 6:54 AM
Hi Line,
you can use the function module
REUSE_ALV_COMMENTARY_WRITE
for populating header details and logo.
Regards,
Ravi
‎2007 Jun 13 6:55 AM
hai
u can do it like this
*SELECT-OPTIONS As-Date FOR zchklisth-erdat DEFAULT sy-datum.
START-OF-SELECTION.
DATA test_date TYPE string.
DATA test_date1 TYPE string.
DATA :sp_day TYPE string,
sp_month TYPE string,
sp_year TYPE string,
sp_day1 TYPE string,
sp_month1 TYPE string,
sp_year1 TYPE string,
test_date2 TYPE string,
test_date3 TYPE string.
test_title = 'heading '. " gv the heading
test_date = pr_peri-low. " gv the date or any other info
test_date3 = pr_peri-high.
*
test_date1 = pr_plant-low.
test_date2 = pr_plant-high.
CONCATENATE test_title ''test_date '' test_date3 ''
*CONCATENATE test_title ' 'test_date '' test_date3 ''
test_date1 '' test_date2 INTO " finally concatanate all
test_title1
SEPARATED BY space.
<b>OR</b>
form build_comment using p_heading type slis_t_listheader.
data: hline type slis_listheader,
text(60) type c,
sep(20) type c.
clear: hline, text.
hline-typ = 'H'.
write: text-101 to text+23.
hline-info = text.
append hline to p_heading.
clear text.
write: 'User: ' to text,
sy-uname to text+6,
'Date: ' to text+25,
sy-datum to text+31,
'Page: ' to text+50,
sy-pagno to text+56.
hline-info = text.
append hline to p_heading.
endform.
<b>if u want to mor detal about the ALV c that program</b>
1-Go to SE38
2-Put BCALV*
3-Press F4
you ll find lots of example related to ALV,test them and use them accordingly.
regard
nawa
‎2007 Jun 13 6:55 AM
Hi,
pass watever u want to print in i_grid_title in reuse_alv grid display.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
i_grid_title = 'Header'.
regards,
sudha