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

At user_command is not working

Former Member
0 Likes
3,702

hi All,

i have written below code to execute at user_command event , when i click on MATNR field it is not going to 'MM02 ' screen .

can anybody tell me what is fault in my code ?

form USER_COMMAND using ucomm like sy-ucomm selfield type slis_selfield

   data : ok_code type sy-ucomm.

   ok_code = ucomm.

   case ok_code.

     when 'MY_SELECTION'.

       if selfield-fieldname = 'MATNR'.

         read table it_final into wa_final index selfield-tabindex.

         if not wa_final-matnr is initial.

           set parameter id 'MAT' field wa_final-matnr.

           call transaction 'MM02' and skip first screen.

         endif.

       endif.

   endcase.

endform.

1 ACCEPTED SOLUTION
Read only

vinoth_aruldass
Contributor
0 Likes
3,256

hi

form USER_COMMAND using ucomm like sy-ucomm selfield type slis_selfield

   case ucomm.

     when 'MY_SELECTION'.

       if selfield-fieldname = 'MATNR'.

         read table it_final into wa_final index selfield-tabindex.

         if not wa_final-matnr is initial.

           set parameter id 'MAT' field wa_final-matnr.

           call transaction 'MM02' and skip first screen.

         endif.

       endif.

   endcase.

endform.

this will work...

hi All,

i have written below code to execute at user_command event , when i click on MATNR field it is not going to 'MM02 ' screen .

can anybody tell me what is fault in my code ?

form USER_COMMAND using ucomm like sy-ucomm selfield type slis_selfield

   data : ok_code type sy-ucomm.

   ok_code = ucomm.

   case ok_code.

     when 'MY_SELECTION'.

       if selfield-fieldname = 'MATNR'.

         read table it_final into wa_final index selfield-tabindex.

         if not wa_final-matnr is initial.

           set parameter id 'MAT' field wa_final-matnr.

           call transaction 'MM02' and skip first screen.

         endif.

       endif.

   endcase.

endform.

27 REPLIES 27
Read only

Former Member
0 Likes
3,256

OK_CODE = UCOMM.   (Incorrect)

OK_CODE = SY-UCOMM.. (Correct)

Avirat

Read only

0 Likes
3,256

Read the documentation of REUSE_ALV_GRID_DISPLAY on the CALLBACK USER COMMAND parameter...

Regards,

Raymond

Read only

Former Member
0 Likes
3,256

Hi,

Just check whether the cursor comes into the

when 'MY_SELECTION'. in debugging mode.

i did not see any problem in ur code.

just declare the variables in the top include.

FORM user_command USING r_ucomm LIKE sy-ucomm
                       rs_selfield
TYPE slis_selfield.
 
CASE r_ucomm.
   
WHEN '&IC1'.     

IF rs_selfield-fieldname = 'VBELN'.

* Read data table, using index of row user clicked on
       
READ TABLE it_final INTO wa_final INDEX rs_selfield-tabindex.

* Set parameter ID for transaction screen field
       
SET PARAMETER ID  'AUN' FIELD wa_final-vbeln.
       
CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
    
      ENDIF.
 
ENDCASE.ENDFORM.                    " DETAILED

regards

Ram

Read only

basarozgur_kahraman
Contributor
0 Likes
3,256

Hi Smitha,

In fieldcatalog, set hotspot for MATNR field.

if fieldcatalog-fieldname = 'MATNR'.

fieldcat-hotspot = 'X'.

endif.

and add double click event at user_command

form USER_COMMAND using ucomm like sy-ucomm selfield type slis_selfield

   case ucomm.

     when '&IC1'.

       if selfield-fieldname = 'MATNR'.

         read table it_final into wa_final index selfield-tabindex.

         if not wa_final-matnr is initial.

           set parameter id 'MAT' field wa_final-matnr.

           call transaction 'MM02' and skip first screen.

         endif.

       endif.

   endcase.

endform.

Read only

Former Member
0 Likes
3,256

Hai Samitha,

First of all you debug it and check whether the system triggering the form or not.

If it is not triggering, means a possible reason is in your display function module you are passing the user command in small letter like 'user_command' it should be in Caps 'USER_COMMAND'.

or try the code as below:

form USER_COMMAND using zucomm like sy-ucomm

                                             selfield type slis_selfield

   data : ok_code type sy-ucomm.

   ok_code = zucomm.

   case ok_code.

     when 'MY_SELECTION'.

       if selfield-fieldname = 'MATNR'.

         read table it_final into wa_final index selfield-tabindex.

         if not wa_final-matnr is initial.

           set parameter id 'MAT' field wa_final-matnr.

           call transaction 'MM02' and skip first screen.

         endif.

       endif.

   endcase.

endform.

Thanks,

Anoop S

Read only

vinoth_aruldass
Contributor
0 Likes
3,257

hi

form USER_COMMAND using ucomm like sy-ucomm selfield type slis_selfield

   case ucomm.

     when 'MY_SELECTION'.

       if selfield-fieldname = 'MATNR'.

         read table it_final into wa_final index selfield-tabindex.

         if not wa_final-matnr is initial.

           set parameter id 'MAT' field wa_final-matnr.

           call transaction 'MM02' and skip first screen.

         endif.

       endif.

   endcase.

endform.

this will work...

Read only

0 Likes
3,256

hi All,

Thank you all for the replies ....

i tried all which is mentioned in the replies, still not working

When i'm trying to debug form is not triggering . please suggest on this .

Regards

Smitha

Read only

0 Likes
3,256

Hi,

Check in the FM 'REUSE_ALV_GRID_DISPLAY' whether u given

like this or not

i_callback_user_command = 'USER_COMMAND'

for eg:

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   
EXPORTING
      i_callback_program      = i_repid
      is_layout               = gs_layout
      i_callback_user_command =
'USER_COMMAND'
      it_fieldcat             = fieldcatalog[]
      i_save                  =
'X'
   
TABLES
      t_outtab                = it_final[]
   
EXCEPTIONS
      program_error           =
1
     
OTHERS                  = 2.

Read only

0 Likes
3,256

hi,

if

i_callback_user_command = 'USER_COMMAND' is given this should work.

form USER_COMMAND using ucomm like sy-ucomm selfield type slis_selfield

   case ucomm.

     when 'MY_SELECTION'.

       if selfield-fieldname = 'MATNR'.

         read table it_final into wa_final index selfield-tabindex.

         if not wa_final-matnr is initial.

           set parameter id 'MAT' field wa_final-matnr.

           call transaction 'MM02' and skip first screen.

         endif.

       endif.

   endcase.

endform.

Read only

0 Likes
3,256

Hi,

I think you are trying to use single click only and expecting to trigger the event but it will not. either use double click or make the matnr field hotspot (for single click).

thanks.

Read only

0 Likes
3,256

Hi Smitha,

did you try double click("&IC1") event with hotspot?

if yes, please send your REUSE_ALV call statement and USER_COMMAND method completly.

Read only

0 Likes
3,256

hi

Below is my ALV grid and User_command code , i'm using hotspot

FORM DISPLAY_ALV_REPORT .

   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      I_CALLBACK_PROGRAM                = v_repid

      I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'

      I_CALLBACK_TOP_OF_PAGE            = 'TOP-OF-PAGE'

      IS_LAYOUT                         = fs_layout

      IT_FIELDCAT                       = i_fcat[]

      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.

ENDFORM.                    " DISPLAY_ALV_REPORT

  data : ok_code type sy-ucomm.

form USER_COMMAND using ucomm like sy-ucomm selfield type slis_selfield .

   ok_code = ucomm.

   case ok_code.

     when '&IC1'.

       if selfield-fieldname = 'MATNR'.

         read table it_final into wa_final index selfield-tabindex.

*        if not wa_final-matnr is initial.

           set parameter id 'MAT' field wa_final-matnr.

           call transaction 'MM02' and skip first screen.

*        endif.

       endif.

   endcase.

endform.

Read only

0 Likes
3,256

DATA: v_events    TYPE slis_t_event,
          wa_event    TYPE slis_alv_event.

in initialization event.

call these two performs.

PERFORM event_call.

PERFORM populate_event.

define these form calls in your code

FORM event_call.
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      i_list_type = 0
    IMPORTING
      et_events   = v_events.
  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.                    "EVENT_CALL

*&--------------------------------------------------------------------*
*&      Form  POPULATE_EVENT
*&--------------------------------------------------------------------*
*      Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM populate_event.
  READ TABLE v_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.
  IF sy-subrc EQ 0.
    wa_event-form = 'TOP_OF_PAGE'.
    MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =
