cancel
Showing results for 
Search instead for 
Did you mean: 

How to Print smartform directly through Background Program ?

Former Member
0 Kudos

Dear Gurus,

I have an requirement where I need to Print smartform directly through background job.

The same I have developed and it is only printing smartform if i execute in front end if I schedule my program in background spool is getting generated but print is not happening.Below is the code I am using.Please suggest

REPORT ztest_label.

CALL FUNCTION 'ZPPFM_LABEL'.

FUNCTION zppfm_label.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(GS_LABEL) TYPE ZPPS_REBAR_LABEL OPTIONAL
*" CHANGING
*" REFERENCE(GS_LABEL1) TYPE ZPPS_REBAR_LABEL OPTIONAL
*"----------------------------------------------------------------------
BREAK-POINT.
gs_label1-num_charge = '2114-0547'. "wa_ppt_bundle-num_charge.
gs_label1-spec = 'ASTM GRADE 60'."wa_ppt_bundle-spec.
gs_label1-grade = '60'."wa_ppt_bundle-grade.
gs_label1-size = 'RB 2'."wa_ppt_bundle-zsize.
gs_label1-length = '8 M'."wa_ppt_bundle-lenght.
gs_label1-nom_weight = '2000'."wa_ppt_bundle-weight.
gs_label1-num_bar = 8.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lc_formname
IMPORTING
fm_name = lv_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc EQ 0.
ENDIF.

CLEAR: ls_control_param, ls_output_options.


*--control parameters
ls_control_param-no_dialog = 'X'. " To hide the print priview screen
ls_control_param-device = 'PRINTER'.


*--output options
ls_output_options-tddest = 'ZPDF'. "name of printer
ls_output_options-tdnoprev = 'X'. "preview
ls_output_options-tdimmed = 'X'.

CALL FUNCTION lv_fm_name "'/1BCDWB/SF00000047'
EXPORTING
control_parameters = ls_control_param
output_options = ls_output_options
user_settings = space
i_itab = gs_label1
* IMPORTING
* DOCUMENT_OUTPUT_INFO =
* JOB_OUTPUT_INFO =
* JOB_OUTPUT_OPTIONS =
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFUNCTION.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member

Hi

What's PRINTER?

If it's the front-end printer, it can't work in a background process, but you need to use local printer defined in SAP

Max

Former Member
0 Kudos

Sorry

I've wanted to mean what's ZPDF?

Check how it's defined: probably is a front-end printer

Former Member
0 Kudos

It is defined as below:

Sandra_Rossi
Active Contributor
0 Kudos

So, what is your conclusion? Don't you see "G: Front End ..."? Max told you that if it's front-end, it can't work in background. As Max said, choose a local printer (type L).