SET_TABLE_FOR_FIRST_DISPLAY and HotSpots
Posted onJun 17, 2008 at 06:30 PM | 1.8k Views
Follow
RSS Feed
Hello,
We have a report that uses SET_TABLE_FOR_FIRST_DISPLAY which works well but I have been asked to add a hotspot to call another screen. I see that a fieldcatalog can be passed but I have not found a method that corresponds to REUSE_ALV_FIELDCATALOG_MERGE.
I am a novice at method programming and did think that using the FM was the correct thing to do. Is there was a method that would do the same thing? Does anyone have some sample code?
Thank you in advance.
Regards, Dean.
Add a Comment
Alert Moderator
Assigned Tags
ABAP Development
Related questions
cl_gui_splitter_container and hotspots?
ByFormer Member Feb 18, 2011
Distinguish Hotspots
ByFormer Member Feb 19, 2014
5 Answers
Votes
|
Newest
|
Oldest
Best Answer
Chidanand Chauhan
Posted onJun 17, 2008 at 06:38 PM
2
Hi Dean,
There is no harm in OOALV, But I would suggest you to go for the OOALV.
Now a days a new feature has provided by SAP regarding ALV which is SALV.
I have created a sample program corresponding to almost all funcitonality.
just copy and paste this program you will see the difference how easy is OOALV (SALV).
*&---------------------------------------------------------------------*
*& Report ZCC_OOALV_CL_SALV_FUNCTIONS *
*& *
*&---------------------------------------------------------------------*
*& Developer Name: Chidanand Chauhan *
*& Date: 15/05/2008 *
*& Description: SALV for the Program for the functionality. *
*& *
*& *
*&---------------------------------------------------------------------*
report zcc_ooalv_cl_salv_functions.
data: ispfli type table of spfli.
field-symbols: <fs> type spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings.
data: gr_columns type ref to cl_salv_columns_table.
data: gr_column type ref to cl_salv_column_table.
data: color type lvc_s_colo.
data: gr_sorts type ref to cl_salv_sorts.
data: gr_agg type ref to cl_salv_aggregations.
data: gr_filter type ref to cl_salv_filters.
data: gr_layout type ref to cl_salv_layout.
data: key type salv_s_layout_key.
data: gr_selections type ref to cl_salv_selections.
data: xspfli type spfli.
data: gr_events type ref to cl_salv_events_table.
*----------------------------------------------------------------------*
• CLASS lcl_handle_events DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_handle_events definition.
public section.
on_user_command for event added_function of cl_salv_events
importing e_salv_function,
on_double_click for event double_click of cl_salv_events_table
importing row column,
on_link_click for event link_click of cl_salv_events_table
importing row column.
endclass. "lcl_handle_events DEFINITION
data: event_handler type ref to lcl_handle_events.
data: lt_celltype type salv_t_int4_column,
ls_celltype type salv_s_int4_column.
*&>>>>-----------------------------------------------------------------*
• START OF SELECTION
*&>>>>-----------------------------------------------------------------*
start-of-selection.
select * into table ispfli from spfli.
cl_salv_table=>factory( importing r_salv_table = gr_tablechanging t_table = ispfli ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
*&>>>>-----------------------------------------------------------------*
• Next, add functions to the application toolbar. For this, use the
• CL_SALV_FUNCTIONS class. Create the object reference variable and
• receive the object using the GET_FUNCTIONS method of the GR_TABLE
• object. Call the method SET_ALL to force the ALV grid to show all
• standard functions.
*&---------------------------------------------------------------------*
gr_display = gr_table->get_display_settings( ).
gr_display->set_striped_pattern( cl_salv_display_settings=>true ).gr_display->set_list_header( 'Test Program for ZSALV By Chidanand' ).
*&<<<<-----------------------------------------------------------------*
*&----------------------------------------------------------------------
• change the Heading Text of a column as well as the color of a column.
*&----------------------------------------------------------------------
gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'CITYTO' ).
gr_column->set_long_text( 'This is long text' ).
gr_column->set_medium_text( 'This is med text' ).
gr_column->set_short_text( 'This is sh' ).
gr_column ?= gr_columns->get_column( 'CITYFROM' ).
color-col = '6'.
color-int = '1'.
color-inv = '0'.
gr_column->set_cell_type( if_salv_c_cell_type=>hotspot ).gr_column->set_color( color ).
• data: val type SALV_DE_CONSTANT.
• val = 1.
• gr_column->SET_DROPDOWN_ENTRY( val ).
*&----------------------------------------------------------------------
*sorting to the ALV grid.
*&----------------------------------------------------------------------
gr_sorts = gr_table->get_sorts( ).
**&----------------------------------------------------------------------
** sorted by CITYTO, we can add an aggregation to subtotal the DISTANCE
** by CITYTO. Create the object reference variable and receive the object
** using the GET_AGGREGATIONS method of the GR_TABLE object. Next, add
** the aggregation by calling the ADD_AGGREGATION method of the GR_SORTS
** object. We also need to modify the call to ADD_SORT to set
** the SUBTOTAL = ABAP_TRUE.
**&----------------------------------------------------------------------
gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ).
gr_agg = gr_table->get_aggregations( ).
gr_agg->add_aggregation( 'DISTANCE' ).
*&>>>>-----------------------------------------------------------------*
• Using the CL_SALV_FILTERS class setup some filters for the data
• in our ALV GRID. Create the object reference variable and receive the
• object using the GET_FILTERS method of the GR_TABLE object,and then
• simply called the method ADD_FILTER with the parameters.
*&>>>>-----------------------------------------------------------------*
gr_filter = gr_table->get_filters( ).
gr_filter->add_filter( columnname = 'CARRID' low = 'LH' ).
*&>>>>-----------------------------------------------------------------*
• If you want to allow the user to manage layouts of the ALV grid, you
• must use the class CL_SALV_LAYOUT.Create the object reference variable
• and receive the object using the GET_LAYOUT method of the GR_TABLE
• object. Then simply call the method SET_KEY with the parameters and
• set the save restriction using the SET_SAVE_RESTRICTION method.
*&>>>>-----------------------------------------------------------------*
gr_layout = gr_table->get_layout( ).
key-report = sy-repid.
gr_layout->set_key( key ).
gr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).*&>>>>-----------------------------------------------------------------*
*----------------------------SET GUI STATUS ---------------------------
• Go to function group SALV_METADATA_STATUS and copy the gui status
• ZSALV_TABLE_STANDARD into the ZCC_OOALV_CL_SALV_FUNCTIONS program.This
• is the standard gui status for the 2 Dimensional Table ALV grid. Once
• you have copied the status, set the screen status using the appropriate
• method of the object GR_TABLE. Go to the gui status and add a new
• button on the application toolbar and name it as u201CMYFUNCTIONu201D.
*&>>>>-----------------------------------------------------------------*
gr_table->set_screen_status(
pfstatus = 'ZSALV_TABLE_STANDARD'
report = sy-repid
set_functions = gr_table->c_functions_all ).
*&>>>>-----------------------------------------------------------------*
• -----------------Get Event Handler.----------------------------------*
• Define the event handler method for DOUBLE_CLICK event and add the
• implementation for the ON_DOUBLE_CLICK event handler method. Remember
• to set the handler for the event.
*&>>>>-----------------------------------------------------------------*
gr_events = gr_table->get_event( ).
create object event_handler.
set handler event_handler->on_user_command for gr_events.
set handler event_handler->on_double_click for gr_events.
set handler event_handler->on_link_click for gr_events.
• Set up selections.
gr_selections = gr_table->get_selections( ).
gr_selections->set_selection_mode( 1 ). "Single
gr_table->display( ).
*----------------------------------------------------------------------*
• CLASS lcl_handle_events IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
class lcl_handle_events implementation.
method on_user_command.
• Get the selection rows
data: lr_selections type ref to cl_salv_selections.
data: lt_rows type salv_t_row.
data: ls_rows type i.
data: message type string.
case e_salv_function.
when '&FUNCTION'.
lr_selections = gr_table->get_selections( ).lt_rows = lr_selections->get_selected_rows( ).read table lt_rows into ls_rows index 1.
read table ispfli into xspfli index ls_rows.
concatenate xspfli-carrid xspfli-connid
xspfli-cityfrom xspfli-cityto
into message separated by space.
message i001(00) with 'You Clicked the button!' message.
endcase.
endmethod. "on_user_command
method on_double_click.
data: message type string.
...