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

Hotspot

Former Member
0 Likes
1,597

I have a very simple report which displays Material, Material Desc, Plant, Storage Loc etc through a alv grid. Now the requirement is like when we click on any particular material Number the report should take us to MM03 transaction.

I have found some resolution with using OOABAP.

But it would be gr8 if any body can tell me that how I can make it without ooabap.

Thanks,

Nabanita

Use meaningful subject line for your questions

Edited by: Vijay Babu Dudla on Jan 20, 2009 2:29 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,542

Hi Nandi,

You just use export parameter 'i_callback_user_command' for the 'REUSE_ALV_GRID_DISPLAY' function module.

Write a FORM user_command as shown below. No need to call this FORM explicitly.



  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
       i_callback_program               = sy-repid
*   I_CALLBACK_PF_STATUS_SET          = ' '
       i_callback_user_command          = 'USER_COMMAND'     "here u have to write like this for user cmd
       i_callback_top_of_page           = c_toppag
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
       is_layout                        = wa_layout
       it_fieldcat                      = i_fieldcat
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
       i_save                           = l_save_alv_variant
       is_variant                       = wa_disvariant
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   I_HTML_HEIGHT_TOP                 =
*   I_HTML_HEIGHT_END                 =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    TABLES
      t_outtab                          = i_final
    EXCEPTIONS
      program_error                     = 1
      OTHERS                            = 2.


*&---------------------------------------------------------------------*
*&      Form  user_command
*&---------------------------------------------------------------------*
* HOTSPOT processing withing ALV
* User has clicked on hotspot, now display value in transaction
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM user_command USING p_ucomm     LIKE sy-ucomm
                        ps_selfield TYPE slis_selfield .   


  IF p_ucomm EQ c_f2.                                "doubleclick

    CASE ps_selfield-fieldname.

      WHEN 'MATNR'.

*C-- Material Number
        IF NOT ps_selfield-value IS INITIAL.
         SET PARAMETER ID c_mat FIELD  ps_selfield-value.
         CALL TRANSACTION c_mm03 AND SKIP FIRST SCREEN.
        ENDIF.

    ENDCASE.

Edited by: Ramya AS on Jan 20, 2009 7:43 AM

10 REPLIES 10
Read only

Former Member
0 Likes
1,542

use

SET PARAMETER ID: 'MAT' FIELD matnr.

CALL TRANSACTION 'MM03'.

Read only

Former Member
0 Likes
1,542

Hi,

If you are using function module then Use USER_COMMAND in alv grid.

Follow the sample code:

**Calling the function module for ALV Grid

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = sy-repid

is_layout = it_layout

i_callback_user_command = 'USERCOMMAND'

it_fieldcat = it_fieldcat[]

i_save = 'A'

is_variant = v_variant

tables

t_outtab = it_final

exceptions

program_error = 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.

endform.

**For navigating the screen.

form usercommand using ucomm type sy-ucomm

selfield type slis_selfield.

case ucomm.

when '&IC1'.

if selfield-fieldname = 'MATNR'.

set parameter id 'MAT' field selfield-value.

call transaction 'MM03' and skip first screen.

endif.

endcase.

endform.

Hope this will help u.

Thanks.

Read only

Former Member
0 Likes
1,542

Hi,

You can do it through statement " Call transaction MM03" setting it in parameter id.

Thanks & Regards

Read only

Former Member
0 Likes
1,543

Hi Nandi,

You just use export parameter 'i_callback_user_command' for the 'REUSE_ALV_GRID_DISPLAY' function module.

Write a FORM user_command as shown below. No need to call this FORM explicitly.



  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
       i_callback_program               = sy-repid
*   I_CALLBACK_PF_STATUS_SET          = ' '
       i_callback_user_command          = 'USER_COMMAND'     "here u have to write like this for user cmd
       i_callback_top_of_page           = c_toppag
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
       is_layout                        = wa_layout
       it_fieldcat                      = i_fieldcat
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
       i_save                           = l_save_alv_variant
       is_variant                       = wa_disvariant
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   I_HTML_HEIGHT_TOP                 =
*   I_HTML_HEIGHT_END                 =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    TABLES
      t_outtab                          = i_final
    EXCEPTIONS
      program_error                     = 1
      OTHERS                            = 2.


*&---------------------------------------------------------------------*
*&      Form  user_command
*&---------------------------------------------------------------------*
* HOTSPOT processing withing ALV
* User has clicked on hotspot, now display value in transaction
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM user_command USING p_ucomm     LIKE sy-ucomm
                        ps_selfield TYPE slis_selfield .   


  IF p_ucomm EQ c_f2.                                "doubleclick

    CASE ps_selfield-fieldname.

      WHEN 'MATNR'.

*C-- Material Number
        IF NOT ps_selfield-value IS INITIAL.
         SET PARAMETER ID c_mat FIELD  ps_selfield-value.
         CALL TRANSACTION c_mm03 AND SKIP FIRST SCREEN.
        ENDIF.

    ENDCASE.

Edited by: Ramya AS on Jan 20, 2009 7:43 AM

Read only

Former Member
0 Likes
1,542

Hi Nandi,

You just use export parameter 'i_callback_user_command' for the 'REUSE_ALV_GRID_DISPLAY' function module.

Write a FORM user_command as shown below. No need to call this FORM explicitly.



  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
       i_callback_program               = sy-repid
