How To Activate Another TCode From ALV

How to trigger another t-code from ALV report? For example, I have an inventory report and want to check the transaction details in MMBE by clicking on that material no in the ALV report.

This is done through a interactive report in normal reporting but in Alv' s this is a object oriented.abap programming by using class cl_gui_grid as a container for data to be displayed in a grid and and to call a transaction write 'call transaction <tcode>' in implementation of class.and for clicking purpose event handler should be used.

This is a method for writing:

First create a module pool program and later this is the code.

********************
class lcl_events_handler definition.

public section.
methods: Handle_double_click for
                    events double_click of cl_gui_alv_grid
                                         importing e_row.
endclass       .

class lcl_event_handler implementation.
method : handle_double_click.
read table it_ekko into wa_ekko..
set parameter id 'bes' field wa_ekko-ebeln.

call transaction 'me23n'
endmethod.
endclass.

create object o_container.
                exporting  container_name = 'container'
create object o_grid 
                exporting i_parent = o_container.
wa_layout-sel_mode = 'D'.       " / this can be A,C,D which are used to retreive data into grid as rows and column. 

call method o_grid ->set_table_for_first_display
exporting 
        i_structure_name = 'EKKO'
        is_layout              = wa_layout
changing
        it_outtab              = it_ekko.

data o_handler type ref to lcl_event_handler.
create object o_handler.
set handler : o_handler->handle_double_click for o_grid.
endif.

-------------

Another method:

*&--------------------------------------------------------------------*
*&      Form  user_command
*&--------------------------------------------------------------------*

FORM user_command USING ucomm LIKE sy-ucomm
                       selfield TYPE slis_selfield.

  CASE ucomm.

    WHEN '&IC1'.                  "Double click on selected line

      READ TABLE i_final INTO w_final INDEX selfield-tabindex. --------------------------->Internal table u r displaying in ALV

      CHECK sy-subrc EQ 0.

      SET PARAMETER ID 'AUN' FIELD w_final-vbeln. -----------------------------------------> give the parameter Id of the field u r double clicking

      CALL TRANSACTION 'MMBE' AND SKIP FIRST SCREEN.

      CLEAR w_final.

  ENDCASE.

ENDFORM.                    "user_command

------->Call the above subroutine in the below function

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

   EXPORTING

*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '

     i_callback_program                = program

*   I_CALLBACK_PF_STATUS_SET          = ' '

     i_callback_user_command           = 'USER_COMMAND' --------------------------> the above subroutine should be called here 

See Also:
Brain Dump ABAP Questions and Answers

Tables
Database Table

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.