Skip to Content
-1

How to Print smartform directly through Background Program ?

Oct 13, 2016 at 09:09 AM

264

avatar image

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

max bianchi Oct 13, 2016 at 09:26 AM
2

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Sorry

I've wanted to mean what's ZPDF?

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

0
vipin saraika Oct 13, 2016 at 10:26 AM
0

It is defined as below:


printer.jpg (12.8 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded

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).

0