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

Convert Smartform to word document or PDF to word?

Hi All,

I need to convert <b>smartform</b> output to <b>word document</b> or <b>PDF</b> out put to <b>word document</b>. Have anyone done such conversion before? Reason I need to do this because customer to return will edit output form. Any code reference or thread reference or function module to this kind of conversion will be of great help. Thanks in advance.

Regards,

Tim

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Posted on Oct 04, 2006 at 01:13 AM

    Hi Tim,

    Converting the output from Spool to Word is possible.

    Here is the sample code.

    convert-a-spool-id-into-a-word-document

    Best regards,

    Prashant

    Pls mark points for helpful answers

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 04, 2006 at 01:55 AM

    Hi Tim,

    Please check this sample codes from other thread perhaps it may help.

    CALL FUNCTION fm_name        " '/1BCDWB/SF00000031'
      EXPORTING
        control_parameters = control_parameters
        output_options     = output_options
        s_header           = st_header
      IMPORTING
        job_output_info = output_data
      TABLES
        it_overdue = ITAB[]
      EXCEPTIONS
        formatting_error = 1
        internal_error   = 2
        send_error       = 3
        user_canceled    = 4
        OTHERS           = 5.
    
    * now convert the final document (OTF format) into PDF 
    format
    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        format = 'DOC'
      IMPORTING
        bin_filesize = v_pdf_len
      TABLES
        otf   = output_data-otfdata
        lines = pdf_table
      EXCEPTIONS
        err_max_linewidth     = 1
        err_format            = 2
        err_conv_not_possible = 3
        err_bad_otf           = 4
        OTHERS                = 5.
    
    ** Downloading the PDF file to the local Server
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        FILENAME = L_FILENAME
        FILETYPE = C_BIN_FILETYPE
      TABLES
        DATA_TAB = lt_pdf_nuc_data
      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.

    Regards,

    Ferry Lianto

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 04, 2006 at 05:30 AM

    hi,

    chk this.

    ia m converting the smart gorm to pdf and sending it as email.

    • Internal Table declarations

    DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,

    i_tline TYPE TABLE OF tline WITH HEADER LINE,

    i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,

    i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,

    • Objects to send mail.

    i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,

    i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,

    i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,

    i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,

    • Work Area declarations

    wa_objhead TYPE soli_tab,

    w_ctrlop TYPE ssfctrlop,

    w_compop TYPE ssfcompop,

    w_return TYPE ssfcrescl,

    wa_doc_chng typE sodocchgi1,

    w_data TYPE sodocchgi1,

    wa_buffer TYPE string,"To convert from 132 to 255

    • Variables declarations

    v_form_name TYPE rs38l_fnam,

    v_len_in LIKE sood-objlen,

    v_len_out LIKE sood-objlen,

    v_len_outn TYPE i,

    v_lines_txt TYPE i,

    v_lines_bin TYPE i.

    call function 'SSF_FUNCTION_MODULE_NAME'

    exporting

    formname = 'ZZZ_TEST1'

    importing

    fm_name = v_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.

    w_ctrlop-getotf = 'X'.

    w_ctrlop-no_dialog = 'X'.

    w_compop-tdnoprev = 'X'.

    CALL FUNCTION v_form_name

    EXPORTING

    control_parameters = w_ctrlop

    output_options = w_compop

    user_settings = 'X'

    IMPORTING

    job_output_info = w_return

    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.

    i_otf[] = w_return-otfdata[].

    call function 'CONVERT_OTF'

    EXPORTING

    format = 'PDF'

    max_linewidth = 132

    IMPORTING

    bin_filesize = v_len_in

    TABLES

    otf = i_otf

    lines = i_tline

    EXCEPTIONS

    err_max_linewidth = 1

    err_format = 2

    err_conv_not_possible = 3

    others = 4.

    • Fehlerhandling

    if sy-subrc <> 0.

    endif.

    loop at i_tline.

    translate i_tline using '~'.

    concatenate wa_buffer i_tline into wa_buffer.

    endloop.

    translate wa_buffer using '~'.

    do.

    i_record = wa_buffer.

    append i_record.

    shift wa_buffer left by 255 places.

    if wa_buffer is initial.

    exit.

    endif.

    enddo.

    • Attachment

    refresh:

    i_reclist,

    i_objtxt,

    i_objbin,

    i_objpack.

    clear wa_objhead.

    i_objbin[] = i_record[].

    • Create Message Body

  • Title and Description

  • i_objtxt = 'test with pdf-Attachment!'.

    append i_objtxt.

    describe table i_objtxt lines v_lines_txt.

    read table i_objtxt index v_lines_txt.

    wa_doc_chng-obj_name = 'smartform'.

    wa_doc_chng-expiry_dat = sy-datum + 10.

    wa_doc_chng-obj_descr = 'smartform'.

    wa_doc_chng-sensitivty = 'F'.

    wa_doc_chng-doc_size = v_lines_txt * 255.

    • Main Text

  • wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )

  • *.

    clear i_objpack-transf_bin.

    i_objpack-head_start = 1.

    i_objpack-head_num = 0.

    i_objpack-body_start = 1.

    i_objpack-body_num = v_lines_txt.

    i_objpack-doc_type = 'RAW'.

    append i_objpack.

    • Attachment

  • (pdf-Attachment)

  • i_objpack-transf_bin = 'X'.

    i_objpack-head_start = 1.

    i_objpack-head_num = 0.

    i_objpack-body_start = 1.

    • Länge des Attachment ermitteln

    describe table i_objbin lines v_lines_bin.

    read table i_objbin index v_lines_bin.

    i_objpack-doc_size = v_lines_bin * 255 .

    i_objpack-body_num = v_lines_bin.

    i_objpack-doc_type = 'PDF'.

    i_objpack-obj_name = 'smart'.

    i_objpack-obj_descr = 'test'.

    append i_objpack.

    clear i_reclist.

    i_reclist-receiver = 'zyz@wipro.com'.

    i_reclist-rec_type = 'U'.

    append i_reclist.

    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    EXPORTING

    document_data = wa_doc_chng

    put_in_outbox = 'X'

    TABLES

    packing_list = i_objpack

    object_header = wa_objhead

    CONTENTS_BIN = i_objbin

    contents_txt = i_objtxt

    receivers = i_reclist

    EXCEPTIONS

    too_many_receivers = 1

    document_not_sent = 2

    document_type_not_exist = 3

    operation_no_authorization = 4

    parameter_error = 5

    x_error = 6

    enqueue_error = 7

    others = 8.

    rgds

    anver

    pls mark all hlpful answers

