Skip to Content

Not able to capture Sy-Ucomm from REUSE_ALV_POPUP_TO_SELECT

Hi All,

I am calling the FM 'REUSE_ALV_POPUP_TO_SELECT' inside another Function module.

When the user clicks on any lines or the green tick mark from the pop-up , i want to capture the sy-ucomm code and display something accordingly.


CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

    EXPORTING

      i_title                 = lv_string

      i_selection             = 'X'            "<--enable selection

      i_allow_no_selection    = 'X'            "<--allow exiting without selection

      i_zebra                 = 'X'

      i_screen_start_column   = 100

      i_screen_start_line     = 5

      i_screen_end_column     = 217 "120 Character

      i_screen_end_line       = 13

      i_tabname               = 'L_ACTIVE_Dxxx'

      i_structure_name        = 'ZSD_Dxxx_STRUCT'       "<--custom structure goes here

      i_callback_user_command = 'HANDLE_USER_COMMAND'  " "

    IMPORTING

      es_selfield             = ls_selfield

    TABLES

      t_outtab                = l_active_deals.



* Export dealtype selected by user

  CLEAR: w_active_deals, lv_dealtyp.

  READ TABLE l_active_deals INTO w_active_deals

    INDEX ls_selfield-tabindex.

  o_dealtype = w_active_deals-zzdealtyp.



PERFORM handle_user_command USING r_ucomm ls_selfield

                            CHANGING ok_code.


form handle_user_command  using    p_r_ucomm

                                   p_selfield

                          changing p_ok_code.

  case p_r_ucomm.

    when '&ETA'.

      p_ok_code = 'X'.

    when others.

  endcase.

  endform.         
Add comment
10|10000 characters needed characters exceeded

  • Hi raymond ,

    I used both callback_user and callback_program as per your suggestion and checked but i think user_command works only for reuse_alv_merge , i got sy-xcode which captures the sy-ucomm.

    thanks,

  • Get RSS Feed

3 Answers

  • Best Answer
    Jul 01, 2017 at 06:41 AM

    Your question is misleading :

    • If you want to do something when the user "clicks on any lines or the green tick mark"
      .....Then you don't need to retrieve the function code (you're talking about SY-UCOMM/SY-XCODE but you should better never trust these values, they are not guaranteed in future releases): the function module returns the E_EXIT parameter which tells you whether the user cancelled the dialog ('X') or has selected one or more values (' ')
    • If you want to handle the "Detail" button inside the popup, then you use the two I_CALLBACK_* parameters (see Raymond's answer), and the subroutine must have this interface or it won't work:
    • FORM user_command
        CHANGING
          r_ucomm     TYPE syucomm
          rs_selfield TYPE slis_selfield.
      ENDFORM.
      
    • In your code, you defined the subroutine with an extra parameter, which will trigger a SHORT DUMP at runtime when the detail button is pressed.
    • In the subroutine, you may change R_UCOMM, for instance to prevent the standard detail dialog from being displayed, or change one of the components of RS_SELFIELD, for instance to modify the ALV table and refresh the screen, and you have other possibilities. These features are described in the documentation of REUSE_ALV_LIST_DISPLAY function module.
    Add comment
    10|10000 characters needed characters exceeded

    • First , thanks Sandra, Rice and Raymond.

      Well i tried the callback_user_program and callback_user_command first in my "REUSE_ALV_POPUP_TO_SELECT".

      But actually i am calling this reuse pop up inside a function module . So when i added the below code

      after the Reuse FM call i got an error saying that "endform should be outside endfunction"

      However i included a perform inside an endfunction and later called the form outside and my r_ucomm did not have any values.

      FORM user_command
        CHANGING
          r_ucomm     TYPE syucomm
          rs_selfield TYPE slis_selfield.ENDFORM.
      
  • Jun 28, 2017 at 08:12 AM

    If you use your own form for user_command you MUST provide the I_CALLBACK_USER_COMMAND parameter but also the I_CALLBACK_PROGRAM parameter (and don't use sy-repid in the call of the FM but use a local variable)

    Add comment
    10|10000 characters needed characters exceeded

    • Yes they do...

      However, I've decided to still copy sy-repid to a local variable each time because as a contractor I work on many different systems so if I do that i don't need to worry about whether it's 6.10 or not.

  • Jul 06, 2017 at 05:11 PM

    So My code looks like this

    call function 'REUSE_ALV_POPUP_TO_SELECT'
     exporting
     i_title = lv_string
     i_selection = 'X' "<--enable selection
     i_allow_no_selection = 'X' "<--allow exiting without selection
     i_zebra = 'X'
     i_screen_start_column = 100
     i_screen_start_line = 5
     i_screen_end_column = 217 "120 Character
     i_screen_end_line = 13
     i_tabname = 'L_ACTIVE_DEALS'
     i_structure_name = 'ZSD_DEAL_STRUCT' "<--custom structure goes here
     i_callback_program = sy-repid
     i_callback_user_command = 'USER_COMMAND'
     importing
     es_selfield = ls_selfield
     e_exit = lv_exit
     tables
     t_outtab = l_active_deals.
    
    
    perform user_command using ls_selfield r_ucomm.
    
    if lv_exit is initial.
     if sy-xcode = '&NT1' and ( sy-tcode = 'VA01' or sy-tcode = 'VA02' ). 
     ok_code = 'X'. 
     endif.
    endif.
    
    
    
    Add comment
    10|10000 characters needed characters exceeded

    • Hi Sandra,

      No Luck,

      I moved it (form.endform subroutine) outside the endfunction and it doesn capture anything. I am not sure why. I have checked almost all the internet.

      I also found this in the forum

      PS : Functionality of ‘REUSE_ALV_POPUP_TO_SELECT'

      if you do a doubleclick on a record of ALV, it means you want to select it, so the ALV is closed and returns the selected value in ES_SELFIELD parameter without to call USER_COMMAND routine.