PDF Conversion of Smartform Output

Hi All,
Requirement : Be able to provide customers with reprinting old invoices.
As Is : We have a standard way of doing it by reissuing a print of the Invoice by going into transaction VF02. But in doing so we have a chance that if some master data changes for that customer or the material those changes will get reflected in the new smartform output.
To Be : We want to be able to exactly reproduce the invoice which was sent out at the time of invoice creation, what I mean to say is on initial issue of the print output, is there any way we can store that output(may be as raw data) and retrieve it and issue a print at a later stage.
Any help in this regard would be greatly appreciated.
Karthik

hi
check this link...it will help you
https://www.sdn.sap.com/irj/scn/advancedsearch?query=sendalvtomailas+pdf&cat=sdn_all
or
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.
Regards
Ansumesh

Similar Messages

  • Conversion of smartform output to DOC format

    Hi,
    I have a requirement to convert Smartform output to DOC format. Could anyone provide me any direction for this?
    SS

    Hi SS,
    In the link sent by Anki Reddy... you can follow the same but in this FM change PDF to DOC thats it.
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    FORMAT = 'DOC'         * Change from 'PDF' * to DOC
    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
    Regards,
    sg

  • PDF Conversion from Smartform-Thai

      Hi All,
    we have smartform which has Thai Characters along with bar codes. we want to convert it into PDF, as have tried PDF! however the Thai in not coming as correct. we have uploaded TTF as well. please anyone suggest any SAP notes for this or solution.
    Thank you very much!
    Regards,
    Pradeep

    Hi Wen,
    TH_VISTA_FONTS is already activated in the system. please refer the attached screenshot.
    Regards,
    Pradeep

  • PDF conversion of smartform- Printing Latin -2 characters

    Hi All,
    We are facing a typical issue with Printing of Latin -2 characters in PDFs.
    These are characters from the Polish language for e.g. char 'Ń'.
    These were originally printing as # in the Production system. After raising a message with SAP, they came up with the advice of uploading Latin-2 fonts using note 141343.
    However when I did a test in the sandbox system, the character 'Ń' is replaced by character 'C' and not '#'. This was even before I could upload an appropriate font! I am confused as to why this is happening.
    Any help appreciated.
    Regards,
    Jitender.

    Hi ...
    we had a similar kind of problem ..in which the special characters were coming in development and quality systems..but when they were moved to production system..the special characters were not coming and the desire characters were getting printed...this was becuase of the difference betwwen the codepage of dev and production systems.....So i think in your case also the same may work....
    Edited by: Rudra Prasanna Mohapatra on Aug 6, 2008 1:15 PM

  • Smartform Output to PDF conversion

    Hi experts,
    i want to convert the smartform output to PDF Format and stored it in system level.But i got the following information message "OTF end command // missing in OTF data".
    I used "CONVERT_OTF" for conversion of smartform output and "WS_DOWNLOAD & GUI_DOWNLOAD".
    wt it means,can i make any changes,if tl me why it shows the message.
    points wl be rewarded.
    Thank you
    chandu
    Edited by: Chandu Valluri on Jan 4, 2008 12:56 PM

    hi,
    *& Report  ZPDF_DNLD_TEST2                                             *
    *& DEVK904540                                                                    *
    REPORT  ZPDF_DNLD_TEST2                         .
    data: i_otf LIKE itcoo OCCURS 100 WITH HEADER LINE,
          i_pdf LIKE tline OCCURS 100 WITH HEADER LINE.
    data: op_option type SSFCTRLOP,
          job_output type SSFCRESCL.
    op_option-getotf = 'X'.
    CALL FUNCTION '/1BCDWB/SF00000005'
      EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
       CONTROL_PARAMETERS         = op_option
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
      OUTPUT_OPTIONS             =
      USER_SETTINGS              = 'X'
       itab1                      = itab1
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
       JOB_OUTPUT_INFO            = job_output
      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.
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
       FORMAT                      = 'PDF'
      MAX_LINEWIDTH               = 132
      ARCHIVE_INDEX               = ' '
      COPYNUMBER                  = 0
      ASCII_BIDI_VIS2LOG          = ' '
      PDF_DELETE_OTFTAB           = ' '
    IMPORTING
      BIN_FILESIZE                =
      BIN_FILE                    =
      TABLES
        otf                         = job_output-otfdata
        lines                       = i_pdf
    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 FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
      BIN_FILESIZE                    =
        filename                        = 'c:\test_pdf_sf.pdf'
       FILETYPE                        = 'BIN'
      tables
        data_tab                        = i_pdf
      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.

  • Smartform output in word format

    dear all
    i have created a smartform which needs to send to external mail ID.s as an .doc attachment.
    how to do this.  even i have no basic idea also.  kindly help out.
    regards

    Hi,
    You cannot convert the smartfrom to word doc for this sap has not provided any provision, Instead you can convert to pdf and send as email.
    You can check my reply in this thread..
    [convert smartform output to pdf   |Re: convert smartform output to pdf]

  • Send Smartforms Output as pdf Attachment in E-Mail

    Hi!
    I've searched quite a long time and tried to use different examples I've found in the forum but it doesn't work for me.
    I tried to do the following:
    Send output of smartforms by mail to a specified e-mail adress. Sometimes there have to be sent 2 pdf's (both are output of smartforms) in one e-mail.
    The function to download the output of smartform with FM CONVERT_OTF_2_PDF and GUI_DOWNLOAD works fine for me but I couldn't get the FM SO_NEW_DOCUMENT_SEND_API1 to work.
    Can someone give me an example or a description to get from the output of the smartform to the e-mail with attachment?
    I'm pretty new to this so it maybe is a very simple question.
    Regards,
    Jacko

    Try the following code
    report zpp430_report_in_pdf no standard page heading line-size 255.
    *& Converts spool request into PDF document and emails it to *
    *& recipicant. *
    *& Execution *
    *& This program must be run as a background job in-order for the write *
    *& commands to create a Spool request rather than be displayed on *
    *& screen *
    tables: tsp01.
    parameter: p_email1 like somlreci1-receiver.
    p_sender like somlreci1-receiver.
    p_repid like sy-repid, " Report to execute
    p_linsz like sy-linsz default 132, " Line size
    p_paart like sy-paart default 'X_65_132', " Paper Format
    p_slset like sy-slset, "Variant name
    p_odescr like sodocchgi1-obj_descr,
    p_adescr type so_obj_nam,
    p_delspl as checkbox.
    *DATA DECLARATION
    data: gd_recsize type i.
    * Spool IDs
    types: begin of t_tbtcp.
    include structure tbtcp.
    types: end of t_tbtcp.
    data: it_tbtcp type standard table of t_tbtcp initial size 0,
    wa_tbtcp type t_tbtcp.
    * Job Runtime Parameters
    data: gd_eventid like tbtcm-eventid,
    gd_eventparm like tbtcm-eventparm,
    gd_external_program_active like tbtcm-xpgactive,
    gd_jobcount like tbtcm-jobcount,
    gd_jobname like tbtcm-jobname,
    gd_stepcount like tbtcm-stepcount,
    gd_error type sy-subrc,
    gd_reciever type sy-subrc.
    data: w_recsize type i,
    mc_valid(1) type c.
    data: gd_subject like sodocchgi1-obj_descr,
    it_mess_bod like solisti1 occurs 0 with header line,
    it_mess_att like solisti1 occurs 0 with header line,
    gd_sender_type like soextreci1-adr_typ,
    gd_attachment_desc type so_obj_nam,
    gd_attachment_name type so_obj_des,
    mi_rqident like tsp01-rqident.
    * Spool to PDF conversions
    data: gd_spool_nr like tsp01-rqident,
    w_spool_nr like tsp01-rqident,
    gd_destination like rlgrap-filename,
    gd_bytecount like tst01-dsize,
    gd_buffer type string.
    data:
    mstr_print_parms like pri_params.
    * Binary store for PDF
    data: begin of it_pdf_output occurs 0.
    include structure tline.
    data: end of it_pdf_output.
    constants: c_dev like sy-sysid value 'DEV',
    c_no(1) type c value ' ',
    c_device(4) type c value 'LOCL'.
    *START-OF-SELECTION.
    start-of-selection.
    * Write statement to represent report output. Spool request is created
    * if write statement is executed in background. This could also be an
    * ALV grid which would be converted to PDF without any extra effort
    * WRITE 'Hello World'.
    * NEW-PAGE.
    * COMMIT WORK.
    * NEW-PAGE PRINT OFF.
    * IF SY-BATCH EQ 'X'.
    * PERFORM GET_JOB_DETAILS.
    * PERFORM OBTAIN_SPOOL_ID.
    *** Alternative way could be to submit another program and store spool
    *** id into memory.
    *submit ZSPOOLTOPDF2
    * to sap-spool
    * spool parameters %_print
    * archive parameters %_print
    * without spool dynpro
    * and return.
    call function 'GET_PRINT_PARAMETERS'
    exporting
    authority = space
    copies = '1'
    cover_page = space
    data_set = space
    department = space
    destination = space
    expiration = '1'
    immediately = space
    * in_archive_parameters = space
    * in_parameters = space
    layout = space
    mode = space
    new_list_id = 'X'
    no_dialog = 'X'
    user = sy-uname
    importing
    out_parameters = mstr_print_parms
    valid = mc_valid
    exceptions
    archive_info_not_found = 1
    invalid_print_params = 2
    invalid_archive_params = 3
    others = 4.
    if mstr_print_parms-pdest = space.
    mstr_print_parms-pdest = 'LOCL'.
    endif.
    mstr_print_parms-linsz = p_linsz.
    mstr_print_parms-paart = p_paart.
    submit (p_repid) to sap-spool without spool dynpro
    spool parameters mstr_print_parms
    using selection-set p_slset
    and return.
    * Get spool id from program called above
    perform get_spool_number using sy-repid sy-uname changing mi_rqident.
    * IMPORT w_spool_nr FROM MEMORY ID SY-REPID.
    perform convert_spool_to_pdf.
    perform process_email.
    if p_delspl eq 'X'.
    perform delete_spool.
    endif.
    if sy-sysid = c_dev.
    wait up to 5 seconds.
    submit rsconn01 with mode = 'INT'
    with output = 'X'
    and return.
    endif.
    * ELSE.
    * SKIP.
    * WRITE:/ 'Program must be executed in background in-order for spool'
    * 'request to be created.'.
    * ENDIF.
    * FORM obtain_spool_id *
    form obtain_spool_id.
    check not ( gd_jobname is initial ).
    check not ( gd_jobcount is initial ).
    select * from tbtcp
    into table it_tbtcp
    where jobname = gd_jobname
    and jobcount = gd_jobcount
    and stepcount = gd_stepcount
    and listident <> '0000000000'
    order by jobname
    jobcount
    stepcount.
    read table it_tbtcp into wa_tbtcp index 1.
    if sy-subrc = 0.
    message s004(zdd) with gd_spool_nr.
    gd_spool_nr = wa_tbtcp-listident.
    message s004(zdd) with gd_spool_nr.
    else.
    message s005(zdd).
    endif.
    endform. "OBTAIN_SPOOL_ID
    * FORM get_job_details *
    form get_job_details.
    * Get current job details
    call function 'GET_JOB_RUNTIME_INFO'
    importing
    eventid = gd_eventid
    eventparm = gd_eventparm
    external_program_active = gd_external_program_active
    jobcount = gd_jobcount
    jobname = gd_jobname
    stepcount = gd_stepcount
    exceptions
    no_runtime_info = 1
    others = 2.
    endform. "GET_JOB_DETAILS
    * FORM convert_spool_to_pdf *
    form convert_spool_to_pdf.
    call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
    exporting
    src_spoolid = mi_rqident
    no_dialog = c_no
    dst_device = c_device
    importing
    pdf_bytecount = gd_bytecount
    tables
    pdf = it_pdf_output
    exceptions
    err_no_abap_spooljob = 1
    err_no_spooljob = 2
    err_no_permission = 3
    err_conv_not_possible = 4
    err_bad_destdevice = 5
    user_cancelled = 6
    err_spoolerror = 7
    err_temseerror = 8
    err_btcjob_open_failed = 9
    err_btcjob_submit_failed = 10
    err_btcjob_close_failed = 11
    others = 12.
    check sy-subrc = 0.
    * Transfer the 132-long strings to 255-long strings
    loop at it_pdf_output.
    translate it_pdf_output using ' ~'.
    concatenate gd_buffer it_pdf_output into gd_buffer.
    endloop.
    translate gd_buffer using '~ '.
    do.
    it_mess_att = gd_buffer.
    append it_mess_att.
    shift gd_buffer left by 255 places.
    if gd_buffer is initial.
    exit.
    endif.
    enddo.
    endform. "CONVERT_SPOOL_TO_PDF
    * FORM process_email *
    form process_email.
    describe table it_mess_att lines gd_recsize.
    check gd_recsize > 0.
    perform send_email using p_email1.
    * perform send_email using p_email2.
    endform. "PROCESS_EMAIL
    * FORM send_email *
    * --> p_email *
    form send_email using p_email.
    check not ( p_email is initial ).
    refresh it_mess_bod.
    * Default subject matter
    gd_subject = p_odescr.
    gd_attachment_desc = p_adescr.
    * CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
    it_mess_bod = 'This is an automated report from SAP.'.
    append it_mess_bod.
    it_mess_bod = 'Please do not reply to this mail id.'.
    append it_mess_bod.
    *IT_MESS_BOD = 'For any clarification on the details of this report'
    * APPEND IT_MESS_BOD.
    * IT_MESS_BOD = 'please contact Business Planning. Thank you'.
    * APPEND IT_MESS_BOD.
    * If no sender specified - default blank
    if p_sender eq space.
    gd_sender_type = space.
    else.
    gd_sender_type = 'INT'.
    endif.
    * Send file by email as .xls speadsheet
    perform send_file_as_email_attachment
    tables it_mess_bod
    it_mess_att
    using p_email
    p_odescr
    'PDF'
    gd_attachment_name
    gd_attachment_desc
    p_sender
    gd_sender_type
    changing gd_error
    gd_reciever.
    endform. "SEND_EMAIL
    * FORM delete_spool *
    form delete_spool.
    data: ld_spool_nr type tsp01_sp0r-rqid_char.
    ld_spool_nr = gd_spool_nr.
    check p_delspl <> c_no.
    call function 'RSPO_R_RDELETE_SPOOLREQ'
    exporting
    spoolid = ld_spool_nr.
    endform. "DELETE_SPOOL
    *& Form SEND_FILE_AS_EMAIL_ATTACHMENT
    * Send email
    form send_file_as_email_attachment tables it_message
    it_attach
    using p_email
    p_mtitle
    p_format
    p_filename
    p_attdescription
    p_sender_address
    p_sender_addres_type
    changing p_error
    p_reciever.
    data: ld_error type sy-subrc,
    ld_reciever type sy-subrc,
    ld_mtitle like sodocchgi1-obj_descr,
    ld_email like somlreci1-receiver,
    ld_format type so_obj_tp ,
    ld_attdescription type so_obj_nam ,
    ld_attfilename type so_obj_des ,
    ld_sender_address like soextreci1-receiver,
    ld_sender_address_type like soextreci1-adr_typ,
    ld_receiver like sy-subrc.
    data: t_packing_list like sopcklsti1 occurs 0 with header line,
    t_contents like solisti1 occurs 0 with header line,
    t_receivers like somlreci1 occurs 0 with header line,
    t_attachment like solisti1 occurs 0 with header line,
    t_object_header like solisti1 occurs 0 with header line,
    w_cnt type i,
    w_sent_all(1) type c,
    w_doc_data like sodocchgi1.
    ld_email = p_email.
    ld_mtitle = p_mtitle.
    ld_format = p_format.
    ld_attdescription = p_attdescription.
    ld_attfilename = p_filename.
    ld_sender_address = p_sender_address.
    ld_sender_address_type = p_sender_addres_type.
    * Fill the document data.
    w_doc_data-doc_size = 1.
    * Populate the subject/generic message attributes
    w_doc_data-obj_langu = sy-langu.
    w_doc_data-obj_name = 'SAPRPT'.
    w_doc_data-obj_descr = ld_mtitle .
    w_doc_data-sensitivty = 'F'.
    * Fill the document data and get size of attachment
    clear w_doc_data.
    read table it_attach index w_cnt.
    w_doc_data-doc_size =
    ( w_cnt - 1 ) * 255 + strlen( it_attach ).
    w_doc_data-obj_langu = sy-langu.
    w_doc_data-obj_name = 'SAPRPT'.
    w_doc_data-obj_descr = ld_mtitle.
    w_doc_data-sensitivty = 'F'.
    clear t_attachment.
    refresh t_attachment.
    t_attachment[] = it_attach[].
    * Describe the body of the message
    clear t_packing_list.
    refresh t_packing_list.
    t_packing_list-transf_bin = space.
    t_packing_list-head_start = 1.
    t_packing_list-head_num = 0.
    t_packing_list-body_start = 1.
    describe table it_message lines t_packing_list-body_num.
    t_packing_list-doc_type = 'RAW'.
    append t_packing_list.
    * Create attachment notification
    t_packing_list-transf_bin = 'X'.
    t_packing_list-head_start = 1.
    t_packing_list-head_num = 1.
    t_packing_list-body_start = 1.
    describe table t_attachment lines t_packing_list-body_num.
    t_packing_list-doc_type = ld_format.
    t_packing_list-obj_descr = ld_attdescription.
    t_packing_list-obj_name = ld_attfilename.
    t_packing_list-doc_size = t_packing_list-body_num * 255.
    append t_packing_list.
    * Add the recipients email address
    clear t_receivers.
    refresh t_receivers.
    t_receivers-receiver = ld_email.
    t_receivers-rec_type = 'U'.
    t_receivers-com_type = 'INT'.
    t_receivers-notif_del = 'X'.
    t_receivers-notif_ndel = 'X'.
    append t_receivers.
    call function 'SO_DOCUMENT_SEND_API1'
    exporting
    document_data = w_doc_data
    put_in_outbox = 'X'
    sender_address = ld_sender_address
    sender_address_type = ld_sender_address_type
    commit_work = 'X'
    importing
    sent_to_all = w_sent_all
    tables
    packing_list = t_packing_list
    contents_bin = t_attachment
    contents_txt = it_message
    receivers = t_receivers
    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.
    * Populate zerror return code
    ld_error = sy-subrc.
    * Populate zreceiver return code
    loop at t_receivers.
    ld_receiver = t_receivers-retrn_code.
    endloop.
    endform. "SEND_FILE_AS_EMAIL_ATTACHMENT
    *& Form GET_SPOOL_NUMBER
    * text
    * -->P_SY_REPID text
    * -->P_SY_UNAME text
    * <--P_MI_RQIDENT text
    form get_spool_number using f_repid
    f_uname
    changing f_rqident.
    data:
    lc_rq2name like tsp01-rq2name.
    concatenate f_repid+0(9)
    f_uname+0(3)
    into lc_rq2name.
    select * from tsp01 where rq2name = lc_rq2name
    order by rqcretime descending.
    f_rqident = tsp01-rqident.
    exit.
    endselect.
    if sy-subrc ne 0.
    clear f_rqident.
    endif.
    endform. " GET_SPOOL_NUMBER
    there are lot's of posts available on sdn which u can refer to.
    tx
    ashwa

  • Smartform to PDF conversion having issue with Russian address

    We are having a business situation we are the invoice in English language and the the address of ship-to party and sold-to party in Russian.
    The issue we face is.
    When the  smartform is converted to PDF the Russian specific characters are missing in the PDF output. The same are perfect in the smart form print preview.
    we are using   CONVERT_OTF function module and we are getting the Russian characters correctly in the table parameter OTF.
    We are using "SX_TABLE_LINE_WIDTH_CHANGE" and " SO_DOCUMENT_SEND_API1"
    function module to attach and mail the pdf.
    In the PDF we are missing the Russian specific characters .
    For Example in "Sedláčkova čč" the output is "Sedláčkova    " means "čč" is mising
    Thanks in advance
    Regards
    Joby

    Hi,
    As described in note 999712 - PDF conversion for Unicode, there is a new unicode PDF converter PDFUC.
    It depends on the SAP Version if you have to install the device type or not. You can check also via SPAD -> Full Administration -> Device Types -> Display.
    You can pass the device type in the output options. I used:
    SSFCTRLOP-no_dialog   = 'X'.
    SSFCTRLOP-getotf      = 'X'.
    SSFCTRLOP-langu       = 'EN'.
    SSFCOMPOP-tdprinter = 'PDFUC'.
    If you specify a device other than printer in the control options like SSFCTRLOP-device      = 'TELEFAX'., above will not work as
    SSFCOMPOP-tdprinter is only evaluated for printer.
    You have to check in SCOT -> Settings -> Device Types for Format Conversion.
    You can make a general entry or for a specific language:
    PDF                           SAPscript/Smart Forms    PDFUC
    PDF    EN    English    SAPscript/Smart Forms    PDFUC
    Let me know if you get this working.
    Jeroen.

  • Problem in PDF conversion of a Smartform

    Hi Experts,
    I have Chinese text and english text in the  Smartform
    When see print preview of Smartfrom the output is perfect
    But when i convert the OTF to PDF using  CONVERT_OTF FM and send as mail attachment,
    The chinese characters are JUNK and conversion don't occur properly.
    For english TEXT i use Times new roman font
    For Chinese Text i use CNSONG
    I have used other FM as well CONVERT_OTF_2_PDF, the results were negative.
    Please advise
    Regards
    Balaji R

    Hello Davide,
    We got this solution from SAP active global support.
    I suppose it works in some cases only.
    Our scenario is when we try to create PDF of the smartform using FM convert_otf and send as mail attachment.
    We can able to see chinese chracters when giving the print preview of the form, but during PDF conversion we get Junk chinese characters.
    Even if you have multiple languages in your form, SAP proposes to use 'ZPDFUC' as device type.
    My question has the solution proposed by you works in all cases?
    Please advise.Thanks.
    Best regards
    Balaji R

  • Sending smartform output as PDF attachment, Error opening PDF attachment

    Hi Experts,
    I am using the code form the following link to send a smartform output as PDF attachment. I can able to see the message, but can not open PDF document.
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/convertSmartformtoPDFformat&
    The information should be on my smartform are some text, company logo and a barcode.
    With all of these received error: "There was an error opening this document. The file is damaged and could not be repaired."
    I tried different ways like only text, text with company logo, text with barcode. I got the following errors:
    An unrecognized token 'Td0' was found
    There was problem reading this document(16).
    There was problem reading this document(111).
    Does anyone have idea of these ? Your help is greatly appreciated.
    Thank you,
    Surya

    please see this code  ...  for sending the  Email as  PDF attach file,
    *& Report  ZSPOOLTOPDF                                                 *
    *& Converts spool request into PDF document and emails it to           *
    *& recipicant.                                                         *
    *& Execution                                                           *
    *& This program must be run as a background job in-order for the write *
    *& commands to create a Spool request rather than be displayed on      *
    *& screen                                                              *
    REPORT  zspooltopdf.
    PARAMETER: p_email1 LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_sender LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_delspl  AS CHECKBOX.
    *DATA DECLARATION
    DATA: gd_recsize TYPE i.
    * Spool IDs
    TYPES: BEGIN OF t_tbtcp.
            INCLUDE STRUCTURE tbtcp.
    TYPES: END OF t_tbtcp.
    DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
          wa_tbtcp TYPE t_tbtcp.
    * Job Runtime Parameters
    DATA: gd_eventid LIKE tbtcm-eventid,
          gd_eventparm LIKE tbtcm-eventparm,
          gd_external_program_active LIKE tbtcm-xpgactive,
          gd_jobcount LIKE tbtcm-jobcount,
          gd_jobname LIKE tbtcm-jobname,
          gd_stepcount LIKE tbtcm-stepcount,
          gd_error    TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    DATA:  w_recsize TYPE i.
    DATA: gd_subject   LIKE sodocchgi1-obj_descr,
          it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_sender_type     LIKE soextreci1-adr_typ,
          gd_attachment_desc TYPE so_obj_nam,
          gd_attachment_name TYPE so_obj_des.
    * Spool to PDF conversions
    DATA: gd_spool_nr LIKE tsp01-rqident,
          gd_destination LIKE rlgrap-filename,
          gd_bytecount LIKE tst01-dsize,
          gd_buffer TYPE string.
    * Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    CONSTANTS: c_dev LIKE  sy-sysid VALUE 'DEV',
               c_no(1)     TYPE c   VALUE ' ',
               c_device(4) TYPE c   VALUE 'LOCL'.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    * Write statement to represent report output. Spool request is created
    * if write statement is executed in background. This could also be an
    * ALV grid which would be converted to PDF without any extra effort
      WRITE 'Hello World'.
      new-page.
      commit work.
      new-page print off.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
    *** Alternative way could be to submit another program and store spool
    *** id into memory, will be stored in sy-spono.
    *submit ZSPOOLTOPDF2
    *        to sap-spool
    *        spool parameters   %_print
    *        archive parameters %_print
    *        without spool dynpro
    *        and return.
    * Get spool id from program called above
    *  IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
        PERFORM convert_spool_to_pdf.
        PERFORM process_email.
        if p_delspl EQ 'X'.
          PERFORM delete_spool.
        endif.
        IF sy-sysid = c_dev.
          wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
        ENDIF.
      ELSE.
        SKIP.
        WRITE:/ 'Program must be executed in background in-order for spool',
                'request to be created.'.
      ENDIF.
    *       FORM obtain_spool_id                                          *
    FORM obtain_spool_id.
      CHECK NOT ( gd_jobname IS INITIAL ).
      CHECK NOT ( gd_jobcount IS INITIAL ).
      SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                     AND        jobcount    = gd_jobcount
                     AND        stepcount   = gd_stepcount
                     AND        listident   <> '0000000000'
                     ORDER BY   jobname
                                jobcount
                                stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        MESSAGE s004(zdd) WITH gd_spool_nr.
      ELSE.
        MESSAGE s005(zdd).
      ENDIF.
    ENDFORM.
    *       FORM get_job_details                                          *
    FORM get_job_details.
    * Get current job details
      CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    ENDFORM.
    *       FORM convert_spool_to_pdf                                     *
    FORM convert_spool_to_pdf.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount            = gd_bytecount
           TABLES
                pdf                      = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
      CHECK sy-subrc = 0.
    * Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
    *       FORM process_email                                            *
    FORM process_email.
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      PERFORM send_email USING p_email1.
    *  perform send_email using p_email2.
    ENDFORM.
    *       FORM send_email                                               *
    *  -->  p_email                                                       *
    FORM send_email USING p_email.
      CHECK NOT ( p_email IS INITIAL ).
      REFRESH it_mess_bod.
    * Default subject matter
      gd_subject         = 'Subject'.
      gd_attachment_desc = 'Attachname'.
    *  CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
      it_mess_bod        = 'Message Body text, line 1'.
      APPEND it_mess_bod.
      it_mess_bod        = 'Message Body text, line 2...'.
      APPEND it_mess_bod.
    * If no sender specified - default blank
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
    * Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_mess_bod
                                          it_mess_att
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'PDF'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 changing gd_error
                                          gd_reciever.
    ENDFORM.
    *       FORM delete_spool                                             *
    FORM delete_spool.
      DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
      ld_spool_nr = gd_spool_nr.
      CHECK p_delspl <> c_no.
      CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
           EXPORTING
                spoolid = ld_spool_nr.
    ENDFORM.
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
    *       Send email
    FORM send_file_as_email_attachment tables it_message
                                              it_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
    data:   t_packing_list like sopcklsti1 occurs 0 with header line,
            t_contents like solisti1 occurs 0 with header line,
            t_receivers like somlreci1 occurs 0 with header line,
            t_attachment like solisti1 occurs 0 with header line,
            t_object_header like solisti1 occurs 0 with header line,
            w_cnt type i,
            w_sent_all(1) type c,
            w_doc_data like sodocchgi1.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    * Fill the document data.
      w_doc_data-doc_size = 1.
    * Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    * Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    * Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    * Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    * Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           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.
    * Populate zerror return code
      ld_error = sy-subrc.
    * Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    reward  points  if it is usefull ....
    Girish

  • Convert smartform output in to PDF using CONVERT_OTF function  how to do it

    Hi Anil , and  Hi All
             I am trying to display smartforms output in java webdynpro
             for that i have got the following code in sdn.
               can anybody please clarify these doubts in the  below code
               1) What are the mandatory input and output parameters
                   I have to pass here in this code to my application
               2) please check my previous post also in this regards please
       . Please reply at the very earliest. Check the below code
    Convert smartform output in to PDF using CONVERT_OTF function module and you can write pdf using parameter 'binfile' of this function in WebDynpro using the following code:
    It is copied from my prg. I hope you understand it.
    public void onActionGetQuote(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    //@@begin onActionGetQuote(ServerEvent)
    wdThis.wdGetOppt_QwriterCustController().executeZquote_Writer_Input();
    String fileName = wdContext.currentZquote_Writer_InputElement().getOrder().toString().trim() + System.currentTimeMillis() + ".pdf";
    String pdfOutput = new String(wdContext.currentOutputElement().getBinfile());
    if (pdfOutput != null)
    try
    String pdfResoucePath = WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(), fileName);
    FileOutputStream fileOutputStream = new FileOutputStream(new File(pdfResoucePath));
    PrintStream ps = new PrintStream(fileOutputStream);
    ps.print(pdfOutput);
    ps.close();
    //Display the PDF to the browser
    String fileURL = WDURLGenerator.getAbsoluteWebResourceURL(wdComponentAPI.getDeployableObjectPart(), fileName);
    IWDWindow window = wdComponentAPI.getWindowManager().createExternalWindow(fileURL, "Pdf Browser", false);
    window.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);
    window.removeWindowFeature(WDWindowFeature.MENU_BAR);
    window.removeWindowFeature(WDWindowFeature.STATUS_BAR);
    window.removeWindowFeature(WDWindowFeature.TOOL_BAR);
    window.open();
    // To collect all the file created in the server by user
    quoteFiles.add(quoteFiles.size(), pdfResoucePath);
    } catch (Exception e)
    throw new WDRuntimeException(e);
    //@@end

    Hi
        ABAPers prepared a BAPI function module which calls Smart form , how can i execute it from java Webdynpro, so that I can display the smart form in Webdynpro. Pleas reply at the very earliest.  Every answer will be rewarded.
    regards
    jalandhar

  • Smartforms o/p 2 PDF conversion problem , plz see my code

    Hi Smartform Guys
    1)I m getting error <b>"CONVT_NO_NUMBER "</b>  in converting my Smartform output to PDF.
    *Printing of Export Invoice, Packing List,Enclosure to Packing List &  *
    *Case Marking in one SMART FORMS Layout                                *
    REPORT ZSD_REP_MULTI_PRINT.
    TABLES :
        vbak,
        vbap,
        vbpa,
        vbfa,
        VBRK,
        VBRP,
        LIKP,
        LIPS,
        KONV,
        objk,
        tvko,
        ser01,
        sadr,
        equi,
        makt,
        mast,
        t005t,
        kna1,
        t001w,
        T001,
        ADRC,
        sscrfields,
        zpp_plcmi,      "Packing list history For Conf: Item data
        zplh,           "PACKING LIST HISTORY : HEADER DATA
        zpli.           "PACKING LIST HISTORY : ITEM DATA
    DATA: FM_NAME  TYPE RS38L_FNAM,
          P_E_DEVTYPE TYPE RSPOPTYPE,
          P_JOB_OUTPUT_INFO TYPE SSFCRESCL OCCURS 2000 WITH HEADER LINE,
          P_OUTPUT_OPTIONS TYPE SSFCOMPOP OCCURS 0 WITH HEADER LINE,
          P_CONTROL_PARAMETERS TYPE SSFCTRLOP OCCURS 0 WITH HEADER LINE ,
          P_DOC  LIKE DOCS OCCURS 2000 WITH HEADER LINE,
          P_LINES LIKE TLINE OCCURS 200,
          P_BIN_FILESIZE TYPE I,
          P_LANGUAGE TYPE SFLANGU,
          P_BIN_FILE TYPE XSTRING.
    DATA: T_ITEM   TYPE  ZSD_TABL_LITEM,
          WA_ITEM  TYPE  ZSD_STRUCT_LITEM,
          T_ADRS   LIKE  ZSD_STRUCT_ADRS  OCCURS 0 WITH HEADER LINE,
          MSLINES  LIKE  TLINE OCCURS 1 WITH HEADER LINE,
          TIDNO    LIKE STXL-TDID,
          TNAME    LIKE STXL-TDNAME,
          TOBJT    LIKE STXL-TDOBJECT,
          SSORD    LIKE VBAK-VBELN,
          TOT      LIKE VBAK-NETWR,
          WORD     LIKE SPELL.
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    PARAMETERS: P_DELNO LIKE  LIKP-VBELN OBLIGATORY,
                P_INVNO LIKE  VBRK-VBELN OBLIGATORY,
                P_DATE  LIKE  SY-DATUM.
    SELECTION-SCREEN END   OF BLOCK blk1.
    AT SELECTION-SCREEN.
      CLEAR T_ADRS.
      REFRESH T_ITEM.
      T_ADRS-INVNO = P_INVNO.
      T_ADRS-INVDAT = P_DATE.
      SELECT SINGLE VBELV INTO  VBFA-VBELV
                             FROM  VBFA
                             WHERE VBELN = P_DELNO
                               AND VBTYP_N = 'J'  .
      SSORD = VBFA-VBELV.
    *Exporter's  Address
      SELECT SINGLE BUKRS_VF INTO  VBAK-BUKRS_VF
                             FROM  VBAK
                             WHERE VBELN = VBFA-VBELV.
      SELECT SINGLE   ADRNR
                      INTO T001-ADRNR
                      FROM T001
                      WHERE BUKRS = VBAK-BUKRS_VF.
      SELECT SINGLE NAME1 STREET CITY1 POST_CODE1 COUNTRY
             INTO (T_ADRS-NAME1,T_ADRS-STREET,T_ADRS-CITY1,
                   T_ADRS-POST_CODE1, ADRC-COUNTRY)
             FROM  ADRC
             WHERE ADDRNUMBER EQ T001-ADRNR.
      SELECT SINGLE LANDX
                    INTO T_ADRS-COUNTRY
                    FROM T005T
                    WHERE     SPRAS = 'EN'
                          AND LAND1 = ADRC-COUNTRY.
    **BUYERS NO & DATE
    SELECT SINGLE BSTNK BSTDK INTO  (T_ADRS-BSTNK,T_ADRS-BSTDK)
                         FROM  VBAK
                         WHERE VBELN = VBFA-VBELV.
    *Consignee Address & Buyer Other Than Consignee
      SELECT SINGLE KUNNR KUNAG INTO (LIKP-KUNNR, LIKP-KUNAG)
                                FROM LIKP WHERE VBELN = P_DELNO.
      IF LIKP-KUNNR = LIKP-KUNAG.
        SELECT SINGLE NAME1 NAME2 STRAS ORT01 PSTLZ REGIO TELF1 ADRNR
                  INTO (T_ADRS-CNAME1, T_ADRS-CNAME2, T_ADRS-CSTREET,
                        T_ADRS-CCITY,  T_ADRS-CPCODE, T_ADRS-CREGIO,
                        T_ADRS-CTELF1, KNA1-ADRNR)
                  FROM  KNA1
                  WHERE KUNNR = LIKP-KUNNR.
        SELECT SINGLE COUNTRY INTO  ADRC-COUNTRY
                              FROM  ADRC
                              WHERE ADDRNUMBER EQ KNA1-ADRNR.
        SELECT SINGLE LANDX
                    INTO T_ADRS-CCOUNTRY
                    FROM T005T
                    WHERE     SPRAS = 'EN'
                          AND LAND1 = ADRC-COUNTRY.
        T_ADRS-ONAME1   =  T_ADRS-CNAME1 .
        T_ADRS-ONAME2   =  T_ADRS-CNAME2 .
        T_ADRS-OSTREET  =  T_ADRS-CSTREET .
        T_ADRS-OCITY    =  T_ADRS-CCITY.
        T_ADRS-OPCODE   =  T_ADRS-CPCODE .
        T_ADRS-OREGIO   =  T_ADRS-CREGIO.
        T_ADRS-OTELF1   =  T_ADRS-CTELF1 .
        T_ADRS-OCOUNTRY =  T_ADRS-CCOUNTRY.
      ELSE.
        SELECT SINGLE NAME1 NAME2 STRAS ORT01 PSTLZ REGIO TELF1 ADRNR
                  INTO (T_ADRS-CNAME1, T_ADRS-CNAME2, T_ADRS-CSTREET,
                        T_ADRS-CCITY,  T_ADRS-CPCODE, T_ADRS-CREGIO,
                        T_ADRS-CTELF1, KNA1-ADRNR)
                  FROM  KNA1
                  WHERE KUNNR = LIKP-KUNNR.
        SELECT SINGLE COUNTRY INTO ADRC-COUNTRY
                              FROM  ADRC
                              WHERE ADDRNUMBER EQ KNA1-ADRNR.
        SELECT SINGLE LANDX
                    INTO T_ADRS-CCOUNTRY
                    FROM T005T
                    WHERE     SPRAS = 'EN'
                          AND LAND1 = ADRC-COUNTRY.
    *Buyer Other than Consignee
        SELECT SINGLE NAME1 NAME2 STRAS ORT01 PSTLZ REGIO TELF1 ADRNR
                   INTO (T_ADRS-ONAME1, T_ADRS-ONAME2, T_ADRS-OSTREET,
                         T_ADRS-OCITY,  T_ADRS-OPCODE, T_ADRS-OREGIO,
                         T_ADRS-OTELF1, KNA1-ADRNR)
                   FROM  KNA1
                   WHERE KUNNR = LIKP-KUNAG.
        SELECT SINGLE COUNTRY INTO  ADRC-COUNTRY
                              FROM  ADRC
                              WHERE ADDRNUMBER EQ KNA1-ADRNR.
        SELECT SINGLE LANDX
                    INTO T_ADRS-OCOUNTRY
                    FROM T005T
                    WHERE     SPRAS = 'EN'
                          AND LAND1 = ADRC-COUNTRY.
      ENDIF.
    *Other's Ref
      TIDNO = 'Z071'.
      TNAME = SSORD.
      TOBJT = 'VBBK'.
      PERFORM FINDTEXT.
      LOOP AT MSLINES.
        T_ADRS-OREF = mslines-tdline(25).
        EXIT.
      ENDLOOP.
    *Buyer's Order No  Ref
      TIDNO = 'Z023'.
      TNAME = SSORD.
      TOBJT = 'VBBK'.
      PERFORM FINDTEXT.
      LOOP AT MSLINES.
        T_ADRS-BUYER = mslines-tdline(25).
        EXIT.
      ENDLOOP.
    *Exporter Ref
      TIDNO = 'Z072'.
      TNAME = SSORD.
      TOBJT = 'VBBK'.
      PERFORM FINDTEXT.
      LOOP AT MSLINES.
        T_ADRS-XPREF = mslines-tdline(25).
        EXIT.
      ENDLOOP.
    *Pre-Carraige By
      TIDNO = 'Z074'.
      TNAME = SSORD.
      TOBJT = 'VBBK'.
      PERFORM FINDTEXT.
      LOOP AT MSLINES.
        T_ADRS-PCRG = mslines-tdline(25).
        EXIT.
      ENDLOOP.
    *Place Of reciept by Pre-Carraige
      TIDNO = 'Z073'.
      TNAME = SSORD.
      TOBJT = 'VBBK'.
      PERFORM FINDTEXT.
      LOOP AT MSLINES.
        T_ADRS-PLPCRG = mslines-tdline(25).
        EXIT.
      ENDLOOP.
    *Vessel/Flight No
      TIDNO = 'Z075'.
      TNAME = SSORD.
      TOBJT = 'VBBK'.
      PERFORM FINDTEXT.
      LOOP AT MSLINES.
        T_ADRS-VFNO = mslines-tdline(25).
        EXIT.
      ENDLOOP.
    *Port Of Loading
      TIDNO = 'Z077'.
      TNAME = SSORD.
      TOBJT = 'VBBK'.
      PERFORM FINDTEXT.
      LOOP AT MSLINES.
        T_ADRS-PLOAD = mslines-tdline(25).
        EXIT.
      ENDLOOP.
    *Port Of Discharge
      TIDNO = 'Z076'.
      TNAME = SSORD.
      TOBJT = 'VBBK'.
      PERFORM FINDTEXT.
      LOOP AT MSLINES.
        T_ADRS-PDISG = mslines-tdline(25).
        EXIT.
      ENDLOOP.
    *Final Destination
      TIDNO = 'Z070'.
      TNAME = SSORD.
      TOBJT = 'VBBK'.
      PERFORM FINDTEXT.
      LOOP AT MSLINES.
        T_ADRS-FDEST = mslines-tdline(25).
        EXIT.
      ENDLOOP.
    *Terms Of Delivery & Payment
      TIDNO = 'Z080'.
      TNAME = SSORD.
      TOBJT = 'VBBK'.
      PERFORM FINDTEXT.
      LOOP AT MSLINES.
        T_ADRS-TERMS = mslines-tdline(50).
        EXIT.
      ENDLOOP.
    APPEND T_ADRS.
    *BODY SECTION FOR LINE ITEMS
      SELECT POSNR KWMENG VRKME WAERK
             INTO  (VBAP-POSNR, VBAP-KWMENG, VBAP-VRKME, VBAP-WAERK)
             FROM  VBAP
             WHERE VBELN = SSORD.
    *Mark/Case No
        TIDNO = '0002'.
        CONCATENATE SSORD
                    VBAP-POSNR
        INTO        TNAME.
        TOBJT = 'VBBP'.
        PERFORM FINDTEXT.
        LOOP AT MSLINES.
          WA_ITEM-MARKNO = mslines-tdline(40).
          EXIT.
        ENDLOOP.
    *Packing Type
        TIDNO = '0003'.
        CONCATENATE SSORD
                    VBAP-POSNR
        INTO        TNAME.
        TOBJT = 'VBBP'.
        PERFORM FINDTEXT.
        LOOP AT MSLINES.
          WA_ITEM-PACKTYP = mslines-tdline(40).
          EXIT.
        ENDLOOP.
    *Goods Description
        TIDNO = '0001'.
        CONCATENATE SSORD
                    VBAP-POSNR
        INTO        TNAME.
        TOBJT = 'VBBP'.
        PERFORM FINDTEXT.
        LOOP AT MSLINES.
          WA_ITEM-PACKTYP = mslines-tdline(40).
          EXIT.
        ENDLOOP.
    *Goods Quantity
        WA_ITEM-QTY = VBAP-KWMENG.
        WA_ITEM-VRKME = VBAP-VRKME.
    *Goods Rate
        SELECT SINGLE KNUMV INTO VBAK-KNUMV FROM VBAK WHERE VBELN = SSORD.
        SELECT SINGLE KBETR WAERS
                      INTO  (WA_ITEM-RATE, WA_ITEM-WAERS)
                      FROM  KONV
                      WHERE KNUMV = VBAK-KNUMV
                        AND KPOSN = VBAP-POSNR
                        AND KSCHL = 'PR00'.
    *Goods Amount
        WA_ITEM-AMOUNT = WA_ITEM-QTY * WA_ITEM-RATE.
        WA_ITEM-WAERK = VBAP-WAERK.
        TOT = TOT + WA_ITEM-AMOUNT.
        APPEND WA_ITEM TO T_ITEM.
      ENDSELECT.
      T_ADRS-TOT = TOT.
      CALL FUNCTION 'SPELL_AMOUNT'
       EXPORTING
         AMOUNT          = TOT
         CURRENCY        = VBAP-WAERK
      FILLER          = ' '
         LANGUAGE        = SY-LANGU
       IMPORTING
         IN_WORDS        = WORD
       EXCEPTIONS
         NOT_FOUND       = 1
         TOO_LARGE       = 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.
    TEXT = WORD-WORD.
    CONCATENATE TEXT
                 'DECIMAL'
                  WORD-WORD
         INTO     TEXT
         SEPARATED BY ' '.
      T_ADRS-TOT_WORDS = WORD-WORD.
      APPEND T_ADRS.
    START-OF-SELECTION.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          FORMNAME                 = 'Z_SD_REP_MULTI_PRINT'
      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.
      P_LANGUAGE = 'EN'.
      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_OUTPUT_OPTIONS-TDDEST = 'LOCL'.
      APPEND P_OUTPUT_OPTIONS.
      P_CONTROL_PARAMETERS-NO_DIALOG = 'X'.
      P_CONTROL_PARAMETERS-GETOTF = 'X'.
      P_CONTROL_PARAMETERS-NO_CLOSE = SPACE.
      APPEND  P_CONTROL_PARAMETERS.
      CALL FUNCTION FM_NAME
       EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
        CONTROL_PARAMETERS         = P_CONTROL_PARAMETERS
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
        OUTPUT_OPTIONS             = P_OUTPUT_OPTIONS
        USER_SETTINGS              = 'X'
      IMPORTING
      DOCUMENT_OUTPUT_INFO       =
        JOB_OUTPUT_INFO            = P_JOB_OUTPUT_INFO
      JOB_OUTPUT_OPTIONS         =
      TABLES
        T_ADRS                     = T_ADRS
        T_ITEM                     = T_ITEM
    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.
    P_OTF[] = P_JOB_OUTPUT_INFO-OTFDATA.
    CALL FUNCTION 'CONVERT_OTF_2_PDF'
      EXPORTING
        USE_OTF_MC_CMD               = 'X'
      ARCHIVE_INDEX                =
    IMPORTING
       BIN_FILESIZE                 = P_BIN_FILESIZE
      TABLES
        OTF                          = P_JOB_OUTPUT_INFO-OTFDATA
        DOCTAB_ARCHIVE               = P_DOC
        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.
    BREAK-POINT.
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
       BIN_FILESIZE                  = P_BIN_FILESIZE
      CODEPAGE                      = ' '
       FILENAME                      = 'C:\TEMP.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                    = P_BIN_FILESIZE
      TABLES
        DATA_TAB                      = P_LINES
      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
      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.
    CALL FUNCTION 'GUI_DOWNLOAD'
       EXPORTING
        BIN_FILESIZE = P_BIN_FILESIZE
        FILENAME = 'C:\Documents and Settings\pvipin\Desktop\sd.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 =
    *TABLES
       DATA_TAB = P_LINES.
    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.
    *&      Form  FINDTEXT
          text
    FORM FINDTEXT.
      REFRESH mslines.
      CALL FUNCTION 'READ_TEXT'
        EXPORTING
          client                  = sy-mandt
          id                      = tidno
          language                = sy-langu
          name                    = tname
          object                  = tobjt
        TABLES
          lines                   = mslines
        EXCEPTIONS
          id                      = 1
          language                = 2
          name                    = 3
          not_found               = 4
          object                  = 5
          reference_check         = 6
          wrong_access_to_archive = 7
          OTHERS                  = 8.
      DELETE mslines WHERE tdline IS INITIAL.
    ENDFORM.                    "FINDTEXTThnx in Advnce
    Moni
    Message was edited by: md monirujjaman
    Message was edited by: md monirujjaman
    Message was edited by: md monirujjaman
    Message was edited by: md monirujjaman
    Message was edited by: md monirujjaman
    Message was edited by: md monirujjaman
    Message was edited by: md monirujjaman
    Message was edited by: md monirujjaman
    Message was edited by: md monirujjaman

    Hello,
    I think the following statement is causing problem.
    P_OTF[] = P_JOB_OUTPUT_INFO-OTFDATA.
    either give:
    P_OTF[] = P_JOB_OUTPUT_INFO-OTFDATA[].
    or
    directly pass P_JOB_OUTPUT_INFO-OTFDATA into FM parameter.
    This is because you are filling only header into P_OTF and NOT the Contents of internal table by the statement
    P_OTF[] = P_JOB_OUTPUT_INFO-OTFDATA.
    let me know whether it works.
    Regards, Murugesh AS
    have alook at this thread:
    Re: SX_OBJECT_CONVERT_OTF_PDF
    this may help you
    Message was edited by: Murugesh Arcot
    Message was edited by: Murugesh Arcot

  • Error "number out of range" in pdf sent through mail using smartform output

    Hi Experts,
    We have a program which sends mail using smartform output in 'PDF' format. We are able to preview smartform correctely in SAP and mail is also getting sent fine with attachment of form as PDF document. But, when we try to open the document, it gives error saying 'Number out of range'. Also, not all of the windows of smartform are appearing in document and some are coming only half.
    We are not able to find out the reason for this. Any help would be appriciated.
    Gouri.

    Hello,
    How did you solve this one? We are facing the same problem in ECC6.0.
    Thanks in advance,
    Benjamin de Rijke

  • Converting smartforms output into PDF

    Hi ALL,
      How to convert the smartforms output into PDF based form. After executing the form, it should directly  open in PDF. How to do this?
    Points will be awarded.
    Thanks and regards,
    vinoth.

    Hi Vinoth Kumar,
    Please go throuh the below procedure and sample Code, this might help you.
    Procedure
    When we activate the Smartform the system generates a Function Module. The function module name we can get from Smartfrom screen from menubar
    “Environment => Function Module_Name” . In a report we can get this Function module name by calling a Function Module standard SSF_FUNCTION_MODULE_NAME. This function module at runtime calls the FM generated by smartform, which in turn is then used to pass data from the report to Smartform. In the report given below the FM generated is “ /1BCDWB/SF00000152 ”. In this FM we can see CONTROL_PARAMETERS in import tab. This is of type SSFCTRLOP. We need to set the GETOTF of this to be ‘X’. Setting this field will activate the OTF field in smartform.
    In export tab of the FM generated by smartform we can see a parameter JOB_OUTPUT_INFO which is of type SSFCRESCL. The SSFCRESCL is a structure of having one of fields as OTFDATA. OTFDATA in turn is a table of type ITCOO. ITCOO has two fields TDPRINTCOM and TDPRINTPAR. TDPRINTCOM represents command line of OTF format data and TDPRINTPAR contains command parameters of OTF format data.
    In every Smartform output in OTF format, TDPRINTCOM begins and ends with ‘//’. ‘EP’ represents the end-of-page value for TDPRINTCOM field.
    In addition we need to set few fields at the place where we call this FM(generated by smartform) in our program. While calling this FM we should set control_parameters, output_options, user_settings and job_putput_info fields as shown in program.
    Once these settings are done we can call Function Module CONVERT_OTF to convert the OTF data of smartfrom output to PDF data format. Once these are done we can call method “cl_gui_fronted_services=>file_save_dialog” to specify the directory path where we want to save the output PDF file. After this we can call Function Module GUI_DOWNLOAD to download the PDF file on our local system.
    Here is a sample code of program to perform the function.
    SAMPLE CODE
    *& Report  ZAMIT_SMART_FORM_PDF                                        *
    REPORT  ZAMIT_SMART_FORM_PDF                    .
    data: carr_id type sbook-carrid,
          cparam type ssfctrlop,
          outop type ssfcompop,
          fm_name type rs38l_fnam.
    DATA: tab_otf_data TYPE ssfcrescl,
          pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
          tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
          file_size TYPE i,
          bin_filesize TYPE i,
          FILE_NAME type string,
          File_path type string,
          FULL_PATH type string.
    parameter:      p_custid type scustom-id default 1.
    select-options: s_carrid for carr_id     default 'LH' to 'LH'.
    parameter:      p_form   type tdsfname   default 'ZAMIT_SMART_FORM'.
    data: customer    type scustom,
          bookings    type ty_bookings,
          connections type ty_connections.
    start-of-selection.
    suppressing the dialog box for print preview****************************
    outop-tddest = 'LP01'.
    cparam-no_dialog = 'X'.
    cparam-preview = SPACE.
    cparam-getotf = 'X'.
      select single * from scustom into customer where id = p_custid.
      check sy-subrc = 0.
      select * from sbook   into table bookings
               where customid = p_custid
               and   carrid in s_carrid
               order by primary key.
      select * from spfli into table connections
               for all entries in bookings
               where carrid = bookings-carrid
               and   connid = bookings-connid
               order by primary key.
      call function 'SSF_FUNCTION_MODULE_NAME'
           exporting  formname           = p_form
                    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.
        exit.
      endif.
    Hope this resolves your query.
    Reward all the helpful answers.
    Regards
    calling the generated function module
      call function fm_name
           exporting
                    archive_index        =
                    archive_parameters   =
                     control_parameters   = cparam
                    mail_appl_obj        =
                    mail_recipient       =
                    mail_sender          =
                     output_options       =  outop
                     user_settings        = SPACE
                     bookings             = bookings
                      customer             = customer
                      connections          = connections
          importing
                    document_output_info =
                     job_output_info      = tab_otf_data
                    job_output_options   =
           exceptions formatting_error     = 1
                      internal_error       = 2
                      send_error           = 3
                      user_canceled        = 4
                      others               = 5.
      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.
      endif.
      tab_otf_final[] = tab_otf_data-otfdata[].
      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.
    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             = FILE_NAME
        path                 = FILE_PATH
        fullpath             = 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.
    ************downloading the converted PDF data to your local PC*******
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
       bin_filesize                    = bin_filesize
       filename                        = 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'
    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
    IF sy-subrc <> 0.
    ENDIF.

  • I have a problem in converting smartform output to pdf format.

    Hi,
    While converting the smartform output to pdf format.
    It is showing this error.
    otf end command // missing in otf data.
    I have used this function.
    Assigning the OTFDATA to OTF Structure table
        CLEAR gt_otf.
        gt_otf[] = gs_otfdata-otfdata[].
    Convert the OTF DATA to SAP Script Text lines
        CLEAR gt_pdf_tab.
        CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            format                = 'PDF'
            max_linewidth         = 132
          IMPORTING
            bin_filesize          = gv_bin_filesize
          TABLES
            otf                   = gt_otf
            lines                 = gt_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.
    Please help me in this regard. Thanks in advance.

    Hi ,
    I am getting this exception "err_conv_not_possible"
    CALL FUNCTION f_name " '/1BCDWB/SF00000092'
          EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
            CONTROL_PARAMETERS       = st_control_parameters
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
         OUTPUT_OPTIONS             = st_output_options
      USER_SETTINGS              = 'X'
            ZST_TEXTSYMBOLS            = ZST_TEXTSYMBOLS
            wa_kna1                    = wa_kna1
            wa_claim_header            = wa_claim_header
       IMPORTING
         DOCUMENT_OUTPUT_INFO       = st_document_output_info
         JOB_OUTPUT_INFO            = st_job_output_info
         JOB_OUTPUT_OPTIONS         = st_job_output_options
          TABLES
            IT_CLAIM_VERSION           = IT_CLAIM_VERSION
            IT_CLAIM_ITEM              = IT_CLAIM_ITEM
            IT_CLAIM_PARTNER           = IT_CLAIM_PARTNER
            IT_FINAL                   = IT_FINAL
       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.
        ELSE.
    CALL FUNCTION 'CONVERT_OTF_2_PDF'
          EXPORTING
             USE_OTF_MC_CMD               = 'X'
        ARCHIVE_INDEX                =
          IMPORTING
          BIN_FILESIZE   = v_bin_filesize
          TABLES
          OTF = st_job_output_info-OTFDATA[]
          DOCTAB_ARCHIVE = it_docs
          LINES  = it_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.
        ENDIF.
    HERE when i tried to debug it i got SY-SUBRC = 1.
    Please help me in this regard. Thanks in advance.