*   I_CALLBACK_PF_STATUS_SET          = ' '
       i_callback_user_command          = 'USER_COMMAND'     "here u have to write like this for user cmd
       i_callback_top_of_page           = c_toppag
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  =
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
       is_layout                        = wa_layout
       it_fieldcat                      = i_fieldcat
*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
       i_save                           = l_save_alv_variant
       is_variant                       = wa_disvariant
*   IT_EVENTS                         =
*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   I_HTML_HEIGHT_TOP                 =
*   I_HTML_HEIGHT_END                 =
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
    TABLES
      t_outtab                          = i_final
    EXCEPTIONS
      program_error                     = 1
      OTHERS                            = 2.


*&---------------------------------------------------------------------*
*&      Form  user_command
*&---------------------------------------------------------------------*
* HOTSPOT processing withing ALV
* User has clicked on hotspot, now display value in transaction
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM user_command USING p_ucomm     LIKE sy-ucomm
                        ps_selfield TYPE slis_selfield .   


  IF p_ucomm EQ '<F2CODE>'.                                "doubleclick

    CASE ps_selfield-fieldname.

      WHEN 'MATNR'.

*C-- Material Number
        IF NOT ps_selfield-value IS INITIAL.
         SET PARAMETER ID 'MAT' FIELD  ps_selfield-value.
         CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
        ENDIF.

    ENDCASE.

Read only

Former Member
0 Likes
1,542

Hi ,

If you are using Reuse_alv_grid_display FM than pass user_command also and create a form with name of user_command .This form will import ucomm and your selected column field name and field

value so that you can use this for set the matnr field value and call transaction .

eg :

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = sy-repid

is_layout = it_layout

i_callback_user_command = 'USER_COMMAND' "This is form to handle user command of ALV

it_fieldcat = it_fieldcat[]

i_save = 'A'

is_variant = v_variant

tables

t_outtab = it_final

exceptions

program_error = 1

others = 2.

*****create a form with name user_command ******************

form user_command using ucomm type sy-ucomm "user command

selfield type slis_selfield. "structure which containm field name and value

case ucomm.

when '&IC1'. "when you double click on alv you will debug and see the user command become &IC1

if selfield-fieldname = 'MATNR'.

set parameter id 'MAT' field selfield-value.

call transaction 'MM03' and skip first screen.

endif.

endcase.

endform.

regards ,

Nilesh K Jain.

Read only

Former Member
0 Likes
1,542

Hi,

neccsary thing you have make a field as hotspot is during field catalog

fieldcatalog-fieldname = 'MATNR'.-> name of the field in the internal table

fieldcatalog-seltext_m = 'Material No'.->description that will display in output

fieldcatalog-col_pos = 1.->column position

fieldcatalog-hotspot = 'X'.->to make MATNR field as hotspot

fieldcatalog-tabname = 'it_final'.->name of the internal table which you want to display

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

****to display output*********************************

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = g_repid -> sy-repid

I_CALLBACK_USER_COMMAND = 'HANDLE_USER_COMMAND'

is_layout = gd_layout -> layout

it_fieldcat = fieldcatalog[] ->fieldcatalog

i_default = 'X'

i_save = 'A'

tables

t_outtab = it_final

exceptions

program_error = 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.

FORM HANDLE_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

IF R_UCOMM = '&IC1'.

IF RS_SELFIELD-FIELDNAME = 'MATNR'.

CLEAR : WA_FINAL.

READ TABLE IT_FINAL INTO WA_FINAL INDEX RS_SELFIELD-TABINDEX.

IF NOT WA_FINAL-VBELV IS INITIAL.

set parameter id 'MAT' field WA_FINAL-MATNR.

CALL TRANSACTION 'MM03' and skip first screen.

clear wa_final.

ENDIF.

ENDIF.

ENDIF.

Read only

Former Member
0 Likes
1,542

Hi,

You have to create an subroutine for capturing click event through SY-UCOMM.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_user_command= 'USER_COMMAND' This is Your Subroutine name whose Form Endform is created below.

i_callback_top_of_page = c_toppag

is_layout = wa_layout

it_fieldcat = i_fieldcat

i_save = l_save_alv_variant

is_variant = wa_disvariant

  • IMPORTING

TABLES

t_outtab = i_final

EXCEPTIONS

program_error = 1

OTHERS = 2.

&----


*& Form user_command

&----


  • On the click of hotspot user has to be taken to transaction MM03

FORM user_command USING p_ucomm LIKE sy-ucomm

ps_selfield TYPE slis_selfield .

IF sy-ucomm EQ '&IC1'. "capturing double click event

CASE ps_selfield-fieldname.

WHEN 'MATNR'.

IF NOT ps_selfield-value IS INITIAL.

SET PARAMETER ID 'MAT' FIELD ps_selfield-value.

CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

ENDIF.

ENDCASE.

Hope it helps you

Regards

Mansi

Read only

Former Member
0 Likes
1,542

Thabks to u all for ur valuable suggestion.

only a small thhing. when I click on Material its taking me to MM03 but its happening with single click only. Is there any way i can make this thing happen only after double click on material?

Read only

0 Likes
1,542

Ya you can do that.

fieldcatalog-fieldname = 'MATNR'.-> name of the field in the internal table

fieldcatalog-seltext_m = 'Material No'.->description that will display in output

fieldcatalog-col_pos = 1.->column position

fieldcatalog-hotspot = 'X'.->to make MATNR field as hotspot

Here Dont populate this filed(fieldcatalog-hotspot = 'X')

Remove this line. Now you can goto MM03 by double click

Thanks,

Ramya