06-27-2017 5:27 PM
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.
07-01-2017 7:41 AM
Your question is misleading :
FORM user_command
CHANGING
r_ucomm TYPE syucomm
rs_selfield TYPE slis_selfield.
ENDFORM.
06-28-2017 9: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)
07-01-2017 6:33 AM
PS: SY-REPID may be passed as a parameter without any problem since 6.10. It's not a system variable anymore, but a variable belonging to every program:
07-03-2017 7:02 AM
Old habits die hard...
07-03-2017 8:13 AM
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.
06-30-2017 1:33 PM
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,
07-01-2017 7:41 AM
Your question is misleading :
FORM user_command
CHANGING
r_ucomm TYPE syucomm
rs_selfield TYPE slis_selfield.
ENDFORM.
07-06-2017 5:53 PM
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.
07-06-2017 6: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.
07-06-2017 8:47 PM
No no no, don't call yourself the USER_COMMAND subroutine. Please read the SAP documentation, have a look at all the demo programs in your system (like BCALV_TEST_LIST_EVENTS) and all examples around the WWW.
07-06-2017 9:03 PM
Hi Sandra,
When i added the i_callback_user_command ='USER_COMMAND' to the Function module('REUSE_ALV_POPUP_TO_SELECT') and clicked on pretty printer the Form endform was craeted automatically.
But again it threw an error saying that "Error: Before the statement "FORM", conclude with "ENDFUNCTION"".
So i tried using a perform.
Ps: I am calling this reuse_popup inside another function module.
07-06-2017 9:20 PM
I don't know what happened, but FORM ENDFORM must be outside FUNCTION ENDFUNCTION. You must not use PERFORM (you have probably seen that all the demo programs and examples around the web don't PERFORM this subroutine, haven't you?)
07-06-2017 9:22 PM
Yes i have never seen perform, totally agree, But to avoid error and make my program point to the ("form..endform") i tried using a perform.
07-06-2017 9:59 PM
So, now, I guess you moved successfully your FORM USER_COMMAND ... ENDFORM subroutine outside your Z function module. Does it work?
07-07-2017 3:12 PM
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.