Skip to Content
author's profile photo Former Member
Former Member

SMARTFORM TO PDF FORMAT

Hi All,

I have a requirement to get a print preview of the smartform in the pdf format and have the option to either print it or save it.

meaning - the adobe application must automatically open and in it, there must be a window to display the smartform in the PDF format.

the code i have so far is as below

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = W_FORM_NAME

IMPORTING

FM_NAME = W_FMODULE

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.

  • Calling the SMARTFORM using the function module retrieved above

  • GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF

gst_output_options-tddest = 'FRNT_End_Print'. "Frontend printer

gst_output_options-tdnewid = sy-prnew.

gst_output_options-tdimmed = 'X'.

gst_output_options-tddelete = sy-prrel.

clear gst_control_parameters.

gst_control_parameters-no_dialog = 'X'.

gst_control_parameters-getotf = 'X'.

gst_control_parameters-preview = 'X'. "Deactivate preview!

*Call the original function module.

call function w_fmodule

exporting

control_parameters = gst_control_parameters

output_options = gst_output_options

importing

job_output_info = gt_job_output_info

job_output_options = gt_output_options

tables

tbl_amt = final_tab

exceptions

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4.

if sy-subrc ne 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

T_OTF[] = gt_job_output_info-OTFDATA[].

call function 'SSFCOMP_PDF_PREVIEW'

exporting

i_otf = t_otf

exceptions

convert_otf_to_pdf_error = 1

cntl_error = 2

others = 3.

if sy-subrc ne 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

The adobe application is launched but the window inside does not hold anything.

i get a pop-up inside the adobe window with the message " FILE DOES NOT BEGIN WITH '%PDF-' ".

Any suggestions are greatly appreciated.

hoping to hear from you all.

thank you.

Sandeep

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Apr 02, 2008 at 05:54 AM

    Hi Sandeep,

    Plz try with this code this code is working properly.

    DATA: form_name TYPE rs38l_fnam.
    DATA: wa_ctrlop TYPE ssfctrlop,
    wa_outopt TYPE ssfcompop.
    DATA: t_otfdata TYPE ssfcrescl,
    t_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA: t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE.
    DATA: w_filesize TYPE i.
    DATA: w_bin_filesize TYPE i.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    formname = 'ZSM_PDF_1'
    * VARIANT = ' '
    * DIRECT_CALL = ' '
    IMPORTING
    fm_name = form_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.
    wa_ctrlop-getotf = 'X'.
    wa_ctrlop-no_dialog = 'X'.
    wa_outopt-tdnoprev = 'X'.
    CALL FUNCTION form_name
    EXPORTING
    * ARCHIVE_INDEX =
    * ARCHIVE_INDEX_TAB =
    * ARCHIVE_PARAMETERS =
    control_parameters = wa_ctrlop
    * MAIL_APPL_OBJ =
    * MAIL_RECIPIENT =
    * MAIL_SENDER =
    output_options = wa_outopt
    user_settings = 'X'
    mydate = F_DATE
    IMPORTING
    * DOCUMENT_OUTPUT_INFO =
    job_output_info = t_otfdata
    * JOB_OUTPUT_OPTIONS =
     TABLES
         ITAB = ITAB
    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.
    t_otf[] = t_otfdata-otfdata[].
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    format = 'PDF'
    max_linewidth = 132
    * ARCHIVE_INDEX = ' '
    IMPORTING
    bin_filesize = w_bin_filesize
    TABLES
    otf = t_otf
    lines = t_pdf_tab
    EXCEPTIONS
    err_max_linewidth = 1
    err_format = 2
    err_conv_not_possible = 3
    OTHERS = 4
    .
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
    bin_filesize = w_bin_filesize
    * CODEPAGE = ' '
    filename = 'C:\Users\KO58\Desktop\test1.pdf'
    filetype = 'BIN'
    * MODE = ' '
    * WK1_N_FORMAT = ' '
    * WK1_N_SIZE = ' '
    * WK1_T_FORMAT = ' '
    * WK1_T_SIZE = ' '
    * COL_SELECT = ' '
    * COL_SELECTMASK = ' '
    * NO_AUTH_CHECK = ' '
    IMPORTING
    filelength = w_filesize
    TABLES
    data_tab = t_pdf_tab
    * FIELDNAMES =
    EXCEPTIONS
    file_open_error = 1
    file_write_error = 2
    invalid_filesize = 3
    invalid_type = 4
    no_batch = 5
    unknown_error = 6
    invalid_table_width = 7
    gui_refuse_filetransfer = 8
    customer_error = 9
    OTHERS = 10
    .
    IF sy-subrc <> 0.
    MESSAGE i003(z00) WITH 'File not downloaded succesfully'.
    ELSE.
    MESSAGE i003(z00) WITH 'File Test.pdf downloaded succesfully '
    'under D drive'.
    ENDIF.

    If usefull plz give rewards.

    Cheers

    Anirudh

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.