Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Smartform to PDF, how to suppres Print/Preview dialog

Hi Experts,

Facing some issues in downloading PDF converted from Smartform.

In the program I am trying directly download a smartform converted into PDF format and save it in local system.

When ever I am trying to execute the program it shows up the Print/Preview dialog before showing the Save As dialog.

I have passed control_parameters-getotf = 'X' to the smartform runtime FM, which ideally should have suppressed the Print/Preview dialog and return the otfdata.

Here the entire code is...

REPORT yfr_invoice.

TABLES : t001, bsad, bsid, kna1,sscrfields .

DATA : fm_name TYPE rs38l_fnam.

DATA : it_bsad TYPE STANDARD TABLE OF bsad.

DATA : BEGIN OF it_bseg OCCURS 0,

belnr TYPE belnr_d,

END OF it_bseg.

DATA : error_flag.

DATA:

cont_param TYPE ssfctrlop,

out_param TYPE ssfcompop,

otfdata TYPE ssfcrescl,

t_tline TYPE TABLE OF tline INITIAL SIZE 0,

t_docs TYPE STANDARD TABLE OF docs,

v_filesize TYPE i,

v_name TYPE string,

v_path TYPE string,

v_fullpath TYPE string,

v_filename TYPE string,

v_filter TYPE string.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.

SELECT-OPTIONS : s_bukrs FOR t001-bukrs NO-EXTENSION NO INTERVALS OBLIGATORY.

SELECT-OPTIONS : s_gjahr FOR bsid-gjahr NO-EXTENSION NO INTERVALS OBLIGATORY.

SELECT-OPTIONS : s_rebzg FOR bsid-rebzg OBLIGATORY.

SELECT-OPTIONS : s_kunnr FOR kna1-kunnr.

SELECTION-SCREEN END OF BLOCK b1.

INITIALIZATION.

START-OF-SELECTION.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'YFF_INVOICE'

IMPORTING

fm_name = fm_name

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

cont_param-getotf = 'X'.

cont_param-no_dialog = 'X'.

cont_param-preview = 'X' .

CALL FUNCTION fm_name

EXPORTING

control_parameters = cont_param "Passing getotf = 'X'

IMPORTING

job_output_info = otfdata

TABLES

s_bukrs = s_bukrs[]

s_gjahr = s_gjahr[]

s_rebzg = s_rebzg[]

s_kunnr = s_kunnr[]

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.

ELSE.

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

bin_filesize = v_filesize

TABLES

otf = otfdata-otfdata

doctab_archive = t_docs

lines = t_tline

EXCEPTIONS

err_conv_not_possible = 1

err_otf_mc_noendmarker = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CONCATENATE 'filename' '.pdf' INTO v_name.

CALL METHOD cl_gui_frontend_services=>file_save_dialog

EXPORTING

default_extension = 'PDF'

default_file_name = v_name

file_filter = v_filter

CHANGING

filename = v_name

path = v_path

fullpath = v_fullpath.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = v_filesize

filename = v_fullpath "'C:\Test.pdf'

filetype = 'BIN'

TABLES

data_tab = t_tline

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDIF.

ENDIF.

The program other wise works absolutly fine .

Please advise.

Thanks

Jahan

Former Member
Not what you were looking for? View more on this topic or Ask a question