Skip to Content
author's profile photo
Former Member

ABAP-Smartforms

How to convert smartform layout into .PDF format?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • author's profile photo
    Former Member
    Posted on Aug 22, 2007 at 10:42 PM

    Hi,

    In the print program,

    1. Use FM CONVERT_OTF_2_PDF to convert smartform output (otf) to pdf. It will store converted data into an internal table.

    2. Use FM GUI_DOWNLOAD to download that internal table on the presentation server as a pdf file.

    Reward points if the answer is helpful.

    Regards,

    Mukul

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 03:19 AM

    Hi Ravi,

    Try This

    s_control_parameters-no_dialog = 'X'.

    s_control_parameters-getotf = 'X'.

    CALL FUNCTION v_func_name "call your smartform

    EXPORTING

    output_options = s_output_options

    control_parameters = s_control_parameters

    IMPORTING

    job_output_info = s_job_output_info

    call function 'CONVERT_OTF_2_PDF'

    tables

    otf = s_job_output_info-otfdata

    lines = t_pdf

    Example Program

    ****************

    data:

    fm_name TYPE RS38L_FNAM, "Smart Forms: FM Name

    sf_name TYPE TDSFNAME

    value 'YOUR_FORM_NAME', "Smart Forms: Form Name

    P_OUTPUT_OPTIONS TYPE SSFCOMPOP,

    P_JOB_OUTPUT_INFO TYPE SSFCRESCL,

    P_CONTROL_PARAMETERS TYPE SSFCTRLOP,

    P_LANGUAGE TYPE SFLANGU value 'E',

    P_E_DEVTYPE TYPE RSPOPTYPE.

    data:

    P_BIN_FILESIZE TYPE I,

    P_BIN_FILE TYPE XSTRING,

    P_OTF type table of ITCOO,

    P_DOCS type table of DOCS,

    P_LINES type table of TLINE,

    name type string,

    path type string,

    fullpath type string,

    filter type string,

    guiobj type ref to cl_gui_frontend_services,

    uact type i,

    filename(128).

    *"----


    GET SMARTFORM FUNCTION MODULE NAME ---

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING

    FORMNAME = sf_name

    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.

    CALL FUNCTION 'SSF_GET_DEVICE_TYPE'

    EXPORTING

    I_LANGUAGE = P_LANGUAGE

    I_APPLICATION = 'SAPDEFAULT'

    IMPORTING

    E_DEVTYPE = P_E_DEVTYPE.

    P_OUTPUT_OPTIONS-XSFCMODE = 'X'.

    P_OUTPUT_OPTIONS-XSF = SPACE.

    P_OUTPUT_OPTIONS-XDFCMODE = 'X'.

    P_OUTPUT_OPTIONS-XDF = SPACE.

    P_OUTPUT_OPTIONS-TDPRINTER = P_E_DEVTYPE.

    P_CONTROL_PARAMETERS-NO_DIALOG = 'X'.

    P_CONTROL_PARAMETERS-GETOTF = 'X'.

    *

    ****...................................PRINTING.........................

    CALL FUNCTION fm_name

    EXPORTING

    CONTROL_PARAMETERS = P_CONTROL_PARAMETERS

    OUTPUT_OPTIONS = P_OUTPUT_OPTIONS

    • (....) <--- your form import parameters

    IMPORTING

    JOB_OUTPUT_INFO = P_JOB_OUTPUT_INFO.

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    P_OTF[] = P_JOB_OUTPUT_INFO-OTFDATA.

    ****...................................CONVERT TO PDF...............

    CALL FUNCTION 'CONVERT_OTF_2_PDF'

    IMPORTING

    BIN_FILESIZE = P_BIN_FILESIZE

    TABLES

    OTF = P_OTF

    DOCTAB_ARCHIVE = P_DOCS

    LINES = P_LINES

    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 'xxxx' '.pdf' into name.

    ****..................................REQUEST FILE NAME.................

    create object guiobj.

    call method guiobj->file_save_dialog

    EXPORTING

    default_extension = 'pdf'

    default_file_name = name

    file_filter = filter

    CHANGING

    filename = name

    path = path

    fullpath = fullpath

    user_action = uact.

    if uact = guiobj->action_cancel.

    exit.

    endif.

    move fullpath to filename.

    ****..................................DOWNLOAD AS FILE................

    CALL FUNCTION 'WS_DOWNLOAD'

    EXPORTING

    BIN_FILESIZE = P_BIN_FILESIZE

    FILENAME = filename

    FILETYPE = 'BIN'

    TABLES

    DATA_TAB = P_LINES

    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

    NO_AUTHORITY = 10

    OTHERS = 11.

    .

    IF SY-SUBRC <> 0.

    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    Regards,

    Murali

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 23, 2007 at 03:21 AM

    Follow the below steps.

    1) call function 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING

    formname = formname

    variant = ' '

    direct_call = ' '

    IMPORTING

    fm_name = fm_name

    EXCEPTIONS

    no_form = 1

    no_function_module = 2

    others = 3.

    2) control_param-no_dialog = 'X'.

    control_param-preview = ''.

    control_param-getotf = 'X'.

    output_opt-tddest = 'LOCL'.

    output_opt-tdimmed = ''.

    output_opt-tdnewid = ''.

    output_opt-tdnoprint = ''.

    output_opt-tdnoprev = 'X'.

    call function fm_name

    EXPORTING

    control_parameters = control_param

    output_options = output_opt

    user_settings = ' '

    IMPORTING

    job_output_info = job_info

    TABLES

    int_detail = int_detail

    EXCEPTIONS

    formatting_error = 1

    internal_error = 2

    send_error = 3

    user_canceled = 4

    others = 5.

    3) DATA: filesize type i.

    DATA : job_info type ssfcrescl.

    data: int_docs type standard table of docs,

    int_line type standard table of tline.

    call function 'CONVERT_OTF_2_PDF'

    IMPORTING

    bin_filesize = filesize

    TABLES

    otf = job_info-otfdata

    doctab_archive = int_docs

    lines = int_line

    EXCEPTIONS

    err_conv_not_possible = 1

    err_otf_mc_noendmarker = 2

    others = 3.

    or You can use

    CALL FUNCTION 'CONVERT_OTF'

    • EXPORTING

    • FORMAT = 'PDF'

    • MAX_LINEWIDTH = 255

    • ARCHIVE_INDEX = ' '

  • IMPORTING

  • BIN_FILESIZE = filesize

  • TABLES

  • OTF = job_info-otfdata

  • LINES = int_line

  • EXCEPTIONS

  • ERR_MAX_LINEWIDTH = 1

  • ERR_FORMAT = 2

  • ERR_CONV_NOT_POSSIBLE = 3

  • OTHERS = 4

  • 4) For downloading it into PDF

    call method cl_gui_frontend_services=>gui_download

    exporting

    bin_filesize = filesize

    filename = filename

    filetype = 'BIN'

    changing

    data_tab = int_line

    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

    .

    CLose the thread once your question is answered. Don't forget to reward points.

    Regards,

    Sairam

Add comment
10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 04:03 AM

    try this program RSTXPFD4 and give the spool request number it the downloads form into PFD format

    Add comment
    10|10000 characters needed characters exceeded