by RACH002 on Fri Apr 04, 2008 4:58 am
Hello,
I think I have a solution for you.
1.
You have to use exporting parameter IT_EVENT_EXIT in the function module REUSE_ALV_GRID_DISPLAY.
pass the values
gw_event_exit-ucomm = '&RNT' "User command for print.
gw_event_exit-before = 'X'.
gw_event_exit-after = 'X'.
APPEND gw_event_exit to gt_event_exit.
clear gw_event_exit.
pass gt_event_exit to IT_EVENT_EXIT of function module.
2. Use the user command form to change the fieldcat .
For our example Matnr is the field that needs to be output in the print but not in the screen display.
FORM USER_COMMAND USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
if r_ucomm = '&RNT'.
if gf_set is initial. "(For the first pass it will be initial)
read table gt_fieldcat with key fieldname = 'MATNR' into gs_fieldcat.
gf_tabix = sy-tabix.
clear gs_fieldcat-no_out.
modify gt_fieldcat from gs_fieldcat INDEX gf_tabix TRANSPORTING no_out .
call function 'REUSE_ALV_GRID_LAYOUT_INFO_SET'
EXPORTING
* IS_LAYOUT =
IT_FIELDCAT = gt_fieldcat
* IT_SORT =
* IT_FILTER =
* IS_GRID_SCROLL =
* IS_PRINT =
.
gf_set = 'X'.
else.
read table gt_fieldcat with key fieldname = 'MATNR' into gs_fieldcat.
gf_tabix = sy-tabix.
gs_fieldcat-no_out = 'X'.
modify gt_fieldcat from gs_fieldcat INDEX gf_tabix TRANSPORTING no_out .
call function 'REUSE_ALV_GRID_LAYOUT_INFO_SET'
EXPORTING
IT_FIELDCAT = gt_fieldcat.
endif.
rs_selfield-refresh = 'X'.
endif.
ENDFORM.
3. This way the user command form will be triggered twice --> once for "BEFORE PRINT" event and once after "PRINT EVENT ".
We use function module 'REUSE_ALV_GRID_LAYOUT_INFO_SET' to change the field catalog.
Hope this helps.
Get back to me if you have any question on this one.