ALV display column in print only

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

ALV display column in print only

Postby davejones84 on Fri Apr 04, 2008 1:25 am

Hi,

My program uses 'alv_grid_display' and there is a column that i dont want to display on the output (i use gs_fieldcat-no_out = 'X' in the fieldcatalogue), but i do need to display it when its printed and im not sure how to do it as all of that happens after the 'alv_grid_display' statement.

Any ideas??

Thanks

davejones84
 
Posts: 17
Joined: Mon Sep 03, 2007 7:46 am

Re: ALV display column in print only

Postby 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.
RACH002
 
Posts: 8
Joined: Mon Mar 17, 2008 1:52 pm

Re: ALV display column in print only

Postby davejones84 on Tue Apr 08, 2008 12:47 am

Hey Rach,

Two issues!

1. When i do 'print preview' the column is not visible and it also wont print out when you do 'print' from print preview.
2. Eventhough i use gs_fieldcat-outputlen = 30. in the fieldcat for the field and set it again later on just to be sure, the field doesnt come out that length on the printout. Think its cause its a blank field with no data, its there to be used to physically write something in it.

Any ideas?
davejones84
 
Posts: 17
Joined: Mon Sep 03, 2007 7:46 am

Re: ALV display column in print only

Postby RACH002 on Tue Apr 08, 2008 5:01 am

Hello Dave,

For point 1,
I was not able to find the print preview in my ALV to test your issue , But I think you can solve the problem by including the Function code of print preview in the table IT_EVENT_EXIT(same as we did for print).

For point 2,
Increase the length of the field header description (Not sure if it works but I remember I did this for the same issue some time back)
RACH002
 
Posts: 8
Joined: Mon Mar 17, 2008 1:52 pm


Return to ABAP

Who is online

Users browsing this forum: No registered users and 17 guests