on 02-13-2024 4:31 PM
Hello everyone ,
I am trying to develop the event link_click in order to display a message when I click on a specific container
For example : You have clicked on X container where X is a dynamic number depending on which container i have clicked
the data i am retrieving dynamically from an excel sheet and splitting the container based on how many sheets i have
This is my code
CLASS lcl_excel IMPLEMENTATION.
METHOD open_dialog.
DATA: lv_rc TYPE i.
DATA: lt_files TYPE filetable.
DATA: lv_action TYPE i.
CLEAR lt_files.
TRY.
cl_gui_frontend_services=>file_open_dialog( EXPORTING
file_filter = |{ cl_gui_frontend_services=>filetype_excel }|
CHANGING
file_table = lt_files
rc = lv_rc
user_action = lv_action ).
IF lv_action = cl_gui_frontend_services=>action_ok.
IF lines( lt_files ) > 0.
p_file = lt_files[ 1 ]-filename.
ENDIF.
ENDIF.
CATCH cx_root INTO DATA(e_text).
MESSAGE e_text->get_text( ) TYPE 'I'.
ENDTRY.
ENDMETHOD.
METHOD get_excel.
DATA : lv_filename TYPE string,
lt_records TYPE solix_tab,
lv_headerxstring TYPE xstring,
lv_filelength TYPE i.
lv_filename = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_filename
filetype = 'BIN'
IMPORTING
filelength = lv_filelength
header = lv_headerxstring
TABLES
data_tab = lt_records
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = lv_filelength
IMPORTING
buffer = lv_headerxstring
TABLES
binary_tab = lt_records
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
"Implement suitable error handling here
ENDIF.
DATA : lo_excel_ref TYPE REF TO cl_fdt_xl_spreadsheet .
FIELD-SYMBOLS : <gt_data_h> TYPE ANY TABLE.
TRY .
lo_excel_ref = NEW cl_fdt_xl_spreadsheet(
document_name = lv_filename
xdocument = lv_headerxstring ) .
CATCH cx_fdt_excel_core.
ENDTRY .
IF lo_excel_ref IS BOUND.
lo_excel_ref->if_fdt_doc_spreadsheet~get_worksheet_names(
IMPORTING
worksheet_names = DATA(lt_worksheets) ).
IF NOT lt_worksheets IS INITIAL.
DATA(lo_main_container) = NEW cl_gui_custom_container( container_name = 'CUSTCONTROL' ).
DATA(gv_nr_of_lines) = lines( lt_worksheets ).
lo_split = NEW cl_gui_splitter_container( parent = lo_main_container
rows = 1
columns = gv_nr_of_lines ).
LOOP AT lt_worksheets INTO DATA(lv_woksheetname).
lv_tabix = sy-tabix.
DATA(lo_data_ref) = lo_excel_ref->if_fdt_doc_spreadsheet~get_itab_from_worksheet(
lv_woksheetname ).
ASSIGN lo_data_ref->* TO <gt_data_h>.
lo_split->get_container( EXPORTING row = 1
column = lv_tabix
RECEIVING container = lo_container ).
APPEND INITIAL LINE TO gt_salv_save ASSIGNING FIELD-SYMBOL(<fs_save>).
TRY.
cl_salv_table=>factory( EXPORTING
r_container = lo_container
IMPORTING
r_salv_table = <fs_save>
CHANGING
t_table = <gt_data_h> ).
lo_events = <fs_save>->get_event( ).
SET HANDLER me->on_link_click FOR lo_events.
<fs_save>->get_functions( )->set_all( abap_true ).
<fs_save>->get_columns( )->set_optimize( abap_true ).
<fs_save>->get_display_settings( )->set_list_header( CONV #( lv_woksheetname ) ).
<fs_save>->get_display_settings( )->set_striped_pattern( abap_true ).
<fs_save>->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).
LOOP AT <fs_save>->get_columns( )->get( ) ASSIGNING FIELD-SYMBOL(<c>).
o_col = <c>-r_column.
o_col_table = CAST cl_salv_column_table( <c>-r_column ).
o_col_table->set_cell_type( if_salv_c_cell_type=>hotspot ).
o_col->set_short_text( || ).
o_col->set_medium_text( || ).
* o_col->set_long_text( |{ o_col->get_columnname( ) }| ).
ENDLOOP.
CATCH cx_root INTO DATA(e_txt).
WRITE: / e_txt->get_text( ).
ENDTRY.
<fs_save>->display( ).
ENDLOOP.
CALL SCREEN 0100.
ENDIF.
ENDIF.
ENDMETHOD.
METHOD
METHODS:
on_link_click
FOR EVENT link_click OF cl_salv_events_table
IMPORTING
row
column
sender.
when i double click on a container , i want to show a message that i have clicked on container 1 for example
the number depends on which container i click, dynamically
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.