Skip to Content
avatar image
Former Member

how to convert the output of smartform to pdf format

how to convert the output of smartform to pdf format.I am executing vf03 for one smartform .I want to see the print preview of that one in pdf format

<MOVED BY MODERATOR TO THE CORRECT FORUM>

Edited by: Alvaro Tejada Galindo on Aug 8, 2008 5:32 PM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

9 Answers

  • avatar image
    Former Member
    Aug 08, 2008 at 09:58 AM

    Hi,

    Try the below code in the smartform driver program after the smartform function module call.

    otfdata should be imported from the smartforms calling function module

    i_otf = wa_tab_otf_data-otfdata.

    • converting smartform into PDF

    CALL FUNCTION 'CONVERT_OTF'

    EXPORTING

    format = 'PDF'

    max_linewidth = 132

    IMPORTING

    bin_filesize = ws_i_bin_filesize

    TABLES

    otf = i_otf

    lines = i_pdf_tab

    EXCEPTIONS

    err_max_linewidth = 1

    err_format = 2

    err_conv_not_possible = 3

    err_bad_otf = 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.

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

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

    ENDIF.

    *//--- File will be stored in SAP working directory of Presentation

    • Server which is the default directory for SAVE dialog box

    CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir

    CHANGING

    sapworkdir = ws_fullpath

    EXCEPTIONS

    get_sapworkdir_failed = 1

    cntl_error = 2

    error_no_gui = 3

    not_supported_by_gui = 4

    OTHERS = 5.

    CONCATENATE ws_fullpath '\' ws_c_vbeln '.pdf' INTO ws_fullpath.

    *//--- TO DOWNLOAD IN PRESENTATION SERVER

    CALL METHOD cl_gui_frontend_services=>gui_download

    EXPORTING

    bin_filesize = ws_i_bin_filesize

    filename = ws_fullpath

    filetype = 'BIN'

    CHANGING

    data_tab = i_pdf_tab

    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

    not_supported_by_gui = 22

    error_no_gui = 23

    OTHERS = 24.

    IF sy-subrc <> 0.

    MESSAGE i008(zv_fp).

    ENDIF.

    *//--- TO EXECUTE THE SAVED PDF

    CALL METHOD cl_gui_frontend_services=>execute

    EXPORTING

    document = ws_fullpath

    operation = 'OPEN'

    EXCEPTIONS

    cntl_error = 1

    error_no_gui = 2

    bad_parameter = 3

    file_not_found = 4

    path_not_found = 5

    file_extension_unknown = 6

    error_execute_failed = 7

    synchronous_failed = 8

    not_supported_by_gui = 9

    OTHERS = 10.

    IF sy-subrc <> 0.

    MESSAGE i008(zv_fp) .

    ENDIF.

    ENDIF.

    ENDIF.

    ENDIF.

    ENDFORM. " processing

    Thanks,

    Muthu

    Edited by: Muthu Prabakaran Selvam on Aug 8, 2008 3:29 PM

    Edited by: Muthu Prabakaran Selvam on Aug 8, 2008 3:31 PM

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      FYI...

      anything that starts with cl_gui_frontend_services

      do not work in background.

      thanks

      Edited by: BrightSide on Aug 8, 2008 11:03 AM

  • Aug 08, 2008 at 10:02 AM

    The Smart form Function will return the OTFDATA in

    the exporting parameter JOB_OUTPUT_INFO.

    JOB_OUTPUT_INFO-OTFDATA

    use this OTF data and convert it to pdf. use the Function modue CONVERT_OTF for conversion from OTF to PDF.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 08, 2008 at 10:04 AM

    Hi,

    SMARTFORM to PDF File format

    check this link for your answer.

    Regards,

    Nisrin.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 08, 2008 at 10:04 AM

    Hi,

    SMARTFORM to PDF File format

    check this link for your answer.

    Regards,

    Nisrin.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 08, 2008 at 10:06 AM

    hi.

    if the requirement is to just checking the form output in pdf

    than go to tcode'RSTXPDF4'.

    it asks for spool no. on further execution will download the pdf into your desired location.

    else you want pdf permanently in your driver program than

    check out this program:

    REPORT zsuresh_test.

    • Variable declarations

    DATA:

    w_form_name TYPE tdsfname VALUE 'ZSURESH_TEST',

    w_fmodule TYPE rs38l_fnam,

    w_cparam TYPE ssfctrlop,

    w_outoptions TYPE ssfcompop,

    W_bin_filesize TYPE i, " Binary File Size

    w_FILE_NAME type string,

    w_File_path type string,

    w_FULL_PATH type string.

    • Internal tables declaration

    • Internal table to hold the OTF data

    DATA:

    t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,

    • Internal table to hold OTF data recd from the SMARTFORM

    t_otf_from_fm TYPE ssfcrescl,

    • Internal table to hold the data from the FM CONVERT_OTF

    T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.

    • This function module call is used to retrieve the name of the Function

    • module generated when the SMARTFORM is activated

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING

    formname = w_form_name

    • VARIANT = ' '

    • DIRECT_CALL = ' '

    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

    • format of the output

    w_cparam-no_dialog = 'X'.

    w_cparam-preview = space. " Suppressing the dialog box

    " for print preview

    w_cparam-getotf = 'X'.

    • Printer name to be used is provided in the export parameter

    • OUTPUT_OPTIONS

    w_outoptions-tddest = 'LP01'.

    CALL FUNCTION w_fmodule

    EXPORTING

    • ARCHIVE_INDEX =

    • ARCHIVE_INDEX_TAB =

    • ARCHIVE_PARAMETERS =

    control_parameters = w_cparam

    • MAIL_APPL_OBJ =

    • MAIL_RECIPIENT =

    • MAIL_SENDER =

    output_options = w_outoptions

    • USER_SETTINGS = 'X'

    IMPORTING

    • DOCUMENT_OUTPUT_INFO =

    job_output_info = t_otf_from_fm

    • JOB_OUTPUT_OPTIONS =

    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_otf_from_fm-otfdata[].

    • Function Module CONVERT_OTF is used to convert the OTF format to PDF

    CALL FUNCTION 'CONVERT_OTF'

    EXPORTING

    FORMAT = 'PDF'

    MAX_LINEWIDTH = 132

    • ARCHIVE_INDEX = ' '

    • COPYNUMBER = 0

    • ASCII_BIDI_VIS2LOG = ' '

    • PDF_DELETE_OTFTAB = ' '

    IMPORTING

    BIN_FILESIZE = W_bin_filesize

    • BIN_FILE =

    TABLES

    otf = T_OTF

    lines = T_pdf_tab

    EXCEPTIONS

    ERR_MAX_LINEWIDTH = 1

    ERR_FORMAT = 2

    ERR_CONV_NOT_POSSIBLE = 3

    ERR_BAD_OTF = 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.

    • To display File SAVE dialog window

    CALL METHOD cl_gui_frontend_services=>file_save_dialog

    • EXPORTING

    • WINDOW_TITLE =

    • DEFAULT_EXTENSION =

    • DEFAULT_FILE_NAME =

    • FILE_FILTER =

    • INITIAL_DIRECTORY =

    • WITH_ENCODING =

    • PROMPT_ON_OVERWRITE = 'X'

    CHANGING

    filename = w_FILE_NAME

    path = w_FILE_PATH

    fullpath = w_FULL_PATH

    • USER_ACTION =

    • FILE_ENCODING =

    EXCEPTIONS

    CNTL_ERROR = 1

    ERROR_NO_GUI = 2

    NOT_SUPPORTED_BY_GUI = 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.

    • Use the FM GUI_DOWNLOAD to download the generated PDF file onto the

    • presentation server

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    BIN_FILESIZE = W_bin_filesize

    filename = w_FULL_PATH

    FILETYPE = 'BIN'

    • APPEND = ' '

    • WRITE_FIELD_SEPARATOR = ' '

    • HEADER = '00'

    • TRUNC_TRAILING_BLANKS = ' '

    • WRITE_LF = 'X'

    • COL_SELECT = ' '

    • COL_SELECT_MASK = ' '

    • DAT_MODE = ' '

    • CONFIRM_OVERWRITE = ' '

    • NO_AUTH_CHECK = ' '

    • CODEPAGE = ' '

    • IGNORE_CERR = ABAP_TRUE

    • REPLACEMENT = '#'

    • WRITE_BOM = ' '

    • TRUNC_TRAILING_BLANKS_EOL = 'X'

    • WK1_N_FORMAT = ' '

    • WK1_N_SIZE = ' '

    • WK1_T_FORMAT = ' '

    • WK1_T_SIZE = ' '

    • IMPORTING

    • FILELENGTH =

    tables

    data_tab = T_pdf_tab

    • FIELDNAMES =

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

    by.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 08, 2008 at 10:07 AM

    to get preview u can use

    Function module SSFCOMP_PDF_PREVIEW

    it will call Function module CONVERT_OTF for you internally.

    Edited by: mrugesh phatak on Aug 8, 2008 12:08 PM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 08, 2008 at 11:05 AM

    Hi

    Execute the program "RSTXPDFT4" with SPOOL ID.

    Hope it helps.

    Murthy

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 08, 2008 at 11:09 AM

    Just use function modules

    'CONVERT_OTF'

    rgds

    rajesh

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 26, 2008 at 02:28 PM

    run prog rstxpdft4

    Add comment
    10|10000 characters needed characters exceeded