Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

smartforms - send popup screen only once

Former Member
0 Likes
1,591

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

5 REPLIES 5
Read only

thomas_jung
Developer Advocate
Developer Advocate
0 Likes
1,140

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.

Read only

0 Likes
1,140

Thanks a lot. This does exactly what I needed.

Read only

0 Likes
1,140

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

Read only

0 Likes
1,140

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

Read only

0 Likes
1,140

Hi,

To make it work properly we need to send

USER_SETTINGS = ''

in the list of export parametes.

-Ashim