‎2006 Nov 09 5:55 AM
Hi,
I have a requirement were i need to use ALV OOP for a screen which has to have multiple containers. I need to display multiple ALV control in one screen.
I cannot use module pool. So please help me with the some examples of ALV OOP with containers.
Thanks
Ram
‎2006 Nov 09 5:58 AM
‎2006 Nov 09 1:57 PM
Hi Prabha,
The SAP Report program <b>BALVBT01</b> provides an example of displaying multiple ALV LIST reports on one page.
Regards,
Abdul
P.S: Mark Points, if useful!
‎2006 Nov 09 2:05 PM
HI Prabha,
refer sample code below:
----
ALV Data declaration
----
DATA : o_alvgrid TYPE REF TO cl_gui_alv_grid,
o_alvgrid1 TYPE REF TO cl_gui_alv_grid,
o_split TYPE REF TO cl_gui_easy_splitter_container,
o_split1 TYPE REF TO cl_gui_easy_splitter_container,
o_dockingcontainer TYPE REF TO cl_gui_docking_container,
o_container_top TYPE REF TO cl_gui_container,
o_container_bot TYPE REF TO cl_gui_container,
o_container_btop TYPE REF TO cl_gui_container,
o_container_bbot TYPE REF TO cl_gui_container,
o_html TYPE REF TO cl_dd_document,
ok_code LIKE sy-ucomm,
i_fieldcat TYPE lvc_t_fcat,
i_fieldcat1 TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat,
wa_layout TYPE lvc_s_layo,
w_variant TYPE disvariant. " Variant.
&----
Define the objects for the ALV Grid
&----
METHOD create_object.
IF cl_gui_alv_grid=>offline( ) IS INITIAL.
*-- Create 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-007. " Error in object creation
LEAVE LIST-PROCESSING.
ENDIF.
*--Create Splitter Container
CREATE OBJECT o_split
EXPORTING
parent = o_dockingcontainer
sash_position = 12
with_border = 0
EXCEPTIONS
cntl_error = 1
cntl_system_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.
*--Get the containers of the splitter control
o_container_top = o_split->top_left_container.
o_container_bot = o_split->bottom_right_container.
ENDIF.
IF i_error IS NOT INITIAL.
*--create splitter container
CREATE OBJECT o_split
EXPORTING
parent = o_container_bot
sash_position = 50
with_border = 0
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
o_container_btop = o_split->top_left_container.
o_container_bbot = o_split->bottom_right_container.
ENDIF.
IF i_error IS NOT INITIAL.
CREATE OBJECT o_alvgrid
EXPORTING
i_parent = o_container_btop.
CREATE OBJECT o_alvgrid1
EXPORTING
i_parent = o_container_bbot.
ELSE.
CREATE OBJECT o_alvgrid
EXPORTING
i_parent = o_container_bot.
ENDIF.
CALL METHOD o_extract->top_of_page.
ENDMETHOD. "create_object
METHOD display_list.
IF i_error[] IS NOT INITIAL.
*-- Display Report
CALL METHOD o_alvgrid->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = wa_layout
CHANGING
it_outtab = i_display
it_fieldcatalog = i_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE i000(zo_spa) WITH text-028. " Error in Displaying
LEAVE LIST-PROCESSING.
ENDIF.
*-- Display Report
CALL METHOD o_alvgrid1->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = wa_layout
CHANGING
it_outtab = i_error
it_fieldcatalog = i_fieldcat1
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE i000(zo_spa) WITH text-028. " Error in Displaying
LEAVE LIST-PROCESSING.
ENDIF.
ELSE.
*-- Display Report
CALL METHOD o_alvgrid->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = wa_layout
CHANGING
it_outtab = i_display
it_fieldcatalog = i_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE i000(zo_spa) WITH text-028. " Error in Displaying
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
**-- Create Event object
CREATE OBJECT o_extract.
SET HANDLER o_extract->handle_print_top_of_page FOR o_alvgrid.
ENDMETHOD. "display_list
&----
Define the top of page display
&----
METHOD top_of_page.
DATA: lws_text TYPE sdydo_text_element,
lws_text1 TYPE sdydo_text_element.
DATA: cnt_error TYPE char4.
IF cl_gui_alv_grid=>offline( ) IS INITIAL.
*-- Object for HTML top container
CREATE OBJECT o_html
EXPORTING style = 'ALV_GRID'
background_color = 35.
*-- Top of Page
CALL METHOD o_alvgrid->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = o_html.
*-- Total Sum of Open Items Value
CALL METHOD o_html->add_text
EXPORTING
text = text-008
sap_emphasis = text-009.
*
CALL METHOD o_html->add_gap
EXPORTING
width = 8.
**-- Total Sum of Open Items Value
lws_text = cnt_total.
CALL METHOD o_html->add_text
EXPORTING
text = lws_text
sap_emphasis = text-009.
CLEAR lws_text.
CALL METHOD o_html->new_line
EXPORTING
repeat = 1.
Total Error Values
DESCRIBE TABLE i_error LINES cnt_error.
*-- Total Sum of Open Items Value
CALL METHOD o_html->add_text
EXPORTING
text = text-015
sap_emphasis = text-009.
*
CALL METHOD o_html->add_gap
EXPORTING
width = 8.
**-- Total Sum of Open Items Value
lws_text1 = cnt_error.
CALL METHOD o_html->add_text
EXPORTING
text = lws_text1
sap_emphasis = text-009.
CLEAR lws_text.
*-- Display Report Header
CALL METHOD o_html->display_document
EXPORTING
parent = o_container_top.
ENDIF.
ENDMETHOD. "top_of_page
Reward points if this Helps.
Manish