Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

calling transaction

Former Member
0 Likes
1,090

Hi,

how can i call a transactioncode through ALV

Actually i have to click in output field

then it will take me that transaction code correspondingly

give me some code

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
922

Refer the follwoing code:

In order to add user command functioality to the ALV grid you need to perform the following steps:

1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include 'USER_COMMAND' FORM

2. Create 'USER_COMMAND' FORM

call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program      = gd_repid
            i_callback_top_of_page   = 'TOP-OF-PAGE'  
            I_callback_user_command = 'USER_COMMAND'   "see FORM 
            is_layout               = gd_layout
            it_fieldcat             = fieldcatalog[]
            i_save                  = 'X'
       tables
            t_outtab                = it_ekko
       exceptions
            program_error           = 1
            others                  = 2.


*------------------------------------------------------------------*
*       FORM USER_COMMAND                                          *
*------------------------------------------------------------------*
*       --> R_UCOMM                                                *
*       --> RS_SELFIELD                                            *
*------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
                  rs_selfield TYPE slis_selfield.

* Check function code
  CASE r_ucomm.
    WHEN '&IC1'.
*   Check field clicked on within ALVgrid report
    IF rs_selfield-fieldname = 'EBELN'.
*     Read data table, using index of row user clicked on
      READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
*     Set parameter ID for transaction screen field
      SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
*     Sxecute transaction ME23N, and skip initial data entry screen
      CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
    ENDIF.
  ENDCASE.
ENDFORM.

6 REPLIES 6
Read only

Former Member
0 Likes
923

Refer the follwoing code:

In order to add user command functioality to the ALV grid you need to perform the following steps:

1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include 'USER_COMMAND' FORM

2. Create 'USER_COMMAND' FORM

call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program      = gd_repid
            i_callback_top_of_page   = 'TOP-OF-PAGE'  
            I_callback_user_command = 'USER_COMMAND'   "see FORM 
            is_layout               = gd_layout
            it_fieldcat             = fieldcatalog[]
            i_save                  = 'X'
       tables
            t_outtab                = it_ekko
       exceptions
            program_error           = 1
            others                  = 2.


*------------------------------------------------------------------*
*       FORM USER_COMMAND                                          *
*------------------------------------------------------------------*
*       --> R_UCOMM                                                *
*       --> RS_SELFIELD                                            *
*------------------------------------------------------------------*
FORM user_command USING r_ucomm LIKE sy-ucomm
                  rs_selfield TYPE slis_selfield.

* Check function code
  CASE r_ucomm.
    WHEN '&IC1'.
*   Check field clicked on within ALVgrid report
    IF rs_selfield-fieldname = 'EBELN'.
*     Read data table, using index of row user clicked on
      READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
*     Set parameter ID for transaction screen field
      SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
*     Sxecute transaction ME23N, and skip initial data entry screen
      CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
    ENDIF.
  ENDCASE.
ENDFORM.

Read only

0 Likes
922

If you click to the purchasing document no in the alv display, it will take to you to the transaction 'ME23N'.

Read only

Former Member
0 Likes
922

Hi,

Here Order_num is the field at the output grid which navigates you to the transaction

----


  • CLASS lcl_event_receiver DEFINITION

----


*

----


CLASS lcl_event_receiver DEFINITION.

PUBLIC SECTION.

METHODS: catch_doubleclick

FOR EVENT double_click OF cl_gui_alv_grid

IMPORTING

e_column

es_row_no

sender.

ENDCLASS. "lcl_event_receiver DEFINITION

*----


    • CLASS lcl_event_receiver IMPLEMENTATION

*----


**

*----


CLASS lcl_event_receiver IMPLEMENTATION.

METHOD catch_doubleclick.

DATA: wa_output TYPE t_output,

fname(40),

fvalue(20).

CLEAR :fname,

fvalue.

SET CURSOR FIELD 'ORDER_NUM'.

  • GET CURSOR FIELD fname VALUE fvalue.

IF e_column EQ 'ORDER_NUM'.

LOOP AT i_plan INTO wa_plan

WHERE order_num EQ wa_output-order_num.

IF sy-subrc EQ 0.

SET PARAMETER ID 'PAF' FIELD wa_output-order_num.

CALL TRANSACTION 'MD13' AND SKIP FIRST SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

  • MODIFY i_output FROM wa_output INDEX es_row_no-row_id.

