2004 Mar 03 7:51 AM
Hi all,
We have the following problem: our application should print some document (a Smartform) for all selected documents in an ALV Grid control. So the application does a loop over an internal table and calls every time the function for the Smartform, passing it some data to print.
For every function call the user sees a popup screen where he/she can choose the printer, whether or not to print directly, print preview etc. The problem is - if the user selects 20 documents to print he/she will see that screen 20 times, and that's not nice. It would be better if the user saw the popup screen only once and the settings he chose were passed to all the calls of the smartform in the loop.
Any idea how to do it?
thanks,
Ioana
Hi all,
We have the following problem: our application should print some document (a Smartform) for all selected documents in an ALV Grid control. So the application does a loop over an internal table and calls every time the function for the Smartform, passing it some data to print.
For every function call the user sees a popup screen where he/she can choose the printer, whether or not to print directly, print preview etc. The problem is - if the user selects 20 documents to print he/she will see that screen 20 times, and that's not nice. It would be better if the user saw the popup screen only once and the settings he chose were passed to all the calls of the smartform in the loop.
Any idea how to do it?
thanks,
Ioana
2004 Mar 03 6:20 PM
This is fairly easy. First before you call the generated function module for the SmartForm, you want to check and see if this is the first call. If it is you can ask the functino module to show the printer dialog. Otherwise you will not show it.
****Set Control parameters for the Smart Form
if first = ''.
move 'X' to first.
clear control-no_dialog.
else.
move 'X' to control-no_dialog.
endif.
Then go ahead and call the generated function module:
****Call the Smart Form generated function module
move-corresponding job_output_options to output_options.
call function fm_name
exporting
control_parameters = control
output_options = output_options
edidc = edidc
invoice_header = header
invoice_totals = invoice_totals
invoice_po = invoice_po
importing
job_output_info = job_output_info
job_output_options = job_output_options
tables
invoice_lines = invoice_lines[]
htext = htext[]
hnotes = hnotes[]
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
You should notice that there is an importing parameter called job_output_options. This will contain all the printer selection options from the first dialog call. On the later calls you just set the no-dialog flag. You then can pass thes output options back in the function module with exporting parameter output options.
2004 Mar 04 1:54 PM
Thanks a lot. This does exactly what I needed.
2004 Mar 11 10:20 AM
I Tried the way as u said with a small example..but its not working here is the code..
FORM process_form.
DATA: v_flag type i value 1.
do 3 times.
if v_flag = 1.
v_flag = 0.
CLEAR CONTROL_PARAMETERS-NO_DIALOG.
ELSE.
MOVE 'X' TO CONTROL_PARAMETERS-NO_DIALOG.
MOVE-CORRESPONDING JOB_OUTPUT_OPTIONS TO OUTPUT_OPTIONS.
endif.
CALL FUNCTION '/1BCDWB/SF00000093'
EXPORTING
CONTROL_PARAMETERS = CONTROL_PARAMETERS
OUTPUT_OPTIONS = output_options
IMPORTING
JOB_OUTPUT_INFO = JOB_OUTPUT_INFO
JOB_OUTPUT_OPTIONS = JOB_OUTPUT_OPTIONS
TABLES
IT_CUSTOMERS = it_customers
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
enddo.
endform.
logically even i feel that i code is right..but i don't know y it is not working.so could u please suggest me, what i should do.am i doing wrong anywhere.please check and let me know..awaiting for ur response.
bye
yogi raj
2004 Mar 12 7:50 AM
This looks ok - this kind of logic worked fine for me.
Maybe there is some other error?
You can try to remove the comment in front of your 'EXCEPTIONS' part in the function and do some error catching:
CALL FUNCTION FM_NAME
EXPORTING
CONTROL_PARAMETERS = ctrl_para
OUTPUT_OPTIONS = output_options
IMPORTING
JOB_OUTPUT_OPTIONS = job_output_options
TABLES
...
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
data: errortab type TSFERROR.
CALL FUNCTION 'SSF_READ_ERRORS'
IMPORTING
ERRORTAB = errortab.
ENDIF.
bye
ioana
2005 Dec 19 9:57 AM
Hi,
To make it work properly we need to send
USER_SETTINGS = ''
in the list of export parametes.
-Ashim