Maybe you are looking for

  • How do you get blood out of an Apple?

    Apologies to all if this is a slightly unusual posting, but I'm at the end of my tether. I'm a freelance graphic designer who, back in April, bought a G5 Quad. Yes, I know my timing was bad, but I needed it for a new project and couldn't wait for the

  • Bridge cache files for different bridge versions

    Bridge with CS2 and now CS3 is a superb image browsing tool - particularly when the cache files are within the directory containing the images. It would be very very useful if new versions of bridge could read older version cache files. If a user cre

  • What is the difference between 9i standard edition and enterprise edition

    hi, who can tell me what is the difference between ora 9i standard edition and enterprise edition?? relevant http links are also appreciated. thank you! regards, iron teung.

  • Garage Band 4.1.2 on Power Mac G4 messed up

    I had problems trying to change the tempo of the song, it always froze. So I tried to replace my Garage Band 4.1.2 with the same from my laptop that is an Intel one though. I guess that messed it up completely. Even if it doesn't show anything or doe

  • Project not connected error message,  when trying to Generate DDL on NWDS

    Hello, I created EJB project with Java Persistence Facets. 2 Entities created in the EJB to Generate as Data base table on the Java dictionary project. The connection works OK (I can ping to the JD project). But when I tried to Generate DDL and build