Convert spool (which is for smartform output) to PDF?

how to Convert spool which is for smartform output  to PDF?
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF' is not working for smartform output,
if i use this there will be error spool not contain list output?
than whats the function module or way to convert spool contain smartform output to pdg?
regards,

hi,
use this instead
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        formname                 = 'ZNAK_SMARTFORM_CORRESPONDENCE'
  VARIANT                  = ' '
  DIRECT_CALL              = ' '
     IMPORTING
       fm_name                  = func_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.
    printer-getotf = 'X'.
    printer-no_dialog = 'X'.
    CALL FUNCTION func_name
      EXPORTING
  ARCHIVE_INDEX              =
  ARCHIVE_INDEX_TAB          =
  ARCHIVE_PARAMETERS         =
   control_parameters         = printer
  MAIL_APPL_OBJ              =
  MAIL_RECIPIENT             =
  MAIL_SENDER                =
  OUTPUT_OPTIONS             =
  USER_SETTINGS              = 'X'
        validity                   = ls_smart-validity
        lifnr                      = ls_smart-lifnr
        name1                      = ls_smart-name1
        pstlz                      = ls_smart-pstlz
        regio                      = ls_smart-regio
        stras                      = ls_smart-stras
        smtp_addr                  = ls_smart-smtp_addr
IMPORTING
  DOCUMENT_OUTPUT_INFO       =
   job_output_info            = printer1
  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[] = printer1-otfdata.
DATA gt_tline like TABLE OF tline occurs 0 with header line.
    CALL FUNCTION 'CONVERT_OTF_2_PDF'
  EXPORTING
    USE_OTF_MC_CMD               = 'X'
    ARCHIVE_INDEX                =
     IMPORTING
       bin_filesize                 = w_file
      TABLES
        otf                          = t_otf
        doctab_archive               = gt_docs
        lines                        = gt_tline
  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.

