cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP Dynamic Event for link_click

Alba
Discoverer
0 Kudos

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.

    DATAlv_rc TYPE i.
    DATAlt_files TYPE filetable.
    DATAlv_action TYPE i.

    CLEAR lt_files.

    TRY.
        cl_gui_frontend_services=>file_open_dialogEXPORTING
                                                       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 lineslt_files 0.
            p_file lt_files[ ]-filename.
          ENDIF.
        ENDIF.
      CATCH cx_root INTO DATA(e_text).
        MESSAGE e_text->get_textTYPE '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_containerNEW cl_gui_custom_containercontainer_name 'CUSTCONTROL' ).


        DATA(gv_nr_of_lineslineslt_worksheets ).

        lo_split NEW cl_gui_splitter_containerparent  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_reflo_excel_ref->if_fdt_doc_spreadsheet~get_itab_from_worksheet(
                                                lv_woksheetname ).



          ASSIGN lo_data_ref->TO <gt_data_h>.

          lo_split->get_containerEXPORTING      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=>factoryEXPORTING
                                                 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_allabap_true ).
              <fs_save>->get_columns)->set_optimizeabap_true ).
              <fs_save>->get_display_settings)->set_list_headerCONV #lv_woksheetname ).
              <fs_save>->get_display_settings)->set_striped_patternabap_true ).
              <fs_save>->get_selections)->set_selection_modeif_salv_c_selection_mode=>row_column ).




              LOOP AT <fs_save>->get_columns)->getASSIGNING FIELD-SYMBOL(<c>).
                o_col <c>-r_column.

                o_col_table CAST cl_salv_column_table<c>-r_column ).


                o_col_table->set_cell_typeif_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.

Sandra_Rossi
Active Contributor
0 Kudos
What is your question? Also, please format your code with button "..." and "</>".

Accepted Solutions (0)

Answers (1)

Answers (1)

Alba
Discoverer
0 Kudos

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

Sandra_Rossi
Active Contributor
Please do not post a solution for commenting the question. Use the "Show replies" of the question > Comment.