wa_event-form.
  ENDIF.

  READ TABLE v_events INTO wa_event WITH KEY name = 'USER_COMMAND'.
  IF sy-subrc EQ 0.
    wa_event-form = 'USER_COMMAND'.
    MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =
wa_event-name.
  ENDIF.
ENDFORM. 

and pass this events table in your ALV display call.. it_events parameters..

Read only

0 Likes
3,256

hi ,

Tried as u said ,still facing same issue .

Regards

Smitha

Read only

0 Likes
3,256

you did passed v_events to it_events in your F.M. right ??

Read only

0 Likes
3,256

and also pass v_repid = sy-repid. before passing it to your ALV ....

Read only

0 Likes
3,256

Hi Smitha,

Are you sure to set v_repid with value of sy-repid before REUSE_ALV call.

DATA: v_repid  like sy-repid.

v_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      I_CALLBACK_PROGRAM                = v_repid

      I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'

      I_CALLBACK_TOP_OF_PAGE            = 'TOP-OF-PAGE'

      IS_LAYOUT                         = fs_layout

      IT_FIELDCAT                       = i_fcat[]

      I_DEFAULT                         = 'X'

      I_SAVE                            = 'A'

     TABLES

       T_OUTTAB                          = it_final[]

    EXCEPTIONS

      PROGRAM_ERROR                     = 1

      OTHERS                            = 2

             .

Read only

0 Likes
3,256

Hi,

is double click also not working with &IC1 command?

thanks.

Read only

0 Likes
3,256

Do you activating the code before run or not ?

check all objects are activated or not.

Read only

0 Likes
3,256

hi

Even double click is not working .

Read only

0 Likes
3,256

hi

ya i have passed v_repid = sy-repid. still not working .

FORM DISPLAY_ALV_REPORT .

   v_repid = sy-repid.

   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      I_CALLBACK_PROGRAM                = v_repid

      I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'

      I_CALLBACK_TOP_OF_PAGE            = 'TOP-OF-PAGE'

       IS_LAYOUT                                       = fs_layout

      IT_FIELDCAT                       = i_fcat[]

      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.

ENDFORM.                    " DISPLAY_ALV_REPORT

  data : ok_code type sy-ucomm.

form USER_COMMAND using ucomm like sy-ucomm selfield type slis_selfield .

   ok_code = sy-ucomm.

   case ok_code.

     when '&IC1'.

       if selfield-fieldname = 'MATNR'.

         read table it_final into wa_final index selfield-tabindex.

*        if not wa_final-matnr is initial.

           set parameter id 'MAT' field wa_final-matnr.

           call transaction 'MM02' and skip first screen.

*        endif.

       endif.

   endcase.

endform.


Read only

0 Likes
3,256

I think the problem lies in the definition of 'MY_SELECTION'. Where are you declaring this ?

means you assigning one OK-Code, but how you are assigning?

Read only

0 Likes
3,256

hi Ritwik ,

below is my code

data : ok_code type sy-ucomm.

form USER_COMMAND using ucomm like sy-ucomm selfield type slis_selfield .

   ok_code = sy-ucomm.

   case ok_code.

     when '&IC1'.

       if selfield-fieldname = 'MATNR'.

         read table it_final into wa_final index selfield-tabindex.

*        if not wa_final-matnr is initial.

           set parameter id 'MAT' field wa_final-matnr.

           call transaction 'MM02' and skip first screen.

*        endif.

       endif.

   endcase.

endform.

Read only

0 Likes
3,256

Hey you are using ucomm write as formal parameter and you should use the same instead of using sy-ucomm here.

ok_code = sy-ucomm.  Because at this point the value of sy-ucomm might have changed.

Read only

0 Likes
3,256

paste your whole code once .... pls

Read only

0 Likes
3,256

Thnk u all for the replies.

Issue has been rectified . I commented ok_code = sy-ucomm and it is working fine .

form USER_COMMAND using ucomm like sy-ucomm selfield type slis_selfield .

*  ok_code = sy-ucomm.

   case ucomm.

     when '&IC1'.

       if selfield-fieldname = 'MATNR'.

         read table it_final into wa_final index selfield-tabindex.

*        if not wa_final-matnr is initial.

           set parameter id 'MAT' field wa_final-matnr.

           call transaction 'MM03' and skip first screen.

*        endif.

       endif.

   endcase.

endform.

Read only

Former Member
0 Likes
3,256

If you have resolved the issue please mark question as answered and close the thread.