2005 Sep 29 10:20 AM
Hi all,
I want to print variable text in the top-of-page in the ALV.
Suppose, I am making customer wise sales report.
A new page is triggered when customer changes. I have done this.
I want to print customer name and code in the top of page whenever the customer changes. I have done coding for this like I have made list header which changes when the customer changes.It is working well when the user sees the report output on the screen but when he prints it , the headers are not printed.
Please give me the solution of this problem.
Thnaks and Regards
Gurpreet Singh
2005 Sep 29 10:35 AM
hi,
in the alv events add TOP-OF-PAGE and one rountine name like top_of_page
in the routine add the below code like
CLEAR WA_COMMENT.
WA_COMMENT-TYP = C_S.
WA_COMMENT-KEY = text-035.
APPEND WA_COMMENT TO ALV_COMMENT.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = ALV_COMMENT.
is this helpful for your problem
cheers,
sasi
2005 Sep 29 11:02 AM
Check that whether u
<b>handle_print_top_of_page</b>
Or else it wont work.
Sample for TOP-OF-PAGE and PRINT-TOP-OF-PAGE
***********************************************************************
* Class definition :
***********************************************************************
*---------------------------------------------------------------------*
* CLASS v_lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
CLASS v_lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_print_top_of_page FOR EVENT print_top_of_page OF
cl_gui_alv_grid,
handle_top_of_page FOR EVENT top_of_page OF
cl_gui_alv_grid.
ENDCLASS.
*---------------------------------------------------------------------*
* CLASS V_LCL_EVENT_RECEIVER IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS v_lcl_event_receiver IMPLEMENTATION.
METHOD handle_print_top_of_page.
IF sy-pagno = 1.
PERFORM top_of_page.
ENDIF.
ENDMETHOD.
METHOD handle_top_of_page.
PERFORM top_of_page.
ENDMETHOD.
ENDCLASS.
DATA: v_event_receiver TYPE REF TO v_lcl_event_receiver.
FORM top_of_page.
WRITE: text-020,
/
ENDFORM. " top_of_page
<u>In PBo of the screen</u>
DATA: v_split TYPE REF TO cl_gui_easy_splitter_container,
v_contnr_top TYPE REF TO cl_gui_container,
v_contnr_bot TYPE REF TO cl_gui_container,
v_grid_02 TYPE REF TO cl_gui_alv_grid,
v_html TYPE REF TO cl_dd_document,
v_text20(255) TYPE c,
v_text16(255) TYPE c,
FORM f9000_objects_create.
IF cl_gui_alv_grid=>offline( ) IS INITIAL.
Create a container
CREATE OBJECT o_dockingcontainer
EXPORTING
ratio = '95'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
IF sy-subrc NE 0.
MESSAGE i000 WITH text-e01."Error in creating Docking container
LEAVE LIST-PROCESSING.
ENDIF.
CREATE OBJECT v_split
EXPORTING
parent = o_dockingcontainer
* ORIENTATION = 0
sash_position = 25
with_border = 0
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
others = 3.
IF sy-subrc NE 0.
MESSAGE i000 WITH text-e01."Error in creating Docking container
LEAVE LIST-PROCESSING.
ENDIF.
* Get the containers of the splitter control
v_contnr_top = v_split->top_left_container.
v_contnr_bot = v_split->bottom_right_container.
CREATE OBJECT o_alvgrid
EXPORTING
i_parent = o_dockingcontainer.
* Create an instance of alv control
CREATE OBJECT o_alvgrid
EXPORTING i_parent = v_contnr_bot.
* Object for display of selection parameters in HTML top container
CREATE OBJECT v_html
EXPORTING
style = 'ALV_GRID'.
* Must be after the SET HANDLER for TOP_OF_PAGE and foreground only
CALL METHOD o_alvgrid->list_processing_events
EXPORTING i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = v_html.
v_text20 = text-020(summary Record counts)Any text.
CALL METHOD v_html->add_gap
EXPORTING
width = 120.
CALL METHOD v_html->add_text
EXPORTING
text = v_text20.
CALL METHOD v_html->new_line.
** Display Text-016
v_text16 = text-016.
CALL METHOD v_html->add_gap
EXPORTING
width = 1.
CALL METHOD v_html->add_text
EXPORTING
text = v_text16.
v_text16 = v_sap_recon.
CALL METHOD v_html->add_gap
EXPORTING
width = 1.
CALL METHOD v_html->add_text
EXPORTING
text = v_text16.
CALL METHOD v_html->new_line.
<b>* Display the data
CALL METHOD v_html->display_document
EXPORTING
parent = v_contnr_top.
* Handle the event
CALL METHOD o_alvgrid->list_processing_events
EXPORTING i_event_name = 'PRINT_TOP_OF_PAGE'.</b>
IN PBO while populating in the output table
FORM f9004_display_data TABLES p_report_tab
p_fieldcat.
CALL METHOD o_alvgrid->set_table_for_first_display
EXPORTING
is_variant = w_variant
i_save = c_a
is_layout = w_layout
CHANGING
it_outtab = p_report_tab[]
it_fieldcatalog = p_fieldcat[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE i000 WITH text-e06."Error in ALV report display
LEAVE LIST-PROCESSING.
ENDIF.
* Create object
IF v_event_receiver IS INITIAL.
CREATE OBJECT v_event_receiver.
ENDIF.
SET HANDLER v_event_receiver->handle_print_top_of_page FOR o_alvgrid.
<b> SET HANDLER v_event_receiver->handle_top_of_page FOR o_alvgrid</b>.
Hope this helps u.
2005 Sep 29 11:21 AM
Hi,
Chek out this code snippet:
----
CLASS v_lcl_event_receiver DEFINITION
----
CLASS v_lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
<b> handle_print_top_of_page FOR EVENT print_top_of_page OF
cl_gui_alv_grid,
handle_top_of_page FOR EVENT top_of_page OF
cl_gui_alv_grid.</b>
ENDCLASS.
----
CLASS V_LCL_EVENT_RECEIVER IMPLEMENTATION
----
CLASS v_lcl_event_receiver IMPLEMENTATION.
<b> METHOD handle_print_top_of_page.
IF sy-pagno = 1.
PERFORM top_of_page.
ENDIF.
ENDMETHOD.</b>
<b> METHOD handle_top_of_page.
PERFORM top_of_page.
ENDMETHOD.</b>
ENDCLASS.
DATA: v_event_receiver TYPE REF TO v_lcl_event_receiver.
In the main Program:
TOP-OF-PAGE.
PERFORM TOP_OF_PAGE.
Form:
&----
*& Form top_of_page
&----
Top of Page
----
FORM TOP_OF_PAGE.
PERFORM SELECTION_PAGE_PRINT.
WRITE:/5(20) V_REPNAME,
23(25) SY-REPID,
70 TEXT-011,
96 V_BR1 ,
98 XUDATE-LOW.
WRITE: 150(9) 'Page No.:', SY-PAGNO. "
ENDFORM. " top_of_page
*AD:19.08.05(END)
&----
*& Form selection_page_print
&----
print data from selection screen
----
FORM SELECTION_PAGE_PRINT.
WRITE:/5 TEXT-100. "Selection Screen Values
SKIP.
WRITE:/5 'Customer name:', p_CUST.
ENDFORM. " selection_page_print
IF SY-BATCH NE 'X'.
CREATE OBJECT V_EVENT_RECEIVER.
<b>SET HANDLER V_EVENT_RECEIVER->HANDLE_PRINT_TOP_OF_PAGE FOR O_ALVGRID.
SET HANDLER V_EVENT_RECEIVER->HANDLE_TOP_OF_PAGE FOR O_ALVGRID.</b>
ENDIF.
Best Regards,
Anjali
2005 Sep 29 12:35 PM
hi all,
I am using type-pool : slis to make ALV.
Please respond according to that.
Thanks and Regards
Gurpreet Singh