12-09-2005 1:17 PM
Hi,
I want to prtint the Execution details with Object Oriented ALV as we did it with normal ALV using top of page event n commentry write.
12-09-2005 1:21 PM
Hi Recently There is one person posted ..
please check the thread...
or else i will give you the thread..
wait..
12-09-2005 1:23 PM
12-09-2005 1:27 PM
Hi Kishore,
Refer this link u will find the entire print structure:
open layout structure-->print structure
http://help.sap.com/saphelp_erp2005/helpdata/en/bf/3bd1369f2d280ee10000009b38f889/frameset.htm
Hope tihs helps u,
Regards,
Nagarajan.
12-09-2005 1:42 PM
Hi Nagarajan,
I dont want to print the Details , but only need display.
12-09-2005 1:43 PM
Hi Kishore,
To do that first you need to split the container
in to two containers and using dynamic doc class
you can display the data, handling Top-of-page event
in CL_GUI_ALV_GRID.
See my previous post Vijay gave the link also for
sample code.
Thanks&Regards,
Siri.
12-12-2005 12:05 PM
Hi Srilatha,
Cud u plz resend me the link r sample code!
Thanks
Kishore
Message was edited by: Kishore Enumula
12-12-2005 12:07 PM
Hi Check out the thread which i mentioned , there she explained it very well...
ask if you don't understand...
12-12-2005 12:22 PM
Hi Kishore,
See the below sample code and let me know if you have
any questions.
To display top-of-page in ALV grid using class.
I have done in my program like below, it is working
for me check this.
1)First we nee to create one loacl class to implemment
event receiver handler methods.
*----------------------------------------------------------------------*
* A L V D E C L A R A T I O N S
*----------------------------------------------------------------------*
DATA : dg_fieldcatalog TYPE lvc_t_fcat, " Field Catalog
* Reference to custom container
dg_custom_container TYPE REF TO cl_gui_custom_container,
* Reference to Grid
dg_grid1 TYPE REF TO cl_gui_alv_grid,
* Reference to Control container
dg_mycontainer TYPE scrfname VALUE 'CONTROL',
* Reference to event receiver
dg_event_receiver TYPE REF TO lcl_event_receiver,
* Reference to document
dg_dyndoc_id TYPE REF TO cl_dd_document,
* Reference to split container
dg_splitter TYPE REF TO cl_gui_splitter_container,
* 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,
* Reference to html container
dg_parent_html TYPE REF TO cl_gui_container.
*----------------------------------------------------------------------*
* C L A S S D E C L A R A T I O N S
****************************************************************
* LOCAL CLASSES: Definition
****************************************************************
*===============================================================
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
* § 2. Define a method for each print event you need.
METHODS:
top_of_page FOR EVENT top_of_page
OF cl_gui_alv_grid
IMPORTING e_dyndoc_id,
handle_top_of_page
FOR EVENT print_top_of_page OF cl_gui_alv_grid,
handle_end_of_list
FOR EVENT print_end_of_list OF cl_gui_alv_grid.
PRIVATE SECTION.
ENDCLASS.
*===============================================================
****************************************************************
* LOCAL CLASSES: Implementation
****************************************************************
*===============================================================
* class c_event_receiver (Implementation)
CLASS lcl_event_receiver IMPLEMENTATION.
*§ 3.Implement your event handler methods. Use WRITE to provide output
METHOD handle_top_of_page.
* Print Top-of-page
PERFORM print_top_of_page.
ENDMETHOD. "handle_top_of_page
*-------------------------------------------
METHOD handle_end_of_list.
* Print End-of-list
PERFORM print_end_of_list.
ENDMETHOD. "handle_end_of_list
*-------------------------------------------
METHOD top_of_page.
* Top-of-page event
PERFORM event_top_of_page USING dg_dyndoc_id.
ENDMETHOD. "top_of_page
*-----------------------------------------------------------------
ENDCLASS.
*&---------------------------------------------------------------------*
*& Form EVENT_TOP_OF_PAGE
*&---------------------------------------------------------------------*
* Top-of-page event
*----------------------------------------------------------------------*
FORM event_top_of_page USING dg_dyndoc_id TYPE REF TO cl_dd_document.
DATA : dl_text(255) TYPE c, "Text
dl_background_id TYPE sdydo_key VALUE '/EMN/EASTMAN_LOGO',
dl_type.
DATA a_logo TYPE REF TO cl_dd_area.
* Create TOP-Document
CREATE OBJECT dg_dyndoc_id
EXPORTING style = 'ALV_GRID'.
* Populating header to top-of-page
CALL METHOD dg_dyndoc_id->add_text
EXPORTING
text = 'Primary Contact Membership Lists'(036)
sap_style = cl_dd_area=>heading.
CALL METHOD dg_dyndoc_id->new_line.
CLEAR : dl_text.
* Add 'Primary Contact ID'
dl_text = text-033.
PERFORM add_text USING dl_text 'H'.
CALL METHOD dg_dyndoc_id->add_gap
EXPORTING width = 3.
CLEAR dl_text.
CONCATENATE dg_contact dg_ename INTO dl_text
SEPARATED BY space.
PERFORM add_text USING dl_text 'S'.
* Add new-line
CALL METHOD dg_dyndoc_id->new_line.
CLEAR : dl_text,dt_protc.
READ TABLE dt_protc WITH KEY pgroup = dg_protc.
* Add Protocol category
dl_text = text-034.
PERFORM add_text USING dl_text 'H'.
CALL METHOD dg_dyndoc_id->add_gap
EXPORTING width = 4.
CLEAR dl_text.
CONCATENATE dg_protc dt_protc-pgroupnam INTO dl_text
SEPARATED BY space.
PERFORM add_text USING dl_text 'S'.
* Add new-line
CALL METHOD dg_dyndoc_id->new_line.
CLEAR : dl_text,dt_prot.
READ TABLE dt_prot WITH KEY pnumber = dg_prot.
* Add Protocol Number
dl_text = text-035.
PERFORM add_text USING dl_text 'H'.
CALL METHOD dg_dyndoc_id->add_gap
EXPORTING width = 5.
CLEAR dl_text.
CONCATENATE dg_prot dt_prot-pname INTO dl_text
SEPARATED BY space.
PERFORM add_text USING dl_text 'S'.
CALL METHOD dg_dyndoc_id->vertical_split
EXPORTING split_area = dg_dyndoc_id
split_width = '70%'
IMPORTING right_area = a_logo.
CALL METHOD a_logo->add_picture
EXPORTING picture_id = '/EMN/EASTMAN_LOGO'.
CALL METHOD dg_dyndoc_id->merge_document.
CALL METHOD dg_dyndoc_id->display_document
EXPORTING reuse_control = 'X'
parent = dg_parent_html
EXCEPTIONS html_display_error = 1.
ENDFORM. " EVENT_TOP_OF_PAGE
2) In PBO do below : First you need to split the container to two containers one is to palce top-of-page and other to display grid.
IF dg_custom_container IS INITIAL.
* Create fieldcatalog for structure dt_final
PERFORM fieldcat_init USING dg_fieldcatalog[].
dt_final[] = dt_members[].
* Create a custom container control for our ALV Control
CREATE OBJECT dg_custom_container
EXPORTING
container_name = dg_mycontainer
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc <> 0.
dg_repid = sy-repid.
* Add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = dg_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'.
ENDIF.
* Create TOP-Document
CREATE OBJECT dg_dyndoc_id
EXPORTING style = 'ALV_GRID'.
* Create Splitter for custom_container
CREATE OBJECT dg_splitter
EXPORTING parent = dg_custom_container
rows = 2
columns = 1.
* Split the custom_container to two containers and move the reference
* to receiving containers g_parent_html and g_parent_grid
CALL METHOD dg_splitter->get_container EXPORTING
row = 1
column = 1
RECEIVING container = dg_parent_html.
CALL METHOD dg_splitter->get_container EXPORTING
row = 2
column = 1
RECEIVING container = dg_parent_grid.
* Set height for g_parent_html
CALL METHOD dg_splitter->set_row_height
EXPORTING
id = 1
height = 25.
* Create an instance of alv control
CREATE OBJECT dg_grid1
EXPORTING i_appl_events = c_x
i_parent = dg_parent_grid.
* Registering events
CREATE OBJECT dg_event_receiver.
SET HANDLER dg_event_receiver->top_of_page FOR dg_grid1.
SET HANDLER dg_event_receiver->handle_top_of_page FOR dg_grid1.
SET HANDLER dg_event_receiver->handle_end_of_list FOR dg_grid1.
* Grid display
CALL METHOD dg_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'TP_FINAL'
is_layout = ds_layout
CHANGING
it_fieldcatalog = dg_fieldcatalog[]
it_outtab = dt_final.
* Initializing document
CALL METHOD dg_dyndoc_id->initialize_document.
* Processing events
CALL METHOD dg_grid1->list_processing_events
EXPORTING i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = dg_dyndoc_id.
ENDIF.
* Setting focus for created grid control
CALL METHOD cl_gui_control=>set_focus EXPORTING control = dg_grid1.
Hope this will help you.
Thanks & Regards,
Siri.
<REMOVED BY MODERATOR - REQUEST OR OFFER POINTS ARE FORBIDDEN>
Edited by: Alvaro Tejada Galindo on Jan 7, 2009 4:34 PM
01-07-2009 5:57 AM
Hi,
Thanks for your posting for handling top of page event in OO ALV.
Could you please give me the logic which you have used for the PERFORM add_text USING dl_text 'S' or 'H'?
And can you explain the logic why we are mentioning 'S' or 'H' with that perform statement?
Thanks in advance if you reply ASAP.
Regards,
JK