‎2021 Apr 16 4:02 AM
Hi all,
After I display my ALV.
I went to menu bar click on LIst->Export->Spreadsheet.
I check the command. It is &XXL
How come my user_command subroutine cannot trigger?
Then I tried added a custom function button on application toolbar named &EXL
Apparently, standard function code cannot trigger, but custom function can?
gw_wrk_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = gw_wrk_repid
i_callback_pf_status_set = 'SUB_PF_STATUS' "znsc
i_callback_user_command = 'USER_COMMAND'
i_callback_html_top_of_page = 'TOP_OF_PAGE'
it_fieldcat = gw_wrk_fieldcat
is_layout = gw_wrk_layout
it_sort = gt_sort
TABLES
t_outtab = gt_output
EXCEPTIONS
program_error = 1
OTHERS = 2.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
FIELD-SYMBOLS: <fs_output> LIKE gs_output.
CASE r_ucomm.
WHEN '&IC1'.
IF rs_selfield-fieldname = 'EBELN'.
READ TABLE gt_output INTO gw_output INDEX rs_selfield-tabindex.
SET PARAMETER ID 'BES' FIELD gw_output-ebeln.
CALL TRANSACTION 'ME23N'.
ENDIF.
* begin znsc
WHEN '&XXL'.
IF gt_output IS NOT INITIAL.
UNASSIGN <fs_output>.
LOOP AT gt_output ASSIGNING <fs_output>.
‎2021 Apr 16 7:17 AM
Sorry, could you explain why you are trying to catch the ucomm &XLL ? it is standard, you do not have to catch it.
(forget this FM, use SALV class, it is more than old-school this FM)
‎2021 Apr 16 7:21 AM
Hi Frederic,
I am trying to remove special characters in a alv column only when user tried to trigger &XXL
by click on LIst->Export->Spreadsheet.
WHEN '&XXL'.
IF gt_output IS NOT INITIAL.
UNASSIGN <fs_output>.
LOOP AT gt_output ASSIGNING <fs_output>.
IF <fs_output>-longtext IS NOT INITIAL.
PERFORM remove_spl_char USING <fs_output>-longtext.
* CHANGING <fs_output>-longtext.
ENDIF.
ENDLOOP.
* refresh the alv table after removing special chars in item long text
rs_selfield-refresh = 'X'. "Set this one. It refreshes internal table data with new values
ENDIF.
‎2021 Apr 16 8:05 AM
‎2021 Apr 16 9:09 AM
it is not better to hide xxl button, create your own ? create an excel file is not really difficult with ABAP2XLS
‎2021 Apr 17 12:54 AM
Did you you register the instance events handler? Looks like there there is a missing
SET HANDLER statement. The user command will trigger once its done