-1

I currently displaying a table as an ALV as follows:

DATA: alv          TYPE REF TO cl_salv_table,
      output_table TYPE TABLE OF output_table.
TRY.
    cl_salv_table=>factory(
      IMPORTING
        r_salv_table = alv
      CHANGING
        t_table      = output_table ).
  CATCH cx_salv_msg INTO DATA(msg).
    cl_demo_output=>display( msg ).
ENDTRY.

alv->display( ).

My output table contains a material number as well as the plant.

Example:

Material Plant ...
123456789 0001 ...
999999999 0002 ...

I want that transaction MM03 (with material and plant and view Accounting 1) is called when clicked on one line in the ALV table.

I've found some solutions on the internet but those are not quite working for me. Do you have some clues on how to proceed with this topic?

What I tried was:

DATA(o_alv) = cl_salv_gui_table_ida=>create( iv_table_name = 'SFLIGHT' ).
o_alv->display_options( )->enable_double_click( ).
SET HANDLER lcl_events=>on_double_click FOR o_alv->display_options( ).
[...]

but my table is not an internal table of SAP.

schmelto
  • 427
  • 5
  • 18
  • 3
    When those solutions you found on the internet didn't work for you, then please tell us what those solutions were and why they didn't work for you. You don't want anyone to waste their time by writing down a solution you already tried, do you? – Philipp Aug 18 '22 at 12:20
  • 1
    cl_salv_table or salv + double click or + link click as well as "call transaction batch input" should get you started. – peterulb Aug 18 '22 at 15:46
  • check https://stackoverflow.com/questions/42161066/how-to-call-transaction-in-pop-up-window, also https://stackoverflow.com/questions/64782697/show-alv-table-row-details-on-double-click, also https://stackoverflow.com/questions/64782697/show-alv-table-row-details-on-double-click – Suncatcher Oct 09 '22 at 22:56

1 Answers1

2

Before you create your ALV, make sure to define your event handler class. Assuming your output_table is global and has the fields MATNR and WERKS, it could look like this:

* define class for event handling
CLASS lcl_events DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS: on_double_click FOR EVENT double_click OF cl_salv_events_table
      IMPORTING
          row
          column
          sender.
ENDCLASS.
  
CLASS lcl_events IMPLEMENTATION.
  METHOD on_double_click.
    " Open Accounting 1 view in MM03
    SET PARAMETER ID 'MAT' FIELD output_table[ row ]-matnr .
    SET PARAMETER ID 'WRK' FIELD output_table[ row ]-werks .
    SET PARAMETER ID 'MXX' FIELD 'B' .
    CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN .
  ENDMETHOD.
ENDCLASS.

After calling cl_salv_table=>factory( ), register your event handler for double click:

SET HANDLER lcl_events=>on_double_click FOR alv->get_event( ).
Stefan
  • 241
  • 5