Add a comment
10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 04, 2006 at 06:47 AM

    HI Tim,

    Plz check this code..

    DATA: fs_output_options TYPE ssfcompop,

    fs_control_parameters TYPE ssfctrlop.

    DATA: fm_name TYPE rs38l_fnam.

    data : wf_pdf_len LIKE sood-objlen.

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING

    formname = 'SMARTFORMNAME'"Smartform name

    IMPORTING

    fm_name = fm_name

    EXCEPTIONS

    no_form = 1

    no_function_module = 2

    OTHERS = 3.

    IF sy-subrc <> 0.

    • error handling

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

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

    EXIT.

    ENDIF.

    *to get the smartform content**********

    CALL FUNCTION fm_name "/1BCDWB/SF01100828

    EXPORTING

    control_parameters = fs_control_parameters

    output_options = fs_output_options

    hrdata = hrdata

    IMPORTING

    job_output_info = fs_output_data

    TABLES

    it_shiphdr = int_shiphdr

    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.

    *--> Convert to OTF format

    CALL FUNCTION 'CONVERT_OTF'

    EXPORTING

    format = 'PDF'

    IMPORTING

    bin_filesize = wf_pdf_len

    TABLES

    otf = fs_output_data-otfdata

    lines = int_lines

    EXCEPTIONS

    err_max_linewidth = 1

    err_format = 2

    err_conv_not_possible = 3

    err_bad_otf = 4

    OTHERS = 5.

    IF sy-subrc <> 0.

    WRITE 'error_otf'.

    ENDIF.

    ******to download and check

    daTA : p_file LIKE rlgrap-filename VALUE 'C:\Documents and Settings\Desktop\test.pdf'.

    data : file type string.

    file = p_file.

    data : wf_len_in1 type i.

    wf_len_in1 = wf_pdf_len.

    CALL FUNCTION 'GUI_DOWNLOAD'

    EXPORTING

    BIN_FILESIZE = wf_len_in1

    FILENAME = file

    FILETYPE = 'BIN'

    TABLES

    DATA_TAB = int_lines.

    Regards,

    Ajith

    Mark if useful.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 16, 2009 at 10:22 AM

    This message was moderated.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 31, 2013 at 07:09 AM

    Trim C 撰写:

    Hi All,

    I need to convert <b>smartform</b> output to <b>word document</b> or <b>PDF</b> out put to <b>word document</b>. Have anyone done such conversion before? Reason I need to do this because customer to return will edit output form. Any code reference or thread reference or function module to this kind of conversion will be of great help. Thanks in advance.

    well, I just know such one useful blog to help you convert PDF to word easily: Free PDF to Word Solutions Reviews | XFlip Blog

    Regards,

    Tim

    Hi, dear, the topic is really very fun, you could try to use some tool by google search, hope it helps!

    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.