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^

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

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

  • Problem while converting smartform out to PDF.

    Hi,
    I have an issue while converting smartform output to PDF. After converting samrtform out to PDF, apostrophe(') is appearing as # in the pdf file. For example the word Indian's is getting printed as Indian#s. I'm using Helvetica font for printing this text.
    How ever print preview is coming fine.
    Could anybody provide me some inputs to solve this.
    Thanks,
    Rick.

    I'm using FM: CONVERT_OTF
    CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
        IMPORTING
          bin_filesize          = lv_filesize
        TABLES
          otf                   = ls_job_info-otfdata
          lines                 = lt_pdf_table
        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.

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

  • 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

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

  • 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

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

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

  • 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

  • To convert smartform spool to pdf

    Hi all,
    I need to convert smartfom spool to pdf..
    When i executed the smartform it is generating a spool number and
    tsp01-rqdoctype =  'SMART'.
    To convert Spool to PDF Iam using the following function module
    'CONVERT_ABAPSPOOLJOB_2_PDF'
    It is converting to pdf only if the document type is 'LIST'.
    can any one suggest me how to convert smartform spool to pdf?
    Regards
    cnu

    Hi
    Refer to this link :
    Re: smartform output to mail
    Reward if useful
    Thanks
    Krushna

Maybe you are looking for

  • My spotcolors aren't displaying correctly. (Different from the swatch)

    I am having an issue that has just randomly happened where when I want to make a colour a certain spot colour from my swatch library fill a certain shape it DOESNT CHANGE the colour yet it SAYS IT IS ANOTHER COLOUR when I do a separations preview. I'

  • Itunes has encountered a problem and needs to close.. please help!

    i used to have the old itunes when i got this message saying "Itunes has encountered a problem and needs to close" and it just wouldn't open! so i tried installing the new itunes and it stil gave the same message! ive done a system update on a date w

  • Accounts on Icloud

    Hello, I have an ipad and I'd like to have two or more different accounts on Icloud. Is it possible? Thank you very much for any help!

  • Part appearing to be ordered in me21n

    Hi Gurus, can anybody plz help me with this? Part number xxxx keeps showing up for me to order thru MRP but there is no opens sales order that I can find.  This is a third party shipment. Can you please explain to me why this keeps appearing on my Cr

  • Customer data

    Hi all 1.What is master data? 2.What is customer  data? 3.What is customer master data? 4.What is master data management (MDM)? With Regards Vijay