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

smart form to PDF

hi experts

i would like to know is it possible to convert a smartform output to

PDF file directly with out creation SPOOL REQUEST.

can any body help me

regards

chandra

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Feb 27, 2007 at 06:52 AM

    hi chandra,

    REPORT yKTREE_smartform1_new .

    ***************************DECLARATIONS*******************************

    TABLES: zKTREE_t1,sflight.

    DATA: cparam TYPE ssfctrlop,

    outop TYPE ssfcompop,

    fm_name TYPE rs38l_fnam,

    my_tabix TYPE sy-tabix,

    file_size TYPE i,

    bin_filesize TYPE i.

    DATA: tab_otf_data TYPE ssfcrescl,

    pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,

    itab LIKE TABLE OF zshail_t1 WITH HEADER LINE,

    otab TYPE TABLE OF sflight WITH HEADER LINE,

    tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE.

    start-of-selection.

    • suppressing the dialog box****************************

    outop-tddest = 'LP01'.

    cparam-no_dialog = 'X'.

    cparam-preview = space.

    cparam-getotf = 'X'.

    ****************for the first smartform*******************************

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING

    formname = 'ZSHAIL_SMFORM2'

    • VARIANT = ' '

    • DIRECT_CALL = ' '

    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.

    SELECT my_id my_income my_name FROM zshail_t1 INTO TABLE itab.

    CALL FUNCTION fm_name

    EXPORTING

    • ARCHIVE_INDEX =

    • ARCHIVE_INDEX_TAB =

    • ARCHIVE_PARAMETERS =

    control_parameters = cparam

    • MAIL_APPL_OBJ =

    • MAIL_RECIPIENT =

    • MAIL_SENDER =

    output_options = outop

    user_settings = space

    IMPORTING

    • DOCUMENT_OUTPUT_INFO =

    job_output_info = tab_otf_data

    • JOB_OUTPUT_OPTIONS =

    TABLES

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

    *********appending the otf data into the final table*********************

    tab_otf_final[] = tab_otf_data-otfdata[].

    *************for the second smartform************************************

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING

    formname = 'ZSHAIL_SMTAB'

    • VARIANT = ' '

    • DIRECT_CALL = ' '

    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.

    SELECT carrid connid fldate price FROM sflight INTO CORRESPONDING FIELDS

    OF TABLE otab.

    CALL FUNCTION fm_name

    EXPORTING

    • ARCHIVE_INDEX =

    • ARCHIVE_INDEX_TAB =

    • ARCHIVE_PARAMETERS =

    control_parameters = cparam

    • MAIL_APPL_OBJ =

    • MAIL_RECIPIENT =

    • MAIL_SENDER =

    output_options = outop

    user_settings = space

    IMPORTING

    • DOCUMENT_OUTPUT_INFO =

    job_output_info = tab_otf_data

    • JOB_OUTPUT_OPTIONS =

    TABLES

    itab = otab[]

    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.

    **removing the initial and final markers from the OTF data*********

    DELETE tab_otf_data-otfdata WHERE tdprintcom = '//'.

    • searching for the end-of-page in OTF table************

    READ TABLE tab_otf_final WITH KEY tdprintcom = 'EP'.

    my_tabix = sy-tabix + 1.

    • appending the modified OTF table to the final OTF table****

    INSERT LINES OF tab_otf_data-otfdata INTO tab_otf_final INDEX my_tabix.

    • converting OTF data into pdf data**************************

    CALL FUNCTION 'CONVERT_OTF'

    EXPORTING

    format = 'PDF'

    max_linewidth = 132

    • ARCHIVE_INDEX = ' '

    • COPYNUMBER = 0

    • ASCII_BIDI_VIS2LOG = ' '

    IMPORTING

    bin_filesize = bin_filesize

    • BIN_FILE =

    TABLES

    otf = tab_otf_final

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

    ************downloading the converted PDF data to your local PC*******

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    bin_filesize = bin_filesize

    filename = 'D:\TEST.PDF'

    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'

    IMPORTING

    filelength = file_size

    TABLES

    data_tab = 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

    .

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 27, 2007 at 08:20 AM

    Yes try this code

    REPORT ZSMART_TEXT_PDF.

    .

    DATA : FM_NAME TYPE RS38L_FNAM.

    • IT_VENDOR LIKE TABLE OF ZVENDOR,

    • IT_MATERIAL LIKE TABLE OF ZMATERIAL,

    • IT_PO LIKE TABLE OF ZPURCHASEORDER.

    DATA: CTRLPARAMS TYPE SSFCTRLOP,

    JOBOUTPUT TYPE SSFCRESCL,

    TLINES LIKE TABLE OF TLINE,

    IT_FILETABLE LIKE TABLE OF FILE_TABLE WITH HEADER LINE,

    FNAME TYPE STRING,

    RC TYPE I,

    BIN_SIZE TYPE I.

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING

    FORMNAME = 'ZSMART'

    • VARIANT = ' '

    • DIRECT_CALL = ' '

    IMPORTING

    FM_NAME = FM_NAME.

    CTRLPARAMS-preview = 'X'.

    CTRLPARAMS-no_dialog = 'X'.

    CTRLPARAMS-GETOTF = 'X'.

    CALL FUNCTION FM_NAME

    EXPORTING

    • ARCHIVE_INDEX =

    • ARCHIVE_INDEX_TAB =

    • ARCHIVE_PARAMETERS =

    CONTROL_PARAMETERS = CTRLPARAMS

    • MAIL_APPL_OBJ =

    • MAIL_RECIPIENT =

    • MAIL_SENDER =

    • OUTPUT_OPTIONS = ''

    • USER_SETTINGS = 'X'

    IMPORTING

    • DOCUMENT_OUTPUT_INFO =

    JOB_OUTPUT_INFO = JOBOUTPUT

    • JOB_OUTPUT_OPTIONS =

    • TABLES

    • IT_VENDOR = IT_VENDOR

    • IT_PO = IT_PO

    • IT_MATERIAL = IT_MATERIAL.

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

    CALL FUNCTION 'CONVERT_OTF'

    EXPORTING

    FORMAT = 'PDF'

    • MAX_LINEWIDTH = 132

    • ARCHIVE_INDEX = ' '

    • COPYNUMBER = 0

    IMPORTING

    BIN_FILESIZE = BIN_SIZE

    TABLES

    OTF = JOBOUTPUT-OTFDATA

    LINES = TLINES

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

    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG

    EXPORTING

    WINDOW_TITLE = 'ENTER A FILENAME'

    DEFAULT_FILENAME = 'REPORT.PDF'

    FILE_FILTER = '*.PDF'

    INITIAL_DIRECTORY = 'C:\'

    CHANGING

    FILE_TABLE = IT_FILETABLE[]

    RC = RC.

    LOOP AT IT_FILETABLE.

    FNAME = IT_FILETABLE-FILENAME.

    ENDLOOP.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    BIN_FILESIZE = BIN_SIZE

    FILENAME = FNAME

    FILETYPE = 'BIN'

    TABLES

    DATA_TAB = tlines.

    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.