CALL METHOD sender->refresh_table_display.

ENDMETHOD. "catch_doubleclick

ENDCLASS. "lcl_event_receiver IMPLEMENTATION

CREATE OBJECT g_custom_container

EXPORTING container_name = g_container.

CREATE OBJECT g_grid

EXPORTING i_parent = g_custom_container.

CALL METHOD g_grid->set_table_for_first_display

EXPORTING

is_layout = gs_layout

  • is_variant = gs_variant

  • is_print = gs_print

i_save = i_save

i_default = space

CHANGING

it_fieldcatalog = i_fieldcat

it_outtab = i_output[].

CREATE OBJECT g_event_receiver.

SET HANDLER g_event_receiver->catch_doubleclick FOR g_grid.

CALL METHOD g_grid->set_ready_for_input

EXPORTING

i_ready_for_input = 1.

Read only

Bema
Active Participant
0 Likes
922

Hi ,

you can use hotspot in ALV.

When creating fieldcatalogue,

u can mention

line_fieldcat-hotspot = 'X'.

Then create a form to handle events.

FORM f_events_init CHANGING i_events TYPE slis_t_event.

DATA: line_event TYPE slis_alv_event.

CLEAR line_event.

line_event-name = 'USER_COMMAND'.

line_event-form = 'F_USER_COMMAND'.

APPEND line_event TO i_events.

endform.

Then

FORM f_user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

  • When user clicks hotspot it will display details

  • Here it calls FB03 transaction

CASE r_ucomm.

WHEN '&IC1'. "for double click

IF rs_selfield-fieldname = 'BELNR'.

READ TABLE i_output INDEX rs_selfield-tabindex.

SET PARAMETER ID 'BLN' FIELD rs_selfield-value.

SET PARAMETER ID 'BUK' FIELD i_output-bukrs.

SET PARAMETER ID 'GJR' FIELD p_ryear.

CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.

ENDIF.

ENDCASE.

ENDFORM. "USER_COMMAND

You just call the event

PERFORM f_events_init CHANGING i_events.

Reward points if helpful

Read only

Former Member
0 Likes
922

Hi Skgarg,

U have to use User-command event in ALV for that.

refer this code :

DATA : L_EVENT TYPE SLIS_ALV_EVENT.

  • FOR GETTING ALL 17 EVENTS

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = P_I_EVENTCAT

EXCEPTIONS

LIST_TYPE_WRONG = 1

OTHERS = 2

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CLEAR L_EVENT.

READ TABLE P_I_EVENTCAT WITH KEY NAME = SLIS_EV_USER_COMMAND INTO L_EVENT.

IF SY-SUBRC = 0.

MOVE 'Z8_USER_COMMAND' TO L_EVENT-FORM.

APPEND L_EVENT TO P_I_EVENTCAT.

ENDIF.

form z8_user_command using p_ucomm type sy-ucomm

p_selfield type slis_selfield.

case p_ucomm.

WHEN '&IC1'. "IC1 is fcode for double click

call transaction Vao3 using p_selfield-value.

Reward points if helpful.

Regards,

Hemant

Read only

Former Member
0 Likes
922

Hi,

for example if you click on the customer number you should get the customer details and if you click on the material tou should show the material quantites text etc..

This is an interactive report..

Example program

This is your grid FM..

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' Or grid display

EXPORTING

I_CALLBACK_PROGRAM = GT_REPID

:

I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND' " FORM NAME

:

:

IT_FIELDCAT = GT_FIELDCAT

.....................................

TABLES

T_OUTTAB = ITAB

...........................

            • This you should write for your double click

FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

CASE r_ucomm.

WHEN '&Ic1'. "double click

CASE rs_selfield-fieldname. "field name

WHEN <your field name>.

IF NOT fp_selfield-value IS INITIAL.

*Setting parameter id for sales order

SET PARAMETER ID c_aun FIELD fp_selfield-value.

*FM for Call transaction "VA03"

CALL FUNCTION 'ABAP4_CALL_TRANSACTION'

EXPORTING

tcode = l_c_va03 " VA03

skip_screen = c_x. "'X'

ENDIF.

WHEN OTHERS.

MESSAGE i078. "Wrong Click msg

LEAVE LIST-PROCESSING.

ENDCASE.

ENDCASE.

ENDFORM.

reward if useful..

regards,

nazeer