2010 Sep 20 9:55 PM
Hi All,
I am using OO to display my ALV, what is needed to have a split on the ALV and display some data in the top half.
Here is my code:
TRY.
cl_salv_table=>factory(
IMPORTING r_salv_table = gr_alv
CHANGING t_table = gt_rpt_details ).
PERFORM f_set_header.
PERFORM f_display_settings.
gr_alv->set_screen_status(
pfstatus = 'ZSTANDARD'
report = sy-repid
set_functions = gr_alv->c_functions_all ). "set all basic ALV funtions
gr_events = gr_alv->get_event( ).
"create layout object
CREATE OBJECT gr_layout.
lr_columns = gr_alv->get_columns( ).
lr_columns->set_optimize( 'X' ).
lr_columns->set_headers_visible( 'X' ).
*
* get layout object
lo_layout = gr_alv->get_layout( ).
*
* set Layout save restriction
* 1. Set Layout Key .. Unique key identifies the Differenet ALVs
ls_key-report = sy-repid.
lo_layout->set_key( ls_key ).
* 2. Remove Save layout the restriction.
lo_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
lo_layout->set_default( abap_true ).
*
* set initial Layout
"lf_variant = 'Z/ZTEST'.
"lo_layout->set_initial_layout( lf_variant ).
CREATE OBJECT event_handler.
SET HANDLER event_handler->on_user_command FOR gr_events.
gr_functions = gr_alv->get_functions( ).
gr_functions->set_all('X').
gr_functions->set_group_filter( value = if_salv_c_bool_sap=>false ).
* Set print preview
gr_functions->set_print_preview( ).
gr_alv->get_display_settings( ).
gr_alv->display( ).
CATCH cx_salv_msg.
MESSAGE 'ALV Display Not possible'(w02) TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
Hi All,
I am using OO to display my ALV, what is needed to have a split on the ALV and display some data in the top half.
Here is my code:
TRY.
cl_salv_table=>factory(
IMPORTING r_salv_table = gr_alv
CHANGING t_table = gt_rpt_details ).
PERFORM f_set_header.
PERFORM f_display_settings.
gr_alv->set_screen_status(
pfstatus = 'ZSTANDARD'
report = sy-repid
set_functions = gr_alv->c_functions_all ). "set all basic ALV funtions
gr_events = gr_alv->get_event( ).
"create layout object
CREATE OBJECT gr_layout.
lr_columns = gr_alv->get_columns( ).
lr_columns->set_optimize( 'X' ).
lr_columns->set_headers_visible( 'X' ).
*
* get layout object
lo_layout = gr_alv->get_layout( ).
*
* set Layout save restriction
* 1. Set Layout Key .. Unique key identifies the Differenet ALVs
ls_key-report = sy-repid.
lo_layout->set_key( ls_key ).
* 2. Remove Save layout the restriction.
lo_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
lo_layout->set_default( abap_true ).
*
* set initial Layout
"lf_variant = 'Z/ZTEST'.
"lo_layout->set_initial_layout( lf_variant ).
CREATE OBJECT event_handler.
SET HANDLER event_handler->on_user_command FOR gr_events.
gr_functions = gr_alv->get_functions( ).
gr_functions->set_all('X').
gr_functions->set_group_filter( value = if_salv_c_bool_sap=>false ).
* Set print preview
gr_functions->set_print_preview( ).
gr_alv->get_display_settings( ).
gr_alv->display( ).
CATCH cx_salv_msg.
MESSAGE 'ALV Display Not possible'(w02) TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
2010 Sep 21 8:05 AM
2010 Sep 21 2:59 PM
In order to split the ALV you can use the below code for your reference
data : lr_custom_container type ref to cl_gui_custom_container,
lr_event_receiver type ref to lcl_event_receiver,
lr_splitter type ref to cl_gui_splitter_container,
lr_parent_top type ref to cl_gui_container,
lr_parent_grid type ref to cl_gui_container,
lr_dyndoc_id type ref to cl_dd_document,
lr_display type ref to cl_gui_alv_grid.
if lr_custom_container is initial.
v_container_name = " Container name which you defined in Screen
create object lr_custom_container
exporting
container_name = v_container_name
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc <> 0.
message i081 display like c_e.
"Unknown Error Occured While Displaying
leave to screen 0.
endif.
*Split the container into two parts
create object lr_splitter
exporting
parent = lr_custom_container
rows = 2
columns = 1
exceptions
cntl_error = 1
cntl_system_error = 2
others = 3.
if sy-subrc <> 0.
message i081 display like c_e.
"Unknown Error Occured While Displaying
leave to screen 0.
endif.
*Get the upper part of the container into V_PARENT_TOP
call method lr_splitter->get_container
exporting
row = 1
column = 1
receiving
container = lr_parent_top.
*Get the lower part of the container into V_PARENT_GRID
call method lr_splitter->get_container
exporting
row = 2
column = 1
receiving
container = lr_parent_grid.
*Set the height of the top part of the container
call method lr_splitter->set_row_height
exporting
id = 1
height = 28
exceptions
cntl_error = 1
cntl_system_error = 2
others = 3.
if sy-subrc <> 0.
message i081 display like c_e.
"Unknown Error Occured While Displaying
leave to screen 0.
endif.
*Create a instance of cl_gui_alv_grid
create object lr_display
exporting
i_parent = lr_parent_grid
exceptions
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5.
if sy-subrc <> 0.
message i081 display like c_e.
"Unknown Error Occured While Displaying
leave to screen 0.
endif.
2010 Sep 21 7:58 PM
Hi All,
I have went and added the suggestions above but I am know getting a program Abend when I run the program, if I take the reference to the container split it does not abend.
Can any expert help with finding the issue?
DATA : lr_custom_container TYPE REF TO cl_gui_custom_container,
"lr_event_receiver TYPE REF TO lcl_event_receiver,
lr_splitter TYPE REF TO cl_gui_splitter_container,
lr_parent_top TYPE REF TO cl_gui_container,
lr_parent_grid TYPE REF TO cl_gui_container,
lr_dyndoc_id TYPE REF TO cl_dd_document,
lr_display TYPE REF TO cl_gui_alv_grid,
lv_container_name TYPE c LENGTH 12 VALUE 'ZMM_RPT_CONT'.
CREATE OBJECT lr_custom_container
EXPORTING
container_name = lv_container_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
*Split the container into two parts
CREATE OBJECT lr_splitter
EXPORTING
parent = lr_custom_container
rows = 2
columns = 1
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
*Get the upper part of the container into V_PARENT_TOP
CALL METHOD lr_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = lr_parent_top.
*Get the lower part of the container into V_PARENT_GRID
CALL METHOD lr_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = lr_parent_grid.
*Set the height of the top part of the container
CALL METHOD lr_splitter->set_row_height
EXPORTING
id = 1
height = 28
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
*Create a instance of cl_gui_alv_grid
CREATE OBJECT lr_display
EXPORTING
i_parent = lr_parent_grid
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
r_container = lr_parent_top
IMPORTING
r_salv_table = gr_alv
CHANGING
t_table = gt_rpt_details.
PERFORM f_display_settings.
"This is where the program abends....
gr_alv->set_screen_status(
pfstatus = 'ZSTANDARD'
report = sy-repid
set_functions = gr_alv->c_functions_all ). "set all basic ALV funtions
gr_events = gr_alv->get_event( ).
"create layout object
CREATE OBJECT gr_layout.
lr_columns = gr_alv->get_columns( ).
lr_columns->set_optimize( 'X' ).
the error I get is:
The exception 'CX_SALV_METHOD_NOT_SUPPORTED' was raised, but it was not caught
thanks
2010 Sep 21 8:16 PM
2010 Sep 21 8:37 PM
2010 Sep 21 9:02 PM
I don't see any screen logic in your code. I assume this is in the PBO of some screen??
Rob
2010 Sep 21 9:10 PM
If you read the exception more carefully, you would spot this
The reason for this exception is:
Class CL_SALV_TABLECLASS, method SET_SCREEN_STATUSMETHOD not supported for
CL_SALV_TABLEOBJECT For Full Screen and List OnlyKEY
From the explanation it is clear to me that this methods is not supported for grid embeded in the container.
Also as Rob noticed, you are missing the screen itself. Anyhow it doens't resolve your issue. Either you give up using this method or switch to full screen/list mode where splitter could not be applied to.
BTW: next time please be more descriptive so the people will not be guessing and asking to get the information they should receive at the beginning.
Regards
Marcin
2010 Sep 21 9:22 PM
I am using the new SALV class and not using a CALL SCREEN.
I do not have any logic in the PBO of the screen.
Either you give up using this method or switch to full screen/list mode where splitter could not be applied to.
How do I would I not use this method? Just set the PF-Status manually?
2010 Sep 21 9:40 PM
I am using the new SALV class and not using a CALL SCREEN.
Come on, do you really think we did not spot it.
For SALV if you use
- list -> you don't need a screen
- full screen grid -> you don't need it either
- grid -> you need a screen, otherwise how custom container would be recognized?
Please refer SALV_DEMO_TABLE_SIMPLE , all three above options are shown there.
How do I would I not use this method? Just set the PF-Status manually?
If you use grid mode you simply can't. The reason is one of the first lines in this method
"if the object is a GRID you can't set status yourself
if get_display_object( ) eq IF_SALV_C_TABLE_OBJECTS=>GRID.
text = text-001.
raise exception type CX_SALV_METHOD_NOT_SUPPORTED
exporting class = 'CL_SALV_TABLE'
method = 'SET_SCREEN_STATUS'
object = 'CL_SALV_TABLE'
key = text.
endif.
So the system will set the default one and apparently you can't change this. Any complaints please direct to sap.com
Regards
Marcin
2010 Sep 21 9:43 PM
maybe I asked the wrong questions... BUT I figured it out, Here is the code to make it work it is from SAP example program
SALV_TEST_TABLE_DISPLAY_OR_XML
*... Top of List, End of List
data: lr_content type ref to cl_salv_form_element.
PERFORM create_alv_form_content_tol USING space CHANGING lr_content.
gr_alv->set_top_of_list( lr_content ).
FORM create_alv_form_content_tol USING i_print TYPE sap_bool
CHANGING cr_content TYPE REF TO cl_salv_form_element.
DATA: lr_header TYPE REF TO cl_salv_form_header_info,
l_text TYPE string.
*... create header information
CASE i_print.
WHEN space.
CONCATENATE 'TOP_OF_LIST' text-h01 INTO l_text SEPARATED BY space.
WHEN abap_true.
CONCATENATE 'TOP_OF_LIST_PRINT' text-h01 INTO l_text SEPARATED BY space.
ENDCASE.
CREATE OBJECT lr_header
EXPORTING
text = l_text
tooltip = l_text.
cr_content = lr_header.
ENDFORM. " CREATE_ALV_FORM_CONTENT_TOL