Similar Messages

  • How to Convert spool which is for smartform output  to PDF?

    how to Convert spool which is for smartform output  to PDF?
    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF' is not working for smartform output,
    if i use this there will be error spool not contain list output?
    than whats the function module or way to convert spool contain smartform output to pdg?
    regards,

    <b>Procedure</b>
         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.
    <b>Here is a sample code of program to perform the function.</b>
    SAMPLE CODE
    [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.
    * 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.
    [/code]
    Thanks and Regards,
    Pavankumar

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

  • Generate spool req number for report output list

    Hi,
    How to generate spool request number for report output list while executing the report.Please provide if you have any sample code.
    Thanks and Regards,
    BSR.

    HI srinivas,
    welcome to sdn.
    Exporting the Contents of a Spool Request
    Use
    You want to export the content of a spool request in one of the following ways:
    ·        As a text file to the SAP GUI working directory
    ·        Unconverted or as a table, RTF, or HTML to a directory of your choice
    ·        As a PDF file to a directory of your choice
    Procedure
    Follow the procedure below:
    Exporting to the SAP GUI Working Directory
    If you are exporting large quantities of data, downloading the spool request as a text file to the SAP GUI working directory is a good solution.
    Choose Spool Request ® Forward® Export as Text.
    The entire text is stored in your SAP GUI working directory in ASCII format.
    A file of this type is named using the following pattern:
    .txt
    Example: ABC0000004327.txt
    You require appropriate authorization for this function from your administrator.
    Exporting Unconverted or as a table, RTF, or HTML to a Directory of Your Choice
    With this method of exporting a spool request, the content of the spool request is first displayed, and you then download the content in the format of your choice to a directory of your choice.
           1.      Select the spool request to be exported and choose  Display Contents.
           2.      In the case of SAPscript/Smart Forms documents, activate list display by choosing Goto.
           3.      Choose System ® List ® Save ® Local File.
           4.      Choose one of the available formats and confirm your choice.
           5.      Choose a directory and save the spool request.
    By default, only the first 10 pages of a spool request are saved in a file. You can increase the number of pages to be saved by choosing Goto ® Display Requests ® Settings and making the desired entries in the Display Area group box.
    Exporting as a PDF File
    You want to export the contents of a spool request as a PDF file to a directory of your choice, and print the file as required. The PDF file contains the print data in the format in which it would be output by the printer.
    The following procedure is irrelevant for the printing of PDF-based forms, since a PDF file is already returned with this method. See also Displaying and Printing PDF-Based Forms.
    You also require authorization from your administrator to run this report.
    The PDF file is generated as follows with report RSTXPDFT4:
           1.      Generate a spool request from the document to be printed.
           2.      In transaction SE38, start report rstxpdft4.
           3.      In the displayed window, enter the spool request number and the directory in which the PDF file is to be stored.
    Leave the Download PDF File option selected.
    Choose  Execute.
           4.      In the next window, you can confirm or change the path in which the file is be stored.
    Save your entries.
           5.      The system displays a log from which you can see whether the report was successfully performed.
    You can then open the file from the directory and print it as required.
    Restrictions for Exporting as a PDF File
    ·        The PDF conversion only supports true bar codes for Smart Forms, which were generated with the new bar code technology as of SAP NetWeaver 04. In all other cases, the bar code is only simulated.
    ·        PDF conversion, especially of ABAP lists, is slower and is therefore not suitable for mass printing. However, you can speed up the conversion to PDF using the FASTLISTCONV option in report RSTXPDF3.
    ·        The font selection for ABAP lists is predefined in the PDF converter and cannot be changed.
    For more information about constraints, see SAP Note 323736 in the SAP Service Marketplace
    see this links
    http://help.sap.com/saphelp_40b/helpdata/en/d9/4a98f351ea11d189570000e829fbbd/content.htm
    http://web.mit.edu/SAPR3/docs/webdocs/reports/rpRFprint.html
    regards
    shankar
    reward me if usefull

  • Error while converting smartform output to pdf

    hi
    while converting smartform output to pdf error occured otf data not founr.
    regarding code is as follows:
    otfitab = i_job_output_info-otfdata.
    CALL FUNCTION 'CONVERT_OTF_2_PDF'
    EXPORTING
       USE_OTF_MC_CMD               = 'X'
      ARCHIVE_INDEX                =
       IMPORTING
       bin_filesize                  = l_pdf_len
       TABLES
        otf                          = otfitab
        doctab_archive               = t_docs_tab
        lines                        = pdfitab
    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.
    rest all declarations are up to date.
    thanks in advance..........

    Hi Mayank,
    I am not sure if u know this already, we can convert the spool ouput to PDF
    by using the program RSTXPDFT4.
    Regards,
    Vivek

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

  • Convert the smartform output to PDF when giving print from vf31

    Hi Gurus,
    I am facing one problem.I developed the program to chnage smartform output to PDF file when giving invoice print from VF02/VF03.
    The same functionality i want to appy when i am giving print for the invoice through VF31.
    I put the break-point in the driver program.But it is not stopping there when i am giving print from VF31.
    How can i do this one..
    Please Help Me.
    Thanks &Regards,
    R.P.Sastry

    Which Program you are putting the Breakpoint?

  • 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

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

  • Logo in Smartform output to pdf format is coming as Junk Character

    Hi All,
    I have a requirement to generate the Smartform output in PDF file. But when i am doing that i am getting the LOGO as Junk character in the PDF file. Can any one help me to resolve this issue?.
    Thanks,
    Muruganand.K

    Yes check the spool and the output displayed correctly in the spool it means there is a problem when you convert OTF to PDF. Check that part of the code and try different options.

  • How to archive smartform output as PDF and store in External server

    Hi,
    I have requirement on archiving smartform output.
    1.need to archive smartform output as PDF  and need to store the PDF  in FileNet server.
    2.These iPDF need to link to SAP transaction FEBA_LOCKBOX at service for object level.
    I know that it can possible through SAP ArchiveLink feature , also aware that i have to enable Archive and Archive print button in the smartform output.
    If any body can give me some solutions it will be a great help.
    Regards,
    Ratheesh BS

    Hi,
    DATA: T_SSFCTRLOP TYPE SSFCTRLOP.   "FOR SMART FORMS
    DATA: T_SSFCRESCL TYPE SSFCRESCL.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          FORMNAME                 = 'Smart Form 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.
      T_SSFCTRLOP-NO_DIALOG = 'X'.
      T_SSFCTRLOP-GETOTF = 'X'.
      T_SSFCTRLOP-LANGU = 'E'.
      CALL FUNCTION FM_NAME
        EXPORTING
          CONTROL_PARAMETERS = T_SSFCTRLOP
        IMPORTING
          JOB_OUTPUT_INFO    = T_SSFCRESCL
        TABLES
          G_T_PERNR          = G_T_PERNR.  "(Internal Table).
      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 'HR_EFI_SHOW_PDF_FORM'
        EXPORTING
          TOP_EDGE  = 10
          LEFT_EDGE = 15
        TABLES
          OTF_TABLE = T_SSFCRESCL-OTFDATA.

  • Problem in converting smartforms output in pdf

    Hi all..
    I am trying to convert smartform's output in PDF file..
    I am able to convert smartforms's output in PDF but after that i can't see Print Preview..
    Code is following...
    REPORT ZMM_R402_FORM_TEST11.
    TABLES : VBRK,J_1IEXCHDR.
    SELECTION-SCREEN : BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-000.
    *PARAMETERS : EXNUM TYPE EXNUM OBLIGATORY.
    SELECT-OPTIONS : EXNUM FOR J_1IEXCHDR-EXNUM NO-EXTENSION OBLIGATORY.
    PARAMETERS : EXDAT LIKE J_1IEXCHDR-EXDAT OBLIGATORY.
    PARAMETERS : KUNNR LIKE VBRK-KUNAG OBLIGATORY.
    PARAMETERS : SR_NO(12) TYPE C.
    PARAMETERS : DATE1 TYPE EXDAT.
    SELECTION-SCREEN : END OF BLOCK BLK.
    DATA : FM_NAME(30) TYPE C.
    DATA : SR(12) TYPE C.
    UNPACK EXNUM-LOW TO EXNUM-LOW.
    UNPACK EXNUM-HIGH TO EXNUM-HIGH.
    DATA:
          it_otf                 TYPE STANDARD TABLE OF itcoo,
          it_docs               TYPE STANDARD TABLE OF docs,
          it_lines               TYPE STANDARD TABLE OF tline.
    Declaration of local variables.
    DATA:
          st_job_output_info            TYPE ssfcrescl,
          st_document_output_info  TYPE ssfcrespd,
          st_job_output_options       TYPE ssfcresop,
          st_output_options              TYPE ssfcompop,
          st_control_parameters       TYPE ssfctrlop,
          v_len_in                              TYPE so_obj_len,
          v_language                         TYPE sflangu VALUE 'E',
          v_e_devtype                      TYPE rspoptype,
          v_bin_filesize                      TYPE i,
          v_name                               TYPE string,
          v_path                                TYPE string,
          v_fullpath                           TYPE string,
          v_filter                                TYPE string,
          v_uact                                TYPE i,
          v_guiobj                             TYPE REF TO
    cl_gui_frontend_services,
          v_filename                         TYPE string,
          v_fm_name                        TYPE rs38l_fnam.
    CONSTANTS c_formname        TYPE tdsfname VALUE 'ZTEST'.
    *CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
    EXPORTING
       i_language          = v_language
       i_application        = 'SAPDEFAULT'
    IMPORTING
       e_devtype           = v_e_devtype.
    st_output_options-tdprinter = v_e_devtype.
    st_control_parameters-no_dialog = ' '.
    st_control_parameters-getotf = 'X'.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        FORMNAME                 = 'ZMM_402_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.
    ENDIF.
    **WRITE:/ FM_NAME.
    CALL FUNCTION FM_NAME
      EXPORTING
      control_parameters            = st_control_parameters
        output_options              = st_output_options
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
      CONTROL_PARAMETERS         =
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
      OUTPUT_OPTIONS             =
      USER_SETTINGS              = 'X'
        EXNUM                      = EXNUM-LOW
        EXNUM1                     = EXNUM-HIGH
        DATE                       = EXDAT
        KUNNR                      = KUNNR
        SR                         = SR_NO
        DATE1                      = DATE1
    IMPORTING
       document_output_info        = st_document_output_info
        job_output_info            = st_job_output_info
        job_output_options         = st_job_output_options
      DOCUMENT_OUTPUT_INFO       =   W_RETURN
      JOB_OUTPUT_INFO            =
      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.
    .........................CONVERT TO OTF TO PDF.......................
      CALL FUNCTION 'CONVERT_OTF_2_PDF'
        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.
    ........................GET THE FILE NAME TO STORE....................
      CONCATENATE 'smrt' '.pdf' INTO v_name.
      CREATE OBJECT v_guiobj.
      CALL METHOD v_guiobj->file_save_dialog
        EXPORTING
          default_extension  = 'pdf'
          default_file_name  = v_name
          file_filter                 = v_filter
        CHANGING
          filename                 = v_name
          path                       = v_path
          fullpath                  = v_fullpath
          user_action            = v_uact.
      IF v_uact = v_guiobj->action_cancel.
        EXIT.
      ENDIF.
    ..................................DOWNLOAD AS FILE....................
      MOVE v_fullpath TO v_filename.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          bin_filesize              = v_bin_filesize
          filename                  = v_filename
          filetype                   = 'BIN'
        TABLES
          data_tab                = it_lines
        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.
    ENDIF.
    Please Help me ..
    How can i see print preview..

    use like this:
       call function lf_fm_name
               exporting
                        archive_index        = toa_dara
                        archive_parameters   = arc_params
                        control_parameters   = ls_control_param         "Smart Forms: Control structure
                        mail_recipient       = ls_recipient
                        mail_sender          = ls_sender                "Structure for Object ID
                        output_options       = ls_composer_param        "SAP Smart Forms: Smart Composer (transfer) options
                        user_settings        = ' '
                        is_dlv_delnote       = ls_dlv_delnote           "Delivery Note Data: Transfer-Structure for Smartform
                        is_nast              = nast                     "Nast
             exceptions formatting_error     = 1
                        internal_error       = 2
                        send_error           = 3
                        user_canceled        = 4
                        others               = 5.
            if sy-subrc <> 0.
      error handling
              cf_retcode = sy-subrc.
              perform protocol_update.
        get SmartForm protocoll and store it in the NAST protocoll
              perform add_smfrm_prot.                  "INS_HP_335958
            endif.
    *To read the Spool Number generated
            read table it_job_output_info-spoolids into v_rspoid index 1.
    concatenate 'aBC.pdf' into v_file_name.
    submit rstxpdft4 and return
              with   spoolno = v_rspoid
              with   p_file  = v_file_name.
              clear: v_rspoid.

  • Convert Smartform Output to PDF

    Hi all,
    I am trying to save Output of Smartform in PDF file format. for that purpose i am calling "CONVERT_OTF" FM from my driver program.
    But it is giving me Information "OTF end command // missing in OTF data"
    while executing FM "CONVERT_OTF". i debug it it is giving Sy-subrc = 2.
    Please Help me in this context. I am also givin code of my driver program:
    TABLES: vbrp.
    DATA: fm_name TYPE rs38l_fnam,
    it_invoice TYPE STANDARD TABLE OF vbrp,
    it_invoice_wa TYPE vbrp,
    it_inv TYPE STANDARD TABLE OF vbrp,
    it_inv_wa TYPE vbrp,
    invoice_no(25) TYPE c,
    invoice_l(10) TYPE c,
    invoice_h(10) TYPE c.
    Converting Output to PDF Declaration **********
    DATA: tab_otf_data TYPE ssfcrescl,
    pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
    bin_filesize LIKE sood-objlen,
    outop TYPE ssfcompop, " Output Parameters
    cparam TYPE ssfctrlop, " Control Parameters
    tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
    my_tabix TYPE sy-tabix,
    file_size TYPE i.
    SELECT-OPTIONS doc_no FOR vbrp-vbeln.
    SELECT vbeln posnr fkimg vrkme meins netwr matnr
    FROM vbrp INTO CORRESPONDING FIELDS
    OF TABLE it_invoice
    WHERE vbeln IN doc_no.
    Inserting Unique Invoice Numbers for Displaying Individual Details in
    Smart Form
    LOOP AT it_invoice INTO it_invoice_wa.
    AT NEW vbeln.
    MOVE it_invoice_wa-vbeln TO it_inv_wa-vbeln.
    APPEND it_inv_wa TO it_inv.
    ENDAT.
    ENDLOOP.
    invoice_no = doc_no.
    invoice_l = doc_no-low.
    invoice_h = doc_no-high.
    suppressing the Print dialog box *********************
    *outop-tddest = 'locl'.
    *cparam-no_dialog = 'X'.
    *cparam-preview = space.
    *cparam-getotf = 'X'.
    START-OF-SELECTION.
    Calling Smart Form *********************************
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    formname = 'ZSB_SMARTFORM_INVOICE'
    VARIANT = ' '
    DIRECT_CALL = ' '
    IMPORTING
    fm_name = fm_name
    CALL FUNCTION fm_name
    EXPORTING
    invoice_no_h = invoice_h
    invoice_no_l = invoice_l
    ARCHIVE_INDEX =
    ARCHIVE_INDEX_TAB =
    ARCHIVE_PARAMETERS =
    control_parameters = cparam
    MAIL_APPL_OBJ =
    MAIL_RECIPIENT =
    MAIL_SENDER =
    output_options = outop
    user_settings = ''
    IMPORTING
    DOCUMENT_OUTPUT_INFO =
    JOB_OUTPUT_INFO = tab_otf_data
    JOB_OUTPUT_OPTIONS =
    TABLES
    it_invoice = it_invoice
    it_inv = it_inv
    ***removing the initial and final markers from the OTF data*********
    DELETE tab_otf_data-otfdata WHERE tdprintcom = '//'.
    searching for the end-of-page in OTF table************
    READ TABLE tab_otf_final WITH KEY tdprintcom = 'EP'.
    my_tabix = sy-tabix + 1.
    appending the modified OTF table to the final OTF table****
    *INSERT LINES OF tab_otf_data-otfdata INTO tab_otf_final INDEX my_tabix.
    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.
    write :/ bin_filesize.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE = bin_filesize
    filename = 'E:/Test.pdf'
    FILETYPE = 'ASC'
    IMPORTING
    FILELENGTH = file_size
    tables
    data_tab = pdf_tab
    FIELDNAMES =
    Help will be rewarded.
    Regards,
    Sachin

    hi
    good
    go through this ,hope this ll help you to solve this problem
    Check out the following documentation and example program and help links
    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
    here is the example for SAMRTFORM TO PDF.
    http://www.sap4.com/wiki/index.php/Genera_PDF_a_partir_de_Smartforms
    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.
    reward poing if helpful..
    thanks
    mrutyun^

  • 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

  • Problem in sending the Smartform Output as PDF through Mail

    Dear All,
    I am sending the Smartform Output as an attachment by converting it into PDF. But when I am recieve this attachment I am unable to open the PDF file, it is giving error that FILE IS DAMAGED. Below is the code:
    REPORT  Y_SEND_MAIL2.
    TABLES: vbrk, vbrp.
    TYPE-POOLS: abap.
    DATA: it_vbrk TYPE TABLE OF vbrk WITH HEADER LINE.
    DATA: i_formname      TYPE       tdsfname,
          i_fm_name       TYPE       rs38l_fnam,
          it_vbak TYPE TABLE OF vbak WITH HEADER LINE,
          it_ekko TYPE TABLE OF ekko WITH HEADER LINE.
    DATA:  is_bil_invoice TYPE lbbil_invoice,
           output_options      TYPE ssfcompop,
           control_parameters  TYPE ssfctrlop,
           e_devtype           TYPE rspoptype,
           job_output_info     TYPE ssfcrescl,
           bin_file            TYPE xstring,
           lines               TYPE TABLE OF tline WITH HEADER LINE,
           doctab_archive      TYPE TABLE OF docs WITH HEADER LINE,
           filelength          TYPE i,
           bin_filesize        TYPE i,
           docs          TYPE TABLE OF docs WITH HEADER LINE.
    *"Types
    TYPES: t_document_data TYPE sodocchgi1,
           t_packing_list TYPE sopcklsti1,
           t_attachment TYPE solisti1,
           t_body_msg TYPE solisti1,
           t_receivers TYPE somlreci1,
           t_pdf TYPE tline.
    *"Workareas
    DATA :w_document_data TYPE t_document_data,
          w_packing_list TYPE t_packing_list,
          w_attachment TYPE t_attachment,
          w_body_msg TYPE t_body_msg,
          w_receivers TYPE t_receivers,
          w_pdf TYPE t_pdf.
    *internal tables
    DATA : i_document_data TYPE STANDARD TABLE OF t_document_data,
           i_packing_list TYPE STANDARD TABLE OF t_packing_list,
           i_attachment TYPE STANDARD TABLE OF t_attachment,
           i_body_msg TYPE STANDARD TABLE OF t_body_msg,
           i_receivers TYPE STANDARD TABLE OF t_receivers,
           i_pdf TYPE STANDARD TABLE OF t_pdf.
    DATA: BEGIN OF line_bin,
             data(1024) TYPE x,
          END OF line_bin.
    DATA: data_tab_bin LIKE STANDARD TABLE OF line_bin.
    So please suggest a solution.
    Regards,
    Vishal

    Continued:
    SELECT-OPTIONS: s_vbeln FOR vbrk-vbeln,
                    s_fkdat FOR vbrk-fkdat OBLIGATORY DEFAULT sy-datum.
    SELECT * FROM vbrk
    INTO TABLE it_vbrk
    WHERE fkdat IN s_fkdat
          AND vbeln IN s_vbeln.
    i_formname = 'Z_SD_JINDAL_INVOICE10'.
    output_options-tddest        = 'LP02'.
    output_options-tdimmed       = 'X'.
    output_options-tdnewid       = 'X'.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        formname           = i_formname
      IMPORTING
        fm_name            = i_fm_name
      EXCEPTIONS
        no_form            = 1
        no_function_module = 2
        OTHERS             = 3.
    IF sy-subrc <> 0.          "checking subrc
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.                     "IF sy-subrc <> 0
    READ TABLE it_vbrk INDEX 1.
    IF sy-subrc = 0.
      is_bil_invoice-hd_gen-bil_number = it_vbrk-vbeln.
    ENDIF.
    control_parameters-no_dialog = 'X'.
    control_parameters-getotf = 'X'.
    CALL FUNCTION i_fm_name        "'/1BCDWB/SF00000097'
      EXPORTING
       control_parameters         = control_parameters
       output_options             = output_options
       user_settings              = space
       is_bil_invoice             = is_bil_invoice
    IMPORTING
       job_output_info            = job_output_info
    TABLES
       it_vbak                    = it_vbak
    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.
    *FORM convert_otf_2_pdf.
      CALL FUNCTION 'CONVERT_OTF_2_PDF'
    *      EXPORTING
    *        USE_OTF_MC_CMD               = 'X'
    *        ARCHIVE_INDEX                =
        IMPORTING
          bin_filesize                 = bin_filesize
        TABLES
          otf                          = job_output_info-otfdata[]
          doctab_archive               = docs[]
          lines                        = 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.
    *ENDFORM.                    "convert_otf_2_pdf

Maybe you are looking for