Skip to Content

How to get the value of selected cell using cl_salv_table...

Hello Experts,

I defined 1 column in my OO ALV(factory method) as a hotspot. Now,

I need to get the value of that selected cell since I will use that value to

call a particular transaction. Hope you can help me guys. Thank you and take care!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 06:34 AM

    Hi Vira,

    TRY.

    cl_salv_table=>factory(

    EXPORTING

    list_display = ''

    IMPORTING

    r_salv_table = lcl_table

    CHANGING

    t_table = gt_output ).

    CATCH cx_salv_msg. "#EC NO_HANDLER

    ENDTRY.

    lcl_functions = lcl_table->get_functions( ).

    Set all standard ALV functions

    lcl_functions->set_all( abap_true ).

    lcl_columns = lcl_table->get_columns( ).

    lcl_columns->set_optimize( abap_true ).

    Set display to striped pattern

    lcl_display = lcl_table->get_display_settings( ).

    lcl_display->set_striped_pattern( cl_salv_display_settings=>true ).

    */Sort columns

    TRY.

    lcl_sorts = lcl_table->get_sorts( ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    lcl_sorts->set_group_active( ).

    IF rb_sum = 'X'.

    TRY.

    lcl_sorts->add_sort(

    columnname = 'DESCRIPT'

    subtotal = abap_true ).

    CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_sorts->add_sort(

    columnname = 'BUKRS'

    subtotal = '' ).

    CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER

    ENDTRY.

    ELSE.

    TRY.

    lcl_sorts->add_sort(

    columnname = 'DESCRIPT'

    subtotal = '' ).

    CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_sorts->add_sort(

    columnname = 'AUFNR'

    subtotal = '' ).

    CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_sorts->add_sort(

    columnname = 'BUKRS'

    subtotal = '' ).

    CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_sorts->add_sort(

    columnname = 'KHINR'

    subtotal = '' ).

    CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_sorts->add_sort(

    columnname = 'KOSTL'

    subtotal = '' ).

    CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_sorts->add_sort(

    columnname = 'AUART'

    subtotal = abap_true ).

    CATCH cx_salv_not_found cx_salv_existing cx_salv_data_error."#EC NO_HANDLER

    ENDTRY.

    ENDIF.

    */Set column names

    TRY.

    lcl_column ?= lcl_columns->get_column( 'DESCRIPT' ).

    lcl_column->set_short_text( text-h01 ).

    lcl_column->set_medium_text( text-h01 ).

    lcl_column->set_long_text( text-h01 ).

    lcl_column->set_output_length( '40' ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'BUKRS' ).

    lcl_column->set_medium_text( text-h02 ).

    lcl_column->set_long_text( text-h02 ).

    lcl_column->set_output_length( '12' ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'KHINR' ).

    lcl_column->set_medium_text( text-h03 ).

    lcl_column->set_long_text( text-h03 ).

    lcl_column->set_output_length( '17' ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'KOSTL' ).

    lcl_column->set_medium_text( text-h04 ).

    lcl_column->set_long_text( text-h04 ).

    lcl_column->set_output_length( '10' ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'AUART' ).

    lcl_column->set_medium_text( text-h05 ).

    lcl_column->set_long_text( text-h05 ).

    lcl_column->set_output_length( '04' ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'KTEXT' ).

    lcl_column->set_medium_text( text-h06 ).

    lcl_column->set_long_text( text-h06 ).

    lcl_column->set_output_length( '20' ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'AUFNR' ).

    lcl_column->set_medium_text( text-h07 ).

    lcl_column->set_long_text( text-h07 ).

    lcl_column->set_output_length( '12' ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'ACTUAL' ).

    lcl_column->set_short_text( text-h08 ).

    lcl_column->set_medium_text( text-h08 ).

    lcl_column->set_long_text( text-h08 ).

    lcl_column->set_output_length( '10' ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'COMMIT' ).

    lcl_column->set_short_text( text-h09 ).

    lcl_column->set_medium_text( text-h09 ).

    lcl_column->set_long_text( text-h09 ).

    lcl_column->set_output_length( '10' ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'TOTAL' ).

    lcl_column->set_short_text( text-h10 ).

    lcl_column->set_medium_text( text-h10 ).

    lcl_column->set_long_text( text-h10 ).

    lcl_column->set_output_length( '10' ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'BUDGET' ).

    lcl_column->set_short_text( text-h11 ).

    lcl_column->set_medium_text( text-h11 ).

    lcl_column->set_long_text( text-h11 ).

    lcl_column->set_output_length( '15' ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'AMOUNT' ).

    lcl_column->set_short_text( text-h12 ).

    lcl_column->set_medium_text( text-h12 ).

    lcl_column->set_long_text( text-h12 ).

    lcl_column->set_output_length( '15' ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'AMOUNT' ).

    lcl_column->set_technical( if_salv_c_bool_sap=>true ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'AGE' ).

    lcl_column->set_short_text( text-h13 ).

    lcl_column->set_medium_text( text-h13 ).

    lcl_column->set_long_text( text-h13 ).

    lcl_column->set_output_length( '15' ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    */Set aggregations

    TRY.

    lcl_aggregations = lcl_table->get_aggregations( ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_aggregations->add_aggregation( 'ACTUAL' ).

    CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_aggregations->add_aggregation( 'COMMIT' ).

    CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_aggregations->add_aggregation( 'TOTAL' ).

    CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_aggregations->add_aggregation( 'BUDGET' ).

    CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_aggregations->add_aggregation( 'AMOUNT' ).

    CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_aggregations->add_aggregation( 'AGE' ).

    CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing."#EC NO_HANDLER

    ENDTRY.

    */Hide columns

    TRY.

    lcl_column ?= lcl_columns->get_column( 'SETNAME' ).

    lcl_column->set_visible( if_salv_c_bool_sap=>false ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'TXT' ).

    lcl_column->set_visible( if_salv_c_bool_sap=>false ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'BUDAT1' ).

    lcl_column->set_visible( if_salv_c_bool_sap=>false ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'BUDAT2' ).

    lcl_column->set_visible( if_salv_c_bool_sap=>false ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'ASTNR' ).

    lcl_column->set_visible( if_salv_c_bool_sap=>false ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'COMMIT' ).

    lcl_column->set_visible( if_salv_c_bool_sap=>false ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'TOTAL' ).

    lcl_column->set_visible( if_salv_c_bool_sap=>false ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'AVAIL' ).

    lcl_column->set_visible( if_salv_c_bool_sap=>false ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'CTRDIV' ).

    lcl_column->set_visible( if_salv_c_bool_sap=>false ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    TRY.

    lcl_column ?= lcl_columns->get_column( 'CTRORD' ).

    lcl_column->set_visible( if_salv_c_bool_sap=>false ).

    CATCH cx_salv_not_found. "#EC NO_HANDLER

    ENDTRY.

    lcl_events2 = lcl_table->get_event( ).

    CREATE OBJECT lcl_handle_events.

    SET HANDLER lcl_handle_events->on_link_click FOR lcl_events2.

    SET HANDLER lcl_handle_events->on_top_of_page FOR lcl_events2.

    lcl_display_settings = lcl_table->get_display_settings( ).

    lcl_table->display( ).

    pls reward if helpful.

    cheers.

    Hema.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2008 at 06:30 AM

    Use this method

    GET_CURRENT_CELL_TEXT..

    There are lots of method for this class.

    Go to se24-> enter class name -> methods.

    From here u can select method according to ur requirement.

    Regards,

    Nishant

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.