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

Similar Messages

  • 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

  • Multiple smartform Outputs in Single PDF

    Hi,
    I am displaying ALV report , from there I am converting my smartform output into PDF using CONVERT_OTF and Downloading it to my desktop.
    Now user is looking for push button in ALV, i.e Display PDF in Single File. I have created the pushbutton and tried to convert the OTF data PDF as per below link.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/62ae7fcd-0b01-0010-3e9d-a54f26944450?quicklink=index&overridelayout=true
    My file is downloading to the desired path. When i tried to open that file it is giving error message as below.
    THERE WAS AN ERROR OPENING THIS DOCUMENT .  THE FILE IS DAMAGED AND COULD NOT BE REPAIRED.
    when i seleted the rows seperatly, it is displaying as PDF correctly, but if i tried to append the lines as per the above reference link i am getting the problem.
    Can anyone please help me out to solve this.
    Thanks & Regards,
    Srinivas Bhavanam
    Moderator message - Cross post locked
    Edited by: Rob Burbank on Mar 24, 2010 6:25 PM

    This article is correct about the //. First make sure you remove them correctly, and nothing else. Only 2 // must remain, one at the beginning, one at the end.

  • While converting smartform output toPDF: end command // missing in OTF data

    Hi,
    While Converting smartform output to PDF i am getiing the following error.
    end command // missing OTF data . And also in the importing parameter of smartform  function module also (job_output_info ) i did not findout the data. Where did i make a mistake. How can i correct this error. Thanks in advance.

    Implemented SAP Note 1123505 - OTF-PDF conversion.

  • Setting Font for converting multiple text files into PDF using VB 6.0

    Dear All,
    Am converting multiple text files into PDF using VB6.0. Currently, am unable to control the font face and size for the generated files. Below is the procedure am using for each file;
    Public Sub proc_convert_to_PDF(srcFilename As String, destFilename As String)
    Dim p_AcroApp As CAcroApp
    Dim p_VDoc As CAcroAVDoc
    Dim p_DDoc As CAcroPDDoc
    Dim IsOk As Boolean
    Set p_AcroApp = CreateObject("AcroExch.App")
    Set p_VDoc = CreateObject("AcroExch.AVDoc")
    Call p_VDoc.Open(srcFilename, "")
    Set p_VDoc = p_AcroApp.GetActiveDoc
    If p_VDoc.IsValid Then
    Set p_DDoc = p_VDoc.GetPDDoc
    ' Fill in pdf properties.
    p_DDoc.SetInfo "Title", Format(Date, "dd-mm-yyy")
    p_DDoc.SetInfo "Subject", srcFilename
    If p_DDoc.Save(1 Or 4 Or 32, destFilename) <> True Then
    MsgBox "Failed to save " & srcFilename
    End If
    p_DDoc.Close
    End If
    'Close the PDF
    p_VDoc.Close True
    p_AcroApp.Exit
    'Clear Variables
    Set p_DDoc = Nothing
    Set p_VDoc = Nothing
    Set p_AcroApp = Nothing
    End Sub
    What I need;
    1) to be able to set the font face of the destination file ( destFilename)
    2) to be able to set the font size of the destination file ( destFilename)
    Am using Adobe Acrobat 7.0 Type Library
    Kindly Help.
    Thanks in advance

    We didn't say it doesn't work. We said it isn't supported.
    There are a number of other ways to make a PDF. The one which would
    give the most control is if your application directly printed to GDI,
    controlling the font directly. This could print to Adobe PDF.
    You could look for an application that gives control of font for
    printing.
    You could use a text-to-PostScript system and distill the result. You
    could even look for a non-Adobe text-to-PDF.
    Working in the unsupported and dangerous world you chose, the font
    size for text conversion is set (and this is very bad design from
    Adobe) in the settings for Create PDF > From Web Page. There is no API
    to this.
    Aandi Inston

  • To convert multiple image files to pdf using pdfsharp in C#

    Hey guys I have this C# code to convert any image file to .pdf using pdfsharp.dll. But I want to select multiple images for conversion please help. here's my code (plz note enable pdfsharp.dll in the reference)
    usingSystem;
    usingSystem.Collections.Generic;
    usingSystem.Linq;
    usingSystem.Text;
    usingSystem.Threading.Tasks;
    usingPdfSharp.Pdf;
    usingPdfSharp.Drawing;
    usingSystem.IO;
    namespaceConsoleApplication1
    classProgram
    staticvoidMain(string[]
    args)
    PdfDocumentdoc =
    newPdfDocument();
    doc.Pages.Add(newPdfPage());
    XGraphicsxgr =
    XGraphics.FromPdfPage(doc.Pages[0]);
    XImageimg =
    XImage.FromFile(source
    path...);
    xgr.DrawImage(img,0,0);
    doc.Save(destination path...);
    doc.Close();

    try this one
    public string CreatePDF(System.Collections.Generic.List<byte[]> images)
    dynamic PDFGeneratePath = Server.MapPath("../images/pdfimages/");
    dynamic FileName = "attachmentpdf-" + DateTime.Now.Ticks + ".pdf";
    if (images.Count >= 1) {
    Document document = new Document(PageSize.LETTER);
    try {
    // Create pdfimages directory in images folder.
    if ((!Directory.Exists(PDFGeneratePath))) {
    Directory.CreateDirectory(PDFGeneratePath);
    // we create a writer that listens to the document
    // and directs a PDF-stream to a file
    PdfWriter.GetInstance(document, new FileStream(PDFGeneratePath + FileName, FileMode.Create));
    // opens up the document
    document.Open();
    // Add metadata to the document. This information is visible when viewing the
    // Set images in table
    PdfPTable imageTable = new PdfPTable(2);
    imageTable.DefaultCell.Border = Rectangle.NO_BORDER;
    imageTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
    for (int ImageIndex = 0; ImageIndex <= images.Count - 1; ImageIndex++) {
    if ((images(ImageIndex) != null) && (images(ImageIndex).Length > 0)) {
    iTextSharp.text.Image pic = iTextSharp.text.Image.GetInstance(SRS.Utility.Utils.ByteArrayToImage(images(ImageIndex)), System.Drawing.Imaging.ImageFormat.Jpeg);
    // Setting image resolution
    if (pic.Height > pic.Width) {
    float percentage = 0f;
    percentage = 400 / pic.Height;
    pic.ScalePercent(percentage * 100);
    } else {
    float percentage = 0f;
    percentage = 240 / pic.Width;
    pic.ScalePercent(percentage * 100);
    pic.Border = iTextSharp.text.Rectangle.BOX;
    pic.BorderColor = iTextSharp.text.BaseColor.BLACK;
    pic.BorderWidth = 3f;
    imageTable.AddCell(pic);
    if (((ImageIndex + 1) % 6 == 0)) {
    document.Add(imageTable);
    document.NewPage();
    imageTable = new PdfPTable(2);
    imageTable.DefaultCell.Border = Rectangle.NO_BORDER;
    imageTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
    if ((ImageIndex == (images.Count - 1))) {
    imageTable.AddCell(string.Empty);
    document.Add(imageTable);
    document.NewPage();
    } catch (Exception ex) {
    throw ex;
    } finally {
    // Close the document object
    // Clean up
    document.Close();
    document = null;
    return PDFGeneratePath + FileName;

  • Have an Adobe PRO 11 user converting a word Document to PDF using PDFMAKER and all of the numbering is disappearing from left column,.  Has anyone had this happen and if so what is the fix?

    have an Adobe PRO 11 user converting a word Document to PDF using PDFMAKER and all of the numbering is disappearing from left column,.  Has anyone had this happen and if so what is the fix?

    Is it possible to post a sample page some place for us to try out (dropbox or acrobat.com)? Is your Acrobat updated? What version of WORD are you using?

  • Multiple smartform output to single pdf file

    HI,
    I am new to ABAP. I have a requirement to combine multiple smartfrom output to  single pdf file.  I searched in this site. I got material but i did not get the complete concept. Can anybody tell me the methodology and sample code to do that.
    Thanks & regards,
    Maha.

    Hi Mahalakshmi,
    Clik on the link to view document: <b>[Combining Multiple Smartform Outputs Into One PDF File|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/62ae7fcd-0b01-0010-3e9d-a54f26944450?overridelayout=true]</b>
    Thanks
    Venkat.O

  • Convert arabic word document to pdf using Inbound Refinery

    convert arabic word document to pdf using Inbound Refinery creating problem. After pdf convert the converted pdf changes to left to right instead of right to left.

    In that case you will need to look at the Adobe LiveCycle ES PDF Generator product, as it is licensed and suitable for server-based conversion.  Adobe Acrobat can not legally be used in the environment that you describe.

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

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

  • Smartform output to a PDF file, using it as an attachment to send the mail.

    Hi,
    I have a smartform output, which needs to be converted to PDF file and it should be mailed to a user as an attachment.
    Could anyone please tell me how this can be done.
    Thanks & Regards,
    Goutham.

    Hi ,
    Find the code below:
    Reward if helpful
    *&      Form  smart_form_process
          Make calls to required functions exporting GT_INTERFACE
    FORM smart_form_process CHANGING cf_retcode TYPE sy-subrc.
    Smart form data
    DATA:
      w_ssfname         TYPE tdsfname,             "Smart form name
      lf_fm_name        TYPE rs38l_fnam.           "Function module name
    Local data:
      DATA:
        ls_control_param  TYPE ssfctrlop,           "Control paramters
        ls_output_options TYPE ssfcompop.           "Output options
    Data for email smart form:
      DATA:
        lv_ip_mailaddr  TYPE so_name,               "Address of a Mail Recipient
        lv_ip_type_id   TYPE so_escape,             "Recipient type
        ls_recipient_id TYPE swotobjid,             "Structure for recvr obj ID
        ls_sender_id    TYPE swotobjid.             "Structure for sender obj id
    Constants:
      CONSTANTS:
        lc_ip_type_id TYPE so_escape VALUE 'U',               "For internet address.
        lc_smartform  TYPE tdsfname VALUE 'ZVSF_ASN_DELNOTE', "Smart form name
        lc_mail       TYPE tddevice VALUE 'MAIL'.             "Mail device
    Assign recipient
      lv_ip_mailaddr = gv_smtp_addr.                "CSAM email id
      lv_ip_type_id  = lc_ip_type_id.               "External address
    Create Mail title
      CONCATENATE text-001
                  nast-objky
             INTO ls_output_options-tdtitle.
    Create recipient object
      CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
        EXPORTING
          ip_mailaddr       = lv_ip_mailaddr
          ip_type_id        = lv_ip_type_id
        IMPORTING
          ep_recipient_id   = ls_recipient_id
        EXCEPTIONS
          invalid_recipient = 1
          OTHERS            = 2.
      IF sy-subrc <> 0.
      error handling
        cf_retcode = sy-subrc.
        PERFORM protocol_update.
      ENDIF.
    Get sender object id.
      CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
        EXPORTING
          ip_sender      = sy-uname
        IMPORTING
          ep_sender_id   = ls_sender_id
        EXCEPTIONS
          invalid_sender = 1
          OTHERS         = 2.
      IF sy-subrc <> 0.
      error handling
        cf_retcode = sy-subrc.
        PERFORM protocol_update.
      ENDIF.
    Assign the smart form name
      w_ssfname = lc_smartform.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = w_ssfname
        IMPORTING
          fm_name            = lf_fm_name
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      IF sy-subrc <> 0.
      error handling
        cf_retcode = sy-subrc.
        PERFORM protocol_update.
      ENDIF.
    For email output.
    Output options
      ls_output_options-BCS_COMMIT = 'X'.
        ls_control_param-device  = lc_mail.
      ENDIF.
    dynamically call Fm behind the Smart form
      CALL FUNCTION lf_fm_name
        EXPORTING
          control_parameters = ls_control_param
          mail_recipient     = ls_recipient_id
          mail_sender        = ls_sender_id
          output_options     = ls_output_options
          user_settings      = ' '
        TABLES
          delivery           = gt_delivery
        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.
      ENDIF.
    ENDFORM.                                        " smart_form_process

  • Converting Smartforms output content into HTML File

    Hi,
    I have a requirement, Smartforms output contents needs be converted as HTML File and it should be sent as email.
    I am able to get the Smartforms output in html format but the output is shown as binary format.
    After the fm call the job_output_info parameter is holding the smartforms output content in
    job_output_info-XMLOUTPUT[]           (xsf content)
    job_output_info-XMLOUTPUT-STSHEET[]   (css content)
    job_output_info-XMLOUTPUT-TRFRESULT[] (html content)
    Help me out how to handle the job_output_info details to html format.
    Code
    DATA v_fm_name TYPE rs38l_fnam.
    DATA v_tdsfname TYPE tdsfname VALUE 'ZVR39_SF'.
    DATA output_options TYPE ssfcompop.
    DATA job_output_info TYPE ssfcrescl.
    DATA document_output_info TYPE ssfcrespd.
    DATA job_output_options TYPE ssfcresop.
    DATA w_control TYPE ssfctrlop.
    *-Finding the Smartform Layout Name
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        formname           = v_tdsfname
      IMPORTING
        fm_name            = v_fm_name
      EXCEPTIONS
        no_form            = 1
        no_function_module = 2
        OTHERS             = 3.
    *-Defining the output to HTML Format
    *-Activating XSF Output
    output_options-xdfcmode   = 'X'.
    output_options-xdf        = space.
    output_options-xsfcmode   = 'X'.
    output_options-xsf        = 'X'.
    output_options-xsfoutmode = 'A'. "
    output_options-xsfoutdev  = 'P863'.
    output_options-xsfformat  = 'X'.
    *-Calling the Smartform Layout
    CALL FUNCTION v_fm_name
      EXPORTING
        output_options       = output_options
        user_settings        = 'X'
      IMPORTING
        document_output_info = document_output_info
        job_output_info      = job_output_info
        job_output_options   = job_output_options
      EXCEPTIONS
        formatting_error     = 1
        internal_error       = 2
        send_error           = 3
        user_canceled        = 4
        OTHERS               = 5.
    Giri

    Hi,
    Check this link.In that,I am converting the output of smartform to PDF and then attaching it through mail.
    https://sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap code samples/smartforms/smartform in abap.pdf

  • Converting smartform output to a text file

    Hi ,
    can anyone explain me in detail that whether a smartform output can be converted to an excel file via ABAP coding in driver program.
    If yes pls tell me how to do it . Thanks...
    Regards,
    Rose.

    Hi,
    I don't know whether its possible (or meaningful) to convert a smartform to excel. But you can find lots of thread to convert a smartform to PDF.
    SEARCH SCN with "smartform to pdf".
    Regards
    Karthik D

Maybe you are looking for