2013 Jul 26 7:46 AM
Sir my report is
*&---------------------------------------------------------------------*
*& Report ZCENTRADE_REPORT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zcentrade_report.
include <color>.
include <icon>.
include <symbol>.
set PF-STATUS 'KK'.
TYPES:BEGIN OF t_disp,
mandt TYPE sflight-mandt,
carrid TYPE sflight-carrid,
connid TYPE sflight-connid,
check TYPE flag,
END OF t_disp.
data: lr_functions type ref to cl_salv_functions_list,
l_text type string,
l_icon type string.
DATA: gr_table TYPE REF TO cl_salv_table,
gr_functions TYPE REF TO cl_salv_functions,
gr_columns TYPE REF TO cl_salv_columns,
gr_column TYPE REF TO cl_salv_column_list,
gr_display TYPE REF TO cl_salv_display_settings,
lr_grid TYPE REF TO cl_salv_form_layout_grid,
lr_gridx TYPE REF TO cl_salv_form_layout_grid,
lr_logo TYPE REF TO cl_salv_form_layout_logo,
lr_label TYPE REF TO cl_salv_form_label,
lr_text TYPE REF TO cl_salv_form_text,
lr_footer TYPE REF TO cl_salv_form_layout_grid,
ls_color TYPE lvc_s_colo
.
DATA: it_disp TYPE TABLE OF t_disp,
wa_disp LIKE LINE OF it_disp.
class lcl_handle_events definition deferred.
data: gr_events type ref to lcl_handle_events.
CLASS lcl_event_handler DEFINITION.
*
PUBLIC SECTION.
METHODS:
on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
*
ENDCLASS.
CLASS lcl_event_handler IMPLEMENTATION.
*
METHOD on_link_click.
*
* Get the value of the checkbox and set the value accordingly
* Refersh the table
FIELD-SYMBOLS: <lfa_data> LIKE LINE OF it_disp.
READ TABLE it_disp ASSIGNING <lfa_data> INDEX row.
CHECK sy-subrc IS INITIAL.
IF <lfa_data>-check IS INITIAL.
<lfa_data>-check = 'X'.
ELSE.
CLEAR <lfa_data>-check.
ENDIF.
gr_table->refresh( ).
ENDMETHOD. "on_link_click
*
ENDCLASS.
class lcl_handle_events definition.
public section.
methods:
on_double_click for event double_click of cl_salv_events_table
importing row column.
endclass.
class lcl_handle_events implementation.
method on_double_click.
perform show_cell_info using row column .
endmethod.
endclass.
CLASS lcl_perf_eval DEFINITION .
PUBLIC SECTION.
METHODS :build_fc,constructor.
METHODS :disp_alv,data.
METHODS set_tol.
METHODS end_of_page.
ENDCLASS. "lcl_perf_eval DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_perf_eval IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_perf_eval IMPLEMENTATION .
METHOD constructor.
TRY.
cl_salv_table=>factory( IMPORTING r_salv_table = gr_table CHANGING t_table = it_disp ).
CATCH cx_salv_msg.
ENDTRY .
IF gr_table IS INITIAL .
MESSAGE TEXT-002 TYPE 'I' DISPLAY LIKE 'E'.
EXIT .
ENDIF .
data lo_events TYPE REF TO cl_salv_events_table.
DATA: lo_event_handler TYPE REF TO lcl_event_handler.
CREATE OBJECT lo_event_handler.
* CREATE OBJECT lo_events .
lo_events = gr_table->get_event( ) .
lr_functions = gr_table->get_functions( ).
lr_functions->set_all('X').
try.
l_text = text-b01.
l_icon = icon_complete.
lr_functions->add_function(
name = 'refresh'
icon = l_icon
text = 'Refresh'
tooltip = l_text
position = if_salv_c_function_position=>right_of_salv_functions ).
catch cx_salv_wrong_call cx_salv_existing.
endtry.
* event handler
SET HANDLER lo_event_handler->on_link_click FOR lo_events.
ENDMETHOD.
METHOD build_fc.
INCLUDE <color>.
TRY.
gr_columns = gr_table->get_columns( ).
gr_columns->set_optimize( abap_true ).
gr_column ?= gr_columns->get_column( 'MANDT' ).
ls_color-col = 8 .
gr_column->set_color( ls_color ).
CATCH cx_salv_not_found.
ENDTRY .
TRY.
gr_column ?= gr_columns->get_column( 'CARRID' ).
ls_color-col = 4.
gr_column->set_color( ls_color ).
CATCH cx_salv_not_found.
ENDTRY .
TRY.
gr_column ?= gr_columns->get_column( 'CONNID' ).
CATCH cx_salv_not_found.
ENDTRY .
TRY.
gr_column ?= gr_columns->get_column( 'CHECK' ).
gr_column->set_cell_type( if_salv_c_cell_type=>checkbox_hotspot ).
gr_column->set_output_length( 10 ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
data: lr_events type ref to cl_salv_events_table.
lr_events = gr_table->get_event( ).
create object gr_events.
set handler gr_events->on_double_click for lr_events.
ENDMETHOD.
method data .
SELECT mandt carrid connid from sflight into table it_disp.
ENDMETHOD .
METHOD disp_alv.
set_tol( ).
build_fc( ).
end_of_page( ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_table->set_top_of_list( lr_logo ).
gr_table->set_end_of_list( lr_footer ).
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
gr_table->display( ).
ENDMETHOD. "disp_alv
METHOD set_tol.
DATA : lv_text(30) TYPE c ,
lv_date TYPE c LENGTH 10.
CREATE OBJECT lr_grid.
lr_grid->create_header_information( row = 1 column = 1
text = 'ABAPOO REPORT FOR SFLIGHT'
tooltip = 'ABAPOO REPORT FOR SFLIGHT' ).
lr_gridx = lr_grid->create_grid( row = 2 column = 1 ).
lr_label = lr_gridx->create_label( row = 2 column = 1
text = 'HERE IAM DISPLAYING THREE FIELDS :' tooltip = 'HERE IAM DISPLAYING THREE FIELDS :' ).
lr_text = lr_gridx->create_text( row = 2 column = 2
text = lv_text tooltip = lv_text ).
lr_text = lr_gridx->create_text( row = 3 column = 2
text = lv_text tooltip = lv_text ).
lr_label = lr_gridx->create_label( row = 4 column = 1
text = 'REPORT DATE:' tooltip = 'REPORT DATE:' ).
lr_text = lr_gridx->create_text( row = 5 column = 1
text = sy-datum tooltip = sy-datum ).
CREATE OBJECT lr_logo.
lr_logo->set_left_content( lr_grid ).
lr_logo->set_right_logo('test' ).
ENDMETHOD.
METHOD end_of_page.
DATA :lf_lines TYPE sy-tfill .
DATA : lf_flow TYPE REF TO cl_salv_form_layout_flow .
CREATE OBJECT lr_footer.
lf_lines = LINES( it_disp ).
lr_label = lr_footer->create_label( row = 1 column = 1 ).
lr_label->set_text( 'Information:' ).
lf_flow = lr_footer->create_flow( row = 2 column = 1 ).
lf_flow->create_text( text = 'Total Number of Entries' ).
lf_flow = lr_footer->create_flow( row = 2 column = 2 ).
lf_flow->create_text( text = lf_lines ).
ENDMETHOD.
ENDCLASS.
form show_cell_info using i_row type i
i_column type LVC_FNAME .
data: l_row_string type string,
l_col_string type string,
l_row type char128.
write i_row to l_row left-justified.
endform.
START-OF-SELECTION.
DATA : obj_rep TYPE REF TO lcl_perf_eval. " Declaring Object for Class
CREATE OBJECT : obj_rep. " Creating Object
obj_rep->data( ).
obj_rep->disp_alv( ).
when i m running it i m getting error
hort text
An exception occurred that was not caught.
hat happened?
The exception 'CX_SALV_METHOD_NOT_SUPPORTED' was raised, but it was not caught
anywhere along
the call hierarchy.
Since exceptions represent error situations and this error was not
adequately responded to, the running ABAP program
'CL_SALV_FUNCTIONS=============CP' has to be
terminated.
rror analysis
An exception occurred which is explained in detail below.
The exception, which is assigned to class 'CX_SALV_METHOD_NOT_SUPPORTED', was
not caught and
therefore caused a runtime error.
The reason for the exception is:
Class CL_SALV_FUNCTIONSCLASS, method ENABLE_FUNCTIONMETHOD not supported for
refreshOBJECT Only Possible in Grid ViewKEY
please help
2013 Jul 26 12:22 PM
Hi Ravi,
I have executed your program and got dump as specified above in this line. When I disabled this line, the ALV was generated.
lr_functions->add_function(
name = 'refresh'
icon = l_icon
text = 'Refresh'
tooltip = l_text
position = if_salv_c_function_position=>right_of_salv_functions ).
When I debugged it, in enable_function method, this function throws a message that this can be added only in the grid view.
In this line of enable_function method, the exception is raised.
if lr_controller->r_model->get_display_object( )
ne IF_SALV_C_TABLE_OBJECTS=>GRID
and lr_controller->r_model->get_display_object( )
ne IF_SALV_C_TABLE_OBJECTS=>TREE.
text = text-001.
l_name = name.
raise exception type CX_SALV_METHOD_NOT_SUPPORTED
exporting class = 'CL_SALV_FUNCTIONS'
method = 'ENABLE_FUNCTION'
object = l_name
key = text.
endif.
I think that since the ALV is displayed using cl_salv_table, the scenario cannot be achieved.
Try to do it using ALV Grid.
Thanks & Regards,
T. Prasanna Kumar
2013 Jul 26 1:01 PM
Hi RAvikumar,
Add the below code inside the METHOD disp_alv and check.
DATA : obj_rep TYPE REF TO lcl_perf_eval. " Declaring Object for Class
CREATE OBJECT : obj_rep. " Creating Object
obj_rep->data( ).
obj_rep->disp_alv( ).
2013 Jul 26 1:44 PM
Hey it looks like
lr_functions->add_function(
name = 'refresh'
icon = l_icon
text = 'Refresh'
tooltip = l_text
position = if_salv_c_function_position=>right_of_salv_functions ).
this block is giving problems... Refresh is only supported to Grid.
If you comment this it is working..
thanks,
Aswath.