2005 May 14 1:26 AM
I have created two custom controls on the Screen.
My requirement is That in one of the Custom Controls I want to diplay an ALV report and in other a Text rerieved from STANDARD TEXT.
Is it possible if yes how.
I am using object oriented approach to develop ALV. SO plz let me know in that methodolgy.
2005 May 14 6:08 AM
yes it is possible.
if we have to answer your question of <b>how</b>.
for ALV you have to use CL_GUI_ALV_GRID and for showing the text you can use CL_GUI_TEXTEDIT or CL_GUI_BTFEDITOR.
Regards
Raja
2005 May 16 8:58 AM
Hi,
This can be done .
Its very simple create two containers in the screen painter. See this sample code using custom container.
START-OF-SELECTION.
**----
Begin of process logic
**----
CALL SCREEN '0100'.
END-OF-SELECTION.
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS01'.
SET TITLEBAR 'SALESTTL'.
*----
A L V G R I D
*----
IF o_grid_container IS INITIAL.
CREATE OBJECT o_grid_container
EXPORTING
container_name = 'CCONTAINER1'.
CREATE OBJECT o_grid
EXPORTING
i_appl_events = 'X'
i_parent = o_grid_container.
*----
FOR first A L V G R I D
*----
PERFORM set_grid_field_catalog
CHANGING i_grid_fcat.
PERFORM modify_grid_fcat_predisplay
CHANGING i_grid_fcat.
PERFORM set_grid_layout_set
CHANGING struct_grid_lset.
PERFORM sort_outtable CHANGING i_sort_fcat.
PERFORM populate_grid_data TABLES i_grid_outs i_grid_outs_pro.
SORT i_grid_outs BY year month.
CALL METHOD o_grid->set_table_for_first_display
EXPORTING
i_bypassing_buffer = space
is_variant = ws_f_grid_disvar
i_save = ws_c_grid_save
is_layout = struct_grid_lset
CHANGING
it_outtab = i_grid_outs[]
it_fieldcatalog = i_grid_fcat[]
it_sort = i_sort_fcat. " Period
ENDIF.
IF o_grid1_container IS INITIAL.
CREATE OBJECT o_grid1_container
EXPORTING
container_name = 'CCONTAINER2'.
CREATE OBJECT o_grid1
EXPORTING
i_appl_events = 'X'
i_parent = o_grid1_container.
-----------------------------------------------------
FOR SECOND ALV GRID
-----------------------------------------------------
PERFORM set_grid1_field_catalog
CHANGING i_grid1_fcat.
PERFORM modify_grid1_fcat_predisplay
CHANGING i_grid1_fcat.
PERFORM set_grid1_layout_set
CHANGING struct_grid1_lset.
PERFORM sort_outtable1 CHANGING i_sort_fcat1.
PERFORM populate_grid1_data TABLES i_grid1_outs i_grid1_outs_pro.
SORT i_grid1_outs BY year month.
CALL METHOD o_grid1->set_table_for_first_display
EXPORTING
i_bypassing_buffer = space
is_variant = ws_f_grid_disvar
i_save = ws_c_grid_save
is_layout = struct_grid1_lset
CHANGING
it_outtab = i_grid1_outs[]
it_fieldcatalog = i_grid1_fcat[]
it_sort = i_sort_fcat1. " Period
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
MODULE user_command_0100 INPUT.
*----
As the events are registered as application events, control is first
passed to the program's PAI. The call 'cl_gui_cfw=>dispatch' will
forward control to ABAP object event handling and the appropriate
event handler will be called (if present). This allows the user to
selectively process events.
*----
DATA: i_return_code TYPE i .
CALL METHOD cl_gui_cfw=>dispatch
IMPORTING return_code = i_return_code.
save_ok = ok_code.
CASE save_ok.
WHEN 'BACK' OR 'END' OR 'CANC'.
PERFORM exit_program.
ENDCASE.
CLEAR save_ok.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Form EXIT_PROGRAM
&----
text
----
FORM exit_program.
CALL METHOD o_grid_container->free.
CALL METHOD o_grid1_container->free.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
Error in FLush
ENDIF.
LEAVE TO SCREEN 0.
ENDFORM. " EXIT_PROGRAM
If u want get more idea revert back to me.
Thanks & Regards,
Judith.
2005 May 14 10:35 AM
Hi Umang,
u can refer to this sample code :
create two custom controls on the screen 'CONTROL_AREA1' and 'CONTROL_AREA2'.
DATA : ref_control1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
ref_control2 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
ref_alv TYPE REF TO CL_GUI_ALV_GRID,
ref_textedit TYPE REF TO CL_GUI_TEXTEDIT.
CREATE OBJECT ref_control1
EXPORTING
container_name = 'CONTROL_AREA1'.
CREATE OBJECT ref_control2
EXPORTING
container_name = 'CONTROL_AREA2'.
CREATE OBJECET ref_alv
EXPORTING
i_parent = ref_control1.
CREATE OBJECET ref_textedit
EXPORTING
i_parent = ref_control2.
Now you can work with the alv and tree controls created.
Thanks and Regards,
Kiran.
2005 May 16 8:27 AM
HI Kiran,
Thanks for the respons and the code but i still nedd some more Help.
I need to dispaly the standard text which i have created in transaction SO10 in one of the ALV containers.
I dont know which class to use and how to use its methos i am new to object orientation methos so you may find some basic question from me but plz help.
I specefically need to display standard text.
Umang
2005 May 16 8:43 AM
Hi Umang,
Do you mean that you want to display the standard text in the Text-Edit control ?
It cannot be displayed in the ALV Grid, which is primarily used for displaying <i>structured</i> data.
Regards,
Anand Mandalika.
2005 May 18 5:20 AM
Hi,
Can try this out,
CLASS LCL_EVENT_RECEIVER DEFINITION DEFERRED.
o_eventreceiver TYPE REF TO lcl_event_receiver,
v_split1 TYPE REF TO <b>cl_gui_easy_splitter_container</b>,
v_grid type ref to cl_gui_alv_grid,
v_html1 type ref to cl_dd_document,
v_contnr_top1 TYPE REF TO cl_gui_container,
v_contnr_bot1 TYPE REF TO cl_gui_container,
flg_no_hits,
----
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</b> of
cl_gui_alv_grid,
<b>handle_top_of_page for event top_of_page of</b>
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.
form top_of_page.
*data: flg_no_of_hits.
data: lv_tot_vendors(10) type n,
lv_text(10) type c.
*flg_no_hits = c_x.
describe table i_total_tab lines lv_tot_vendors.
move lv_tot_vendors to lv_text.
pack lv_text to lv_text.
write: text-017, lv_text.
endform. " top_of_page
data: v_event_receiver1 type ref to v_lcl_event_receiver,
.
MODULE main_tab_active_tab_set OUTPUT.
IF v_event_receiver1 IS INITIAL.
CREATE OBJECT v_event_receiver1.
SET HANDLER v_event_receiver1->handle_print_top_of_page FOR
o_alvgrid1.
SET HANDLER v_event_receiver1->handle_top_of_page FOR
o_alvgrid1.
ENDIF.
In form FORM f9000_objects_create.
<b>**Create the splitter control</b>
CREATE OBJECT v_split1
EXPORTING
parent = custom_container1
sash_position = 12
with_border = 0
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
others = 3.
<b><b>*Get the containers of the splitter control</b></b>
v_contnr_top1 = v_split1->top_left_container.
v_contnr_bot1 = v_split1->bottom_right_container.
<b>* Create an instance of alv control</b>
CREATE OBJECT o_alvgrid1
EXPORTING i_parent = v_contnr_bot1.
<b>* Object for display of selection parameters in HTML top container</b>
CREATE OBJECT v_html1 EXPORTING style = 'ALV_GRID'.
<b>* Must be after the SET HANDLER for TOP_OF_PAGE and foreground only</b>
CALL METHOD o_alvgrid1->list_processing_events
EXPORTING i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = v_html1.
describe table i_total_tab lines lv_tot_vendors.
move lv_tot_vendors to lv_text1.
pack lv_text1 to lv_text1.
lv_text = text-017.
CALL METHOD v_html1->add_text
EXPORTING
text = lv_text.
CALL METHOD v_html1->add_gap
EXPORTING
width = 10.
CALL METHOD v_html1->add_text
EXPORTING
text = lv_text1.
CALL METHOD v_html1->new_line.
Display the data
CALL METHOD v_html1->display_document
EXPORTING
parent = v_contnr_top1.
Handle the event
CALL METHOD o_alvgrid1->list_processing_events
EXPORTING i_event_name = 'PRINT_TOP_OF_PAGE'.
CREATE OBJECT custom_container2
EXPORTING
container_name = cont_for_cognos2
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
Thanks & Regards,
Judith.