04-12-2006 5:16 AM
Dear All,
I've created a new button (using PF-STATUS), then I want to make it has the same functionality like print button.
It means :
When a user click the button = When a user click print button.
Please help me...
Thank you in advance,
Sandi
04-12-2006 5:24 AM
Try to set your data before pushing icon print:
The function code for print is &RNT, so:
- active an exit event for it (perameter IT_EVENT_EXIT):
DATA: GT_EVENT_EXIT TYPE SLIS_T_EVENT_EXIT,
LT_EVENT_EXIT TYPE slis_event_exit.
LT_EVENT_EXIT-ucomm = '&RNT'.
LT_EVENT_EXIT-before = 'X'.
append LT_EVENT_EXIT to GT_EVENT_EXIT.
Now transfer it to fm ALV.
- Create a your routine for user-command:
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE R_UCOMM.
WHEN '&RNT'.
if rs_selfield-before_action = 'X'.
Here insert the code to set your data for print
endif.
WHEN OTHERS.
ENDCASE.
04-12-2006 5:24 AM
Try to set your data before pushing icon print:
The function code for print is &RNT, so:
- active an exit event for it (perameter IT_EVENT_EXIT):
DATA: GT_EVENT_EXIT TYPE SLIS_T_EVENT_EXIT,
LT_EVENT_EXIT TYPE slis_event_exit.
LT_EVENT_EXIT-ucomm = '&RNT'.
LT_EVENT_EXIT-before = 'X'.
append LT_EVENT_EXIT to GT_EVENT_EXIT.
Now transfer it to fm ALV.
- Create a your routine for user-command:
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE R_UCOMM.
WHEN '&RNT'.
if rs_selfield-before_action = 'X'.
Here insert the code to set your data for print
endif.
WHEN OTHERS.
ENDCASE.
04-12-2006 6:30 AM
Dear All,
Thank you for all your help especially Kishan Negi.
Best regards,
Sandi
04-16-2006 8:15 AM
Hi Kishan,
Thank you for your reply, the code works very smooth.
But I found one problem, how do we know if user click cancel in the printing window.
I dont want to execute the code when user click cancel button in the printing window.
Please I need help on this...
Thank you in advance.
Sandi
04-12-2006 5:31 AM
Hi Sandi,
Welcome to SDN.
You can call this FM <b>RS_COVERPAGE_SELECTIONS</b> for your custom print button.
Please check this sample code.
DATA: BEGIN OF MTAB_SEL_OPTIONS OCCURS 0,
FLAG(1) TYPE C,
OLENGTH TYPE X,
LINE LIKE RSVAR-INFOLINE,
END OF MTAB_SEL_OPTIONS.
CALL FUNCTION 'RS_COVERPAGE_SELECTIONS'
EXPORTING
REPORT = 'ZREPORT1' ' Name of current report
VARIANT = ''
NO_IMPORT = 'X'
TABLES
INFOTAB = MTAB_SEL_OPTIONS
EXCEPTIONS
ERROR_MESSAGE = 1
VARIANT_NOT_FOUND = 2
OTHERS = 3.
LOOP AT MTAB_SEL_OPTIONS.
WRITE: / MTAB_SEL_OPTIONS-LINE.
ENDLOOP.
Hope this will help.
Regards,
Ferry Lianto
04-12-2006 5:34 AM
Make use of the Print option given in the 'Standard Toolbar' (Function keys of STATUS) by passing the value as 'APRI'.