Smartform into PDF and store in folder of  application server

Hi Gurus,
     I have to solve this issue please help meu2026
1.Convert Smartform into PDF and store in folder of  application server
2.print the PDF stored in folder(Application Server) automatically
Please give suggestion for the above..
Moderator message: "spec dumping", please work yourself first on your requirement.
Edited by: Thomas Zloch on Oct 7, 2011 10:39 AM

hi uma,
http://www.kodyaz.com/articles/sap-smartforms-download-as-smartform-pdf-using-ws_download-and-cl_gui_frontend_services.aspx
check this out...
thanks,
ram

Similar Messages

  • CONVERTING SMARTFORM INTO PDF AND PRINTING DIRECTLY

    Hai guys,
       I got a problem.
    First the Smartform I created doesnt show all TABLE LINES(the rows coloumns)...
    so I have converted the SMART FORM to ADOBE FORM PROGRAMITICALY ...
    now in order to PRINT ..
    one has to first SAVE the FORM(adobe form) onto desktop(or whereever) and give it to PRINT...
    unfortunately my CLIENT doeasnt like the EXTRA STEP..
    so i best i can SAVE the file to a hardcoded location and
    OPEN it ..
    But then CAN I
    a)PRINT DIRECTLY without SAVING??
    b)ISSUE PRINT PROGRAMITICALY
    c)I learnt that a SMARTFORM can be GENERATED INTO PDF only at RUNNTIME(from SMARTFORMS>UTILITIES etc)..i briefly tried that..can I use that to GET THE PDF to PRINT when one gives PRINT from SPOOL REQUEST(sp01)
    hoping to give some quick points

    Hi,
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    or
    *& 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.
    Regards,
    Kumar

  • How to convert smartform into pdf and send through mail

    Hi Guru,
    I want to send smartform to mail after converting into pdf format.
    if anyof u gives solution its greate.
    Thanks & Regards,
    Lakshmi..

    Hi,
    i can help you till
    downloading the smartform as pdf format
    check this
    DATA: GIT_BSIK LIKE BSIK OCCURS 0 WITH HEADER LINE.
    Variable declarations
    DATA:
    W_FORM_NAME TYPE TDSFNAME VALUE 'ZFII_EDD001',
    W_FMODULE TYPE RS38L_FNAM,
    W_CPARAM TYPE SSFCTRLOP,
    W_OUTOPTIONS TYPE SSFCOMPOP,
    W_BIN_FILESIZE TYPE I, " Binary File Size
    W_FILE_NAME TYPE STRING,
    W_FILE_PATH TYPE STRING,
    W_FULL_PATH TYPE STRING.
    Internal tables declaration
    Internal table to hold the OTF data
    DATA:
    T_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
    Internal table to hold OTF data recd from the SMARTFORM
    T_OTF_FROM_FM TYPE SSFCRESCL,
    Internal table to hold the data from the FM CONVERT_OTF
    T_PDF_TAB LIKE TLINE OCCURS 0 WITH HEADER LINE.
    This function module call is used to retrieve the name of the Function
    module generated when the SMARTFORM is activated
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
        FORMNAME = W_FORM_NAME
        VARIANT = ' '
        DIRECT_CALL = ' '
        IMPORTING
        FM_NAME = W_FMODULE
        EXCEPTIONS
        NO_FORM = 1
        NO_FUNCTION_MODULE = 2
        OTHERS = 3
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    Calling the SMARTFORM using the function module retrieved above
    GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF
    format of the output
    W_CPARAM-NO_DIALOG = 'X'.
    W_CPARAM-PREVIEW = SPACE. " Suppressing the dialog box
    " for print preview
    W_CPARAM-GETOTF = 'X'.
    Printer name to be used is provided in the export parameter
    OUTPUT_OPTIONS
    W_OUTOPTIONS-TDDEST = 'ZPC_'.
          CALL FUNCTION W_FMODULE
          EXPORTING
          ARCHIVE_INDEX =
          ARCHIVE_INDEX_TAB =
          ARCHIVE_PARAMETERS =
          CONTROL_PARAMETERS = W_CPARAM
          MAIL_APPL_OBJ =
          MAIL_RECIPIENT =
          MAIL_SENDER =
          OUTPUT_OPTIONS = W_OUTOPTIONS
          USER_SETTINGS = 'X'
          IMPORTING
          DOCUMENT_OUTPUT_INFO =
          JOB_OUTPUT_INFO = T_OTF_FROM_FM
          JOB_OUTPUT_OPTIONS =
               TABLES
                ITAB                       = GIT_BSIK
          EXCEPTIONS
          FORMATTING_ERROR = 1
          INTERNAL_ERROR = 2
          SEND_ERROR = 3
          USER_CANCELED = 4
          OTHERS = 5.
          IF SY-SUBRC <> 0.
            MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    T_OTF[] = T_OTF_FROM_FM-OTFDATA[].
    Function Module CONVERT_OTF is used to convert the OTF format to PDF
          CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
          FORMAT = 'PDF'
          MAX_LINEWIDTH = 132
          ARCHIVE_INDEX = ' '
          COPYNUMBER = 0
          ASCII_BIDI_VIS2LOG = ' '
          PDF_DELETE_OTFTAB = ' '
          IMPORTING
          BIN_FILESIZE = W_BIN_FILESIZE
          BIN_FILE =
          TABLES
          OTF = T_OTF
          LINES = T_PDF_TAB
          EXCEPTIONS
          ERR_MAX_LINEWIDTH = 1
          ERR_FORMAT = 2
          ERR_CONV_NOT_POSSIBLE = 3
          ERR_BAD_OTF = 4
          OTHERS = 5
          IF SY-SUBRC <> 0.
            MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
    *To display File SAVE dialog window
    CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
    WINDOW_TITLE =
    DEFAULT_EXTENSION =
    DEFAULT_FILE_NAME =
    FILE_FILTER =
    INITIAL_DIRECTORY =
    WITH_ENCODING =
    PROMPT_ON_OVERWRITE = 'X'
    CHANGING
    filename = w_FILE_NAME
    path = w_FILE_PATH
    fullpath = w_FULL_PATH
    USER_ACTION =
    FILE_ENCODING =
    EXCEPTIONS
    CNTL_ERROR = 1
    ERROR_NO_GUI = 2
    NOT_SUPPORTED_BY_GUI = 3
    others = 4
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
    presentation server
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE = W_bin_filesize
    filename = w_FULL_PATH
    FILETYPE = 'BIN'
    APPEND = ' '
    WRITE_FIELD_SEPARATOR = ' '
    HEADER = '00'
    TRUNC_TRAILING_BLANKS = ' '
    WRITE_LF = 'X'
    COL_SELECT = ' '
    COL_SELECT_MASK = ' '
    DAT_MODE = ' '
    CONFIRM_OVERWRITE = ' '
    NO_AUTH_CHECK = ' '
    CODEPAGE = ' '
    IGNORE_CERR = ABAP_TRUE
    REPLACEMENT = '#'
    WRITE_BOM = ' '
    TRUNC_TRAILING_BLANKS_EOL = 'X'
    WK1_N_FORMAT = ' '
    WK1_N_SIZE = ' '
    WK1_T_FORMAT = ' '
    WK1_T_SIZE = ' '
    IMPORTING
    FILELENGTH =
    tables
    data_tab = T_pdf_tab
    FIELDNAMES =
    EXCEPTIONS
    FILE_WRITE_ERROR = 1
    NO_BATCH = 2
    GUI_REFUSE_FILETRANSFER = 3
    INVALID_TYPE = 4
    NO_AUTHORITY = 5
    UNKNOWN_ERROR = 6
    HEADER_NOT_ALLOWED = 7
    SEPARATOR_NOT_ALLOWED = 8
    FILESIZE_NOT_ALLOWED = 9
    HEADER_TOO_LONG = 10
    DP_ERROR_CREATE = 11
    DP_ERROR_SEND = 12
    DP_ERROR_WRITE = 13
    UNKNOWN_DP_ERROR = 14
    ACCESS_DENIED = 15
    DP_OUT_OF_MEMORY = 16
    DISK_FULL = 17
    DP_TIMEOUT = 18
    FILE_NOT_FOUND = 19
    DATAPROVIDER_EXCEPTION = 20
    CONTROL_FLUSH_ERROR = 21
    OTHERS = 22
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    thanks & regards,
    Venkatesh

  • Convert SmartForm into PDF(PDF should be password protected)

    Hi Friends,
                  This is my requirement.
    Need to convert SmartForm into PDF and this PDF should be send as an email with attachment and PDF should be password protected.
    Can anyone plz help me???

    Dear Jena,
                   This is my code.
       CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname = 'ZBIN_SMARTFORM'
        IMPORTING
          fm_name  = v_fm.
    *&   ASSIGNING VALUES TO FORM CONTROL STRUCTURE AND FORM COMPOSER
      gs_ctrlop-getotf = 'X'.
      gs_ctrlop-device = 'PRINTER'.
      gs_ctrlop-preview = ' '.
      gs_ctrlop-no_dialog = 'X'.
      gs_outopt-tddest = 'LOCL'.
    *                   GETTING THE OTF DATA
      CALL FUNCTION v_fm
        EXPORTING
    *     ARCHIVE_INDEX        =
    *     ARCHIVE_INDEX_TAB    =
    *     ARCHIVE_PARAMETERS   =
          control_parameters   = gs_ctrlop
    *     MAIL_APPL_OBJ        =
    *     MAIL_RECIPIENT       =
    *     MAIL_SENDER          =
          output_options       = gs_outopt
          user_settings        = ' '
          wa_lfa1              = wa_lfa1
          wa_t001              = wa_t001
          wa_ekko              = wa_ekko
          wa_adrc              = wa_adrc
        IMPORTING
    *     DOCUMENT_OUTPUT_INFO =
          job_output_info      = gs_otfdata
    *     JOB_OUTPUT_OPTIONS   =
        TABLES
          it_ekpo              = it_ekpo
        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.
    *        ASSIGNING THE OTFDATA TO OTF STRUCTURE TABLE
      CLEAR gt_otf.
      gt_otf[] = gs_otfdata-otfdata[].
    *                   CONVERTING THE OTFDATA
      CLEAR gt_lines.
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
          max_linewidth         = 132
    *     ARCHIVE_INDEX         = ' '
    *     COPYNUMBER            = 0
    *     ASCII_BIDI_VIS2LOG    = ' '
    *     PDF_DELETE_OTFTAB     = ' '
    *     PDF_USERNAME          = ' '
    *     PDF_PREVIEW           = ' '
    *     USE_CASCADING         = ' '
        IMPORTING
          bin_filesize          = bin_file
    *     bin_file              = bin_file
        TABLES
          otf                   = gt_otf
          lines                 = gt_lines
        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.
      DATA l_file TYPE string  .
      CONCATENATE  'D:\usr\sap\CID\DVEBMGS00\work' '.PDF' INTO l_file.
      OPEN DATASET l_file FOR OUTPUT IN BINARY MODE  .
      IF  sy-subrc = 0 .
        LOOP AT gt_lines INTO gs_lines .
          TRANSFER gs_lines TO l_file .
        ENDLOOP.
        CLOSE DATASET l_file .
      ELSE.
        WRITE : / 'operating system could not open file' .
      ENDIF.
    *      ASSIGNING THE DESCRIPTION OF THE OBJECT SENT IN MAIL
      CLEAR gs_docdata.
      gs_docdata-obj_name = gc_tst.
      gs_docdata-obj_descr = gc_testing.
      gs_docdata-obj_langu = sy-langu.
    *        ASSIGNING THE EMAIL-ID TO STRUCTURE OF API RECIPIENT LIST TABLE
      CLEAR : gt_reclist,gs_reclist.
    ***IF INTERNAL MAIL-ID
    *  gs_reclist-receiver = sy-uname.
    *  gs_reclist-rec_type = 'B'.
    ***IF EXTERNAL MAIL-ID
      gs_reclist-receiver = '[email protected]'.
      gs_reclist-rec_type = 'U'.
      APPEND gs_reclist TO gt_reclist.
    *     PASSING THE SAP SCRIPT LINES TO SAP OFFICE
      CLEAR : gs_objbin,gs_lines.
      LOOP AT gt_lines INTO gs_lines.
        gv_pos = 255 - gv_len.
        IF gv_pos > 134.
          gv_pos = 134.
        ENDIF.
        gs_objbin+gv_len = gs_lines(gv_pos).
        gv_len = gv_len + gv_pos.
        IF gv_len = 255.
          APPEND gs_objbin TO gt_objbin.
          CLEAR : gs_objbin,gv_len.
          IF gv_pos < 134.
            gs_objbin = gs_lines+gv_pos.
            gv_len = 134 - gv_pos.
          ENDIF.
        ENDIF.
      ENDLOOP.
      IF gv_len > 0.
        APPEND gs_objbin TO gt_objbin.
      ENDIF.
    *           FILLING THE DETAILS IN SAP OFFICE
      DESCRIBE TABLE gt_objbin LINES gv_tab_lines.
      CLEAR gs_objbin.
      READ TABLE gt_objbin INTO gs_objbin INDEX gv_tab_lines.
      IF sy-subrc = 0.
        gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + strlen( gs_objbin ).
        gs_objpack-transf_bin = 'X'.
        gs_objpack-head_start = 1.
        gs_objpack-head_num = 0.
        gs_objpack-body_start = 1.
        gs_objpack-body_num = gv_tab_lines.
        gs_objpack-doc_type = 'PDF'.
        gs_objpack-obj_name = 'ATTACHMENT'.
        gs_objpack-obj_descr = 'TEST'.
        APPEND gs_objpack TO gt_objpack.
      ENDIF.
      DATA: BEGIN OF command_list OCCURS 0.
              INCLUDE STRUCTURE sxpgcolist.
      DATA: END OF command_list .
      DATA: BEGIN OF exec_protocol OCCURS 0.
              INCLUDE STRUCTURE btcxpm.
      DATA: END OF exec_protocol.
      DATA: status LIKE btcxp3-exitstat,
       commandname LIKE sxpgcolist-name VALUE 'ZB_TEST',
        sel_no LIKE sy-tabix.
    * GET LIST OF EXTERNAL COMMANDS
      CALL FUNCTION 'SXPG_COMMAND_LIST_GET'
        EXPORTING
          commandname     = commandname
          operatingsystem = sy-opsys
        TABLES
          command_list    = command_list
        EXCEPTIONS
          OTHERS          = 1.
      CALL FUNCTION 'SXPG_COMMAND_CHECK'
        EXPORTING
          commandname                = command_list-name
          operatingsystem            = sy-opsys
        EXCEPTIONS
          no_permission              = 1
          command_not_found          = 2
          parameters_too_long        = 3
          security_risk              = 4
          wrong_check_call_interface = 5
          x_error                    = 6
          too_many_parameters        = 7
          parameter_expected         = 8
          illegal_command            = 9
          communication_failure      = 10
          system_failure             = 11
          OTHERS                     = 12.
      CLEAR command_list.
      REFRESH command_list.
      DATA: v_dir_input      TYPE sxpgcolist-parameters.
      DATA: v_dir_input1      TYPE sxpgcolist-parameters.
      command_list-name = 'ZB_TEST'.
      command_list-opsystem = 'Windows NT'.
      DATA : doc  TYPE string.
      DATA : pass TYPE string ,
            name(40).
      doc = 'invoice'.
      pass = '123456'.
      CONCATENATE   'cnd/c d:\pdf\encryptpdf.exe' doc'.PDF' INTO name.
      CONCATENATE 'cmd /c d:\pdf\encryptpdf.exe' '-i'  name  '-o ' name  '-u'  pass INTO v_dir_input SEPARATED BY space .
      READ TABLE command_list INDEX sel_no.
      CONCATENATE command_list-opcommand v_dir_input INTO command_list-opcommand SEPARATED BY space.
    * CHECK AUTHORIZATION
      command_list-addpar = 'X'.
      APPEND command_list.
      CONSTANTS: c_extcom    TYPE sxpgcolist-name VALUE 'ZB_TEST',
       c_oper      TYPE syopsys VALUE 'Windows NT'.
      DATA: t_result         TYPE STANDARD TABLE OF btcxpm.
      v_dir_input  =  command_list-opcommand.
      CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
        EXPORTING
          commandname                   = c_extcom
          additional_parameters         = v_dir_input
          operatingsystem               = c_oper
        TABLES
          exec_protocol                 = t_result
        EXCEPTIONS
          no_permission                 = 1
          command_not_found             = 2
          parameters_too_long           = 3
          security_risk                 = 4
          wrong_check_call_interface    = 5
          program_start_error           = 6
          program_termination_error     = 7
          x_error                       = 8
          parameter_expected            = 9
          too_many_parameters           = 10
          illegal_command               = 11
          wrong_asynchronous_parameters = 12
          cant_enq_tbtco_entry          = 13
          jobcount_generation_error     = 14
          OTHERS                        = 15.
      OPEN DATASET l_file FOR INPUT IN BINARY MODE.
      IF sy-subrc = 0.
        READ DATASET l_file INTO itab_attach.
        CLOSE DATASET l_file.
      ENDIF.
      CALL METHOD cl_bcs_convert=>xstring_to_solix
        EXPORTING
          iv_xstring = itab_attach
        RECEIVING
          et_solix   = t_attachment.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data                    = gs_docdata
       PUT_IN_OUTBOX                    = 'X'
       COMMIT_WORK                      = 'X'
    * IMPORTING
    *   SENT_TO_ALL                      =
    *   NEW_OBJECT_ID                    =
        TABLES
          packing_list                     = gt_objpack
    *   OBJECT_HEADER                    =
       CONTENTS_BIN                     = gt_objbin
    *   CONTENTS_TXT                     =
       CONTENTS_HEX                     = t_attachment
    *   OBJECT_PARA                      =
    *   OBJECT_PARB                      =
          receivers                        = gt_reclist
    * EXCEPTIONS
    *   TOO_MANY_RECEIVERS               = 1
    *   DOCUMENT_NOT_SENT                = 2
    *   DOCUMENT_TYPE_NOT_EXIST          = 3
    *   OPERATION_NO_AUTHORIZATION       = 4
    *   PARAMETER_ERROR                  = 5
    *   X_ERROR                          = 6
    *   ENQUEUE_ERROR                    = 7
    *   OTHERS                           = 8
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
        WRITE 'SENT SUCCESSFULLY'.
      ENDIF.
      SUBMIT rsconn01 WITH mode EQ 'INT' AND RETURN.
    The mail is sent to inbox successfully,but when am opening the attachment am getting the below error as,
    ---> There was an error while opening this file.The file is damaged and couldnt be repaired.

  • Unable to print directly from vf03 txn after converting  smartform into PDF

    Dear All,
    I have converted ond smartform into pdf.now when i am trying to print one document using vf03 transaction whatever button i click(ex-print preview/print) it is asking to save the pdf as local file. but i want to print that document as pdf directly from vf03 without saving it into local file.
    I am giving you the code below:-
    (all modification done by me are in BOLD)
         Print of a invoice by SAPscript SMART FORMS               *
    REPORT zrlb_invoice5.
    declaration of data
    INCLUDE zrlb_invoice_data_declare5.
    *INCLUDE ZRLB_INVOICE_DATA_DECLARE.
    *INCLUDE rlb_invoice_data_declare.
    definition of forms
    INCLUDE zrlb_invoice_form015.
    *INCLUDE ZRLB_INVOICE_FORM01.
    *INCLUDE rlb_invoice_form01.
    INCLUDE zrlb_print_forms5.
    *INCLUDE ZRLB_PRINT_FORMS.
    *INCLUDE rlb_print_forms.
    START-OF-SELECTION.
          FORM ENTRY
    FORM entry USING return_code us_screen.
      DATA: lf_retcode TYPE sy-subrc.
      CLEAR retcode.
      xscreen = us_screen.
      PERFORM processing USING us_screen
                         CHANGING lf_retcode.
      IF lf_retcode NE 0.
        return_code = 1.
      ELSE.
        return_code = 0.
      ENDIF.
    ENDFORM.                    "ENTRY
          FORM PROCESSING                                               *
    FORM processing USING proc_screen
                    CHANGING cf_retcode.
      DATA: lv_medium LIKE tnapr-nacha.
      DATA: lwa_print_data_to_read TYPE lbbil_print_data_to_read.
      DATA: lwa_bil_invoice TYPE lbbil_invoice.
      DATA: lf_fm_name            TYPE rs38l_fnam.
      DATA: lwa_control_param      TYPE ssfctrlop.
      DATA: lwa_composer_param     TYPE ssfcompop.
      DATA: lwa_recipient          TYPE swotobjid.
      DATA: lwa_sender             TYPE swotobjid.
      DATA: lf_formname           TYPE tdsfname.
      DATA: lwa_addr_key           LIKE addr_key.
      DATA: ls_dlv-land           LIKE vbrk-land1.
      DATA:lv_job_output_info      TYPE ssfcrescl,
             lv_document_output_info TYPE ssfcrespd,
             lv_job_output_options   TYPE ssfcresop,
             lv_bin_filesize          TYPE i,
             gt_docs  TYPE STANDARD TABLE OF docs,
             gt_lines TYPE STANDARD TABLE OF tline,
             gt_otf TYPE TABLE OF itcoo, " OTF Structure
             lv_name                  TYPE string VALUE 'INVOICE',
             lv_guiobj                TYPE REF TO cl_gui_frontend_services,
             lv_path                  TYPE string  VALUE 'D:\',
             lv_fullpath              TYPE string VALUE 'D:\INVOICE',
             lv_filter                TYPE string,
             lv_uact                  TYPE i,
             lv_filename              TYPE string,
    ++lv_fm_name               TYPE rs38l_fnam.         +*****************************************
    SmartForm from customizing table TNAPR
      lf_formname = tnapr-sform.
      lv_medium = tnapr-nacha.
    determine print data
      PERFORM set_print_data_to_read USING    lf_formname
                                     CHANGING lwa_print_data_to_read
                                     cf_retcode.
      IF cf_retcode EQ 0.
    select print data
        PERFORM get_data USING    lwa_print_data_to_read
                         CHANGING lwa_addr_key
                                  ls_dlv-land
                                  lwa_bil_invoice
                                  cf_retcode.
      ENDIF.
      IF cf_retcode EQ 0.
        PERFORM set_print_param USING    lwa_addr_key
                                         ls_dlv-land
                                CHANGING lwa_control_param
                                         lwa_composer_param
                                         lwa_recipient
                                         lwa_sender
                                         cf_retcode.
      ENDIF.
      IF cf_retcode EQ 0.
    determine smartform function module for invoice
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
             EXPORTING  formname           = lf_formname
                    variant            = ' '
                    direct_call        = ' '
             IMPORTING  fm_name            = lf_fm_name
             EXCEPTIONS no_form            = 1
                        no_function_module = 2
                        OTHERS             = 3.
        IF sy-subrc NE 0.
      error handling
          cf_retcode = sy-subrc.
          PERFORM protocol_update.
        ENDIF.
      ENDIF.
      IF cf_retcode EQ 0.
        PERFORM check_repeat.
        IF lwa_composer_param-tdcopies EQ 0.
          nast_anzal = 1.
        ELSE.
          nast_anzal = lwa_composer_param-tdcopies.
        ENDIF.
        lwa_composer_param-tdcopies = 1.
        DO nast_anzal TIMES.
    In case of repetition only one time archiving
          IF sy-index GT 1 AND nast-tdarmod EQ 3.
            nast_tdarmod = nast-tdarmod.
            nast-tdarmod = 1.
            lwa_composer_param-tdarmod = 1.
          ENDIF.
          IF sy-index NE 1 AND repeat IS INITIAL.
            repeat = 'X'.
          ENDIF.
    call smartform invoice
         CALL FUNCTION lf_fm_name
              EXPORTING
                         archive_index        = toa_dara
                         archive_parameters   = arc_params
                         control_parameters   = ls_control_param
                    mail_appl_obj        =
                         mail_recipient       = ls_recipient
                         mail_sender          = ls_sender
                         output_options       = ls_composer_param
                         user_settings        = space
                         is_bil_invoice       = ls_bil_invoice
                         is_nast              = nast
                         is_repeat            = repeat
         importing  document_output_info =
                    job_output_info      =
                    job_output_options   =
              EXCEPTIONS formatting_error     = 1
                         internal_error       = 2
                         send_error           = 3
                         user_canceled        = 4
                         OTHERS               = 5.
          lwa_control_param-getotf = 'X'.
          lwa_control_param-no_dialog = 'X'.
          lwa_control_param-device = 'PRINTER'.
          CALL FUNCTION lf_fm_name
            EXPORTING
             archive_index              = toa_dara
    Begin of Changes 24/10/2007*
      ARCHIVE_INDEX_TAB          =*
            ARCHIVE_PARAMETERS         = arc_params*
             control_parameters         = lwa_control_param
      MAIL_APPL_OBJ              =*
            MAIL_RECIPIENT             = lwa_recipient*
            MAIL_SENDER                = lwa_sender*
    *End of changes 04/12/2007
             output_options             = lwa_composer_param
             user_settings              = 'X'
              is_bil_invoice             = lwa_bil_invoice
              is_nast                    = nast
              is_repeat                  = repeat
              iv_medium                  = lv_medium
    Begin OF Changes 04/12/2007*
    IMPORTING
       document_output_info       = lv_document_output_info
       job_output_info            = lv_job_output_info
       *job_output_options         = lv_job_output_options     *
    End Of Changes 04/12/2007*
    EXCEPTIONS
       formatting_error           = 1
       internal_error             = 2
       send_error                 = 3
       user_canceled              = 4
       OTHERS                     = 5.
         CALL FUNCTION lf_fm_name
           EXPORTING
            ARCHIVE_INDEX              = toa_dara
      ARCHIVE_INDEX_TAB          =
            ARCHIVE_PARAMETERS         = arc_params
            CONTROL_PARAMETERS         = lWA_control_param
      MAIL_APPL_OBJ              =
            MAIL_RECIPIENT             = lwa_recipient
            MAIL_SENDER                = lwa_sender
            OUTPUT_OPTIONS             = lwa_composer_param
            USER_SETTINGS              = space
             IS_BIL_INVOICE             = LWA_BIL_INVOICE
             IS_NAST                    = nast
             IS_REPEAT                  = repeat
             IV_MEDIUM                  = lv_medium
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
      JOB_OUTPUT_INFO            =
      JOB_OUTPUT_OPTIONS         =
    EXCEPTIONS
      FORMATTING_ERROR           = 1
      INTERNAL_ERROR             = 2
      SEND_ERROR                 = 3
      USER_CANCELED              = 4
      OTHERS                     = 5
          gt_otf[] = lv_job_output_info-otfdata[].
                  CALL FUNCTION 'CONVERT_OTF'
             EXPORTING
               FORMAT                      = 'PDF'
               MAX_LINEWIDTH               = 132
            ARCHIVE_INDEX               = ' '*
            COPYNUMBER                  = 0*
            ASCII_BIDI_VIS2LOG          = ' '*
             IMPORTING
               BIN_FILESIZE                = lv_bin_filesize
            BIN_FILE                    =*
              TABLES
                otf                         = gt_otf
                lines                       = gt_lines
          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.
    *.......................GET THE FILE NAME TO STORE.........
            CONCATENATE 'smrt' '.pdf' INTO lv_name.
          CREATE OBJECT lv_guiobj.
          CALL METHOD lv_guiobj->file_save_dialog
            EXPORTING
              default_extension = 'pdf'
              default_file_name = lv_name
              file_filter       = lv_filter
            CHANGING
              filename          = lv_name
              path              = lv_path
              fullpath          = lv_fullpath.
       user_action       = lv_uact.*
          IF lv_uact = lv_guiobj->action_cancel.
            EXIT.
          ENDIF.*
         MOVE lv_fullpath TO lv_filename.
           CALL METHOD cl_gui_frontend_services=>gui_download
             EXPORTING
              BIN_FILESIZE              =  lv_bin_filesize
               filename                  =  lv_fullpath
               FILETYPE                  = 'BIN'
       APPEND                    = SPACE
       WRITE_FIELD_SEPARATOR     = SPACE
       HEADER                    = '00'
       TRUNC_TRAILING_BLANKS     = SPACE
       WRITE_LF                  = 'X'
       COL_SELECT                = SPACE
       COL_SELECT_MASK           = SPACE
       DAT_MODE                  = SPACE
       CONFIRM_OVERWRITE         = SPACE
       NO_AUTH_CHECK             = SPACE
       CODEPAGE                  = SPACE
       IGNORE_CERR               = ABAP_TRUE
       REPLACEMENT               = '#'
       WRITE_BOM                 = SPACE
       TRUNC_TRAILING_BLANKS_EOL = 'X'
    IMPORTING
       FILELENGTH                =
             changing
               data_tab                  =   gt_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
       NOT_SUPPORTED_BY_GUI      = 22
       ERROR_NO_GUI              = 23
       others                    = 24
            IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO*
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.*
            ENDIF.
          Else.
           IF sy-subrc NE 0.*
      error handling
              cf_retcode = sy-subrc.
              PERFORM protocol_update.
    get SmartForm protocoll and store it in the NAST protocoll
              PERFORM add_smfrm_prot.
            ENDIF.
          ENDDO.
          lwa_composer_param-tdcopies = nast_anzal.
          IF NOT nast_tdarmod IS INITIAL.
            nast-tdarmod = nast_tdarmod.
            CLEAR nast_tdarmod.
          ENDIF.
        ENDIF.
    get SmartForm protocoll and store it in the NAST protocoll
    PERFORM ADD_SMFRM_PROT.
      ENDFORM.                    "PROCESSING
    kindly give me a sloution.

    Hi,
    Check for the print mode in the print options and set it as 3- print and archive .
    Regards,
    Ram

  • Convert Smartform to PDF and send to SAP Workplace user

    Hi to all.
    I need help of somebody expert in SMARTFORM's.
    I need to convert a smartform into PDF format and to send as attachement for SAP workplace
    of the user.
    I developed the next code.
    IT is to function and to send the mail for SAP workplace, but it happens that smartform
    contains images (logos) and tables, when the user tries to open the file pdf in inbox gives
    to error - "An unrecognized token ' q0 ' was found".
    I tried to call a smartform only with text and functioned well.
    Somebody can help me?
    My code:
    Begin ***********************************************
    REPORT zteste_nsa_send_pdf_sap_office.
    DATA: t_print LIKE zeps_fm04 OCCURS 0 WITH HEADER LINE,
    v_size TYPE i.
    DATA: ls_bil_invoice TYPE lbbil_invoice.
    TABLES: nast.
    DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
    i_tline TYPE TABLE OF tline WITH HEADER LINE,
    i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
    i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
    i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
    i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
    wa_objhead TYPE soli_tab,
    w_ctrlop TYPE ssfctrlop,
    w_compop TYPE ssfcompop,
    w_return TYPE ssfcrescl,
    wa_doc_chng TYPE sodocchgi1,
    w_data TYPE sodocchgi1,
    wa_buffer TYPE string,"To convert from 132 to 255
    Variables declarations
    v_form_name TYPE rs38l_fnam,
    v_len_in LIKE sood-objlen,
    v_len_out LIKE sood-objlen,
    v_len_outn TYPE i,
    v_lines_txt TYPE i,
    v_lines_bin TYPE i.
    START-OF-SELECTION.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    formname = 'ZFPS_FICHA_VALORIZACAO'
    IMPORTING
    fm_name = v_form_name
    EXCEPTIONS
    no_form = 1
    no_function_module = 2
    OTHERS = 3.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    w_ctrlop-getotf = 'X'.
    w_ctrlop-no_dialog = 'X'.
    w_compop-tdnoprev = 'X'.
    CALL FUNCTION v_form_name
    EXPORTING
    control_parameters = w_ctrlop
    output_options = w_compop
    user_settings = 'X'
    is_bil_invoice = ls_bil_invoice
    is_nast = nast
    is_repeat = 'X'
    IMPORTING
    job_output_info = w_return
    TABLES
    t_list = t_print
    EXCEPTIONS
    formatting_error = 1
    internal_error = 2
    send_error = 3
    user_canceled = 4
    OTHERS = 5.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    i_otf[] = w_return-otfdata[].
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    format = 'PDF'
    max_linewidth = 132
    bin_filesize = v_len_in
    TABLES
    otf = i_otf
    lines = i_tline
    EXCEPTIONS
    err_max_linewidth = 1
    err_format = 2
    err_conv_not_possible = 3
    OTHERS = 4.
    IF sy-subrc EQ 0.
    ENDIF.
    Convert PDF from 132 to 255.
    LOOP AT i_tline.
    TRANSLATE i_tline USING '~'.
    CONCATENATE wa_buffer i_tline INTO wa_buffer.
    ENDLOOP.
    TRANSLATE wa_buffer USING '~'.
    DO.
    i_record = wa_buffer.
    APPEND i_record.
    SHIFT wa_buffer LEFT BY 255 PLACES.
    IF wa_buffer IS INITIAL.
    EXIT.
    ENDIF.
    ENDDO.
    SEND MAIL
    REFRESH: i_reclist,
    i_objtxt,
    i_objbin,
    i_objpack.
    CLEAR wa_objhead.
    Object with PDF.
    i_objbin[] = i_record[].
    Object with main text of the mail.
    i_objtxt = 'Fichas de Valorização e Esquemas Tipo'.
    APPEND i_objtxt.
    Document information.
    wa_doc_chng-obj_name = 'SMART'.
    wa_doc_chng-expiry_dat = sy-datum + 10.
    wa_doc_chng-obj_descr = 'Ficha de Valorização'.
    wa_doc_chng-sensitivty = 'F'. "Functional object
    wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + STRLEN( i_objtxt ).
    Pack to main body as RAW.
    Obj. to be transported not in binary form
    DESCRIBE TABLE i_objtxt LINES v_lines_txt.
    READ TABLE i_objtxt INDEX v_lines_txt.
    CLEAR i_objpack-transf_bin.
    i_objpack-head_start = 1.
    i_objpack-head_num = 0.
    i_objpack-body_start = 1.
    i_objpack-body_num = v_lines_txt.
    i_objpack-doc_type = 'RAW'.
    APPEND i_objpack.
    Packing as PDF.
    Obj. to be transported in binary form
    DESCRIBE TABLE i_objbin LINES v_lines_bin.
    READ TABLE i_objbin INDEX v_lines_bin.
    i_objpack-transf_bin = 'X'.
    i_objpack-head_start = 1.
    i_objpack-head_num = 0.
    i_objpack-body_start = 1.
    i_objpack-body_num = v_lines_bin.
    i_objpack-doc_type = 'PDF'.
    i_objpack-obj_name = 'SMART'.
    CONCATENATE 'Ficha_Valorizacao' '.pdf' INTO i_objpack-obj_descr.
    i_objpack-doc_size = ( v_lines_bin - 1 ) * 255 + STRLEN( i_objbin ).
    APPEND i_objpack.
    e-mail receivers.
    CLEAR i_reclist.
    i_reclist-receiver = sy-uname.
    i_reclist-rec_type = 'B'.
    i_reclist-express = 'X'.
    APPEND i_reclist.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = wa_doc_chng
    put_in_outbox = 'X'
    commit_work = ' '
    TABLES
    packing_list = i_objpack
    object_header = wa_objhead
    contents_bin = i_objbin
    contents_txt = i_objtxt
    receivers = i_reclist
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    OTHERS = 8.
    IF sy-subrc EQ 0.
    ENDIF.
    End *************************************************
    Thanks very much to all and Happy New year...
    Nelson

    Hi
    See this report as example:
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    I believe before converting the print to pdf, you should print your document, get the spool and convert it.
    Max

  • Converting Smartform into pdf in encrypted format

    Hi All,
    I have a requirement to download smartform into pdf format. I have done this,but this pdf is editable with pdf editor tool.
    is there any way to encrypt pdf data and downloading it? I find some FM's in forum but those are used to encrypt and decrypt the passwords etc....
    Thanks in advance..
    Anji

    Hi
    SMART form to PDF
    https://wiki.sdn.sap.com/wiki/display/Snippets/ConvertSmartformtoPDFformat
    smartform to MAIL
    https://wiki.sdn.sap.com/wiki/display/Snippets/SmartformtoMailasPDF+attachment

  • Smartform to PDF and e_mail? Urgent

    hi all,
    i am able to convert smartform to pdf and download the pdf onto desktop but not able to send it as attachment thru email. 
    CALL FUNCTION 'CONVERT_OTF_2_PDF'
               EXPORTING
                    use_otf_mc_cmd         = 'X'
               IMPORTING
                    bin_filesize           = v_len_in
               TABLES
                    otf                    = i_otf[]
                    doctab_archive         = lt_doctab
                    lines                  = <b>i_tline</b>
               EXCEPTIONS
                    err_conv_not_possible  = 1
                    err_otf_mc_noendmarker = 2
                    OTHERS                 = 3.
    PERFORM doconv TABLES i_tline objbin.
    FORM doconv TABLES
    mypdf STRUCTURE tline
    outbin STRUCTURE solisti1.
    Data
    DATA : pos TYPE i.
    DATA : len TYPE i.
    Loop And Put Data
    LOOP AT mypdf.
    pos = 255 - len.
    IF pos > 134. "length of pdf_table
    pos = 134.
    ENDIF.
    outbin+len = mypdf(pos).
    len = len + pos.
    IF len = 255. "length of out (contents_bin)
    APPEND outbin.
    CLEAR: outbin, len.
    IF pos < 134.
    outbin = mypdf+pos.
    len = 134 - pos.
    ENDIF.
    ENDIF.
    ENDLOOP.
    IF len > 0.
    APPEND outbin.
    ENDIF.
    ENDFORM. "doconv
    how can i best deal with <b>i_tline</b>  and send mail using <b>i_tline</b>.
    thanks,
    Subba

    hi,
    * Internal Table declarations
    DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
          i_tline TYPE TABLE OF tline WITH HEADER LINE,
          i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
          i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    * Objects to send mail.
          i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
          i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    * Work Area declarations
          wa_objhead TYPE soli_tab,
          w_ctrlop TYPE ssfctrlop,
          w_compop TYPE ssfcompop,
          w_return TYPE ssfcrescl,
          wa_doc_chng typE sodocchgi1,
          w_data TYPE sodocchgi1,
          wa_buffer TYPE string,"To convert from 132 to 255
    * Variables declarations
          v_form_name TYPE rs38l_fnam,
          v_len_in LIKE sood-objlen,
          v_len_out LIKE sood-objlen,
          v_len_outn TYPE i,
          v_lines_txt TYPE i,
          v_lines_bin TYPE i.
    call function 'SSF_FUNCTION_MODULE_NAME'
         exporting
              formname           = 'ZZZ_TEST1'
         importing
              fm_name            = v_form_name
         exceptions
              no_form            = 1
              no_function_module = 2
              others             = 3.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    w_ctrlop-getotf = 'X'.
    w_ctrlop-no_dialog = 'X'.
    w_compop-tdnoprev = 'X'.
    CALL FUNCTION v_form_name
         EXPORTING
              control_parameters = w_ctrlop
              output_options     = w_compop
              user_settings      = 'X'
         IMPORTING
              job_output_info    = w_return
         EXCEPTIONS
              formatting_error   = 1
              internal_error     = 2
              send_error         = 3
              user_canceled      = 4
              OTHERS             = 5.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    i_otf[] = w_return-otfdata[].
    call function 'CONVERT_OTF'
           EXPORTING
                format                = 'PDF'
                max_linewidth         = 132
           IMPORTING
                bin_filesize          = v_len_in
           TABLES
                otf                   = i_otf
                lines                 = i_tline
           EXCEPTIONS
                err_max_linewidth     = 1
                err_format            = 2
                err_conv_not_possible = 3
                others                = 4.
    *   Fehlerhandling
      if sy-subrc <> 0.
      endif.
      loop at i_tline.
        translate i_tline using '~'.
        concatenate wa_buffer i_tline into wa_buffer.
      endloop.
      translate wa_buffer using '~'.
      do.
        i_record = wa_buffer.
        append i_record.
        shift wa_buffer left by 255 places.
        if wa_buffer is initial.
          exit.
        endif.
      enddo.
    * Attachment
      refresh:
        i_reclist,
        i_objtxt,
        i_objbin,
        i_objpack.
      clear wa_objhead.
      i_objbin[] = i_record[].
    ******* Create Message Body
    **** Title and Description
      i_objtxt = 'test with pdf-Attachment!'.
      append i_objtxt.
      describe table i_objtxt lines v_lines_txt.
      read table i_objtxt index v_lines_txt.
      wa_doc_chng-obj_name = 'smartform'.
      wa_doc_chng-expiry_dat = sy-datum + 10.
      wa_doc_chng-obj_descr = 'smartform'.
      wa_doc_chng-sensitivty = 'F'.
      wa_doc_chng-doc_size = v_lines_txt * 255.
    **** Main Text
    *  wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )
      clear i_objpack-transf_bin.
      i_objpack-head_start = 1.
      i_objpack-head_num = 0.
      i_objpack-body_start = 1.
      i_objpack-body_num = v_lines_txt.
      i_objpack-doc_type = 'RAW'.
      append i_objpack.
    **** Attachment
    * (pdf-Attachment)
      i_objpack-transf_bin = 'X'.
      i_objpack-head_start = 1.
      i_objpack-head_num = 0.
      i_objpack-body_start = 1.
    * Länge des Attachment ermitteln
      describe table i_objbin lines v_lines_bin.
      read table i_objbin index v_lines_bin.
      i_objpack-doc_size =  v_lines_bin * 255 .
      i_objpack-body_num = v_lines_bin.
      i_objpack-doc_type = 'PDF'.
      i_objpack-obj_name = 'smart'.
      i_objpack-obj_descr = 'test'.
      append i_objpack.
      clear i_reclist.
      i_reclist-receiver = '[email protected]'.
      i_reclist-rec_type = 'U'.
      append i_reclist.
        call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
             EXPORTING
                  document_data              = wa_doc_chng
                  put_in_outbox              = 'X'
             TABLES
                  packing_list               = i_objpack
                  object_header              = wa_objhead
                  CONTENTS_BIN               = i_objbin
                  contents_txt               = i_objtxt
                  receivers                  = i_reclist
             EXCEPTIONS
                  too_many_receivers         = 1
                  document_not_sent          = 2
                  document_type_not_exist    = 3
                  operation_no_authorization = 4
                  parameter_error            = 5
                  x_error                    = 6
                  enqueue_error              = 7
                  others                     = 8.
    rgds
    Anver

  • Convert smartforms to pdf and sending it as email

    hi,
    i am converting smart form into PDF and sending it as an attachment with the e-mail. the e-mail is getting delivered but i am unable to open the PDF. it shows error saying "unable to open as it is not a supported file type or  it has been damaged".
    can any one please help me.

    Hi Gouthaman,
    Check this code.
    *& 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.
    Hope this resolves your query.
    Reward all the helpful answers.
    Regards

  • Direct Conversion of smartform into PDF system has to take spool request ?

    does anybody know:
    Direct Conversion of smartform into PDF, system has to take spool request dynamically..
    i don't mean to use the SE38 calling PRG RSTXPDFT4 to transfer SAP sript into PDF.
    thanks
    SRIDHAR

    --strike Yes this is what I understood.
    In the structure job_output_info of your function you'll find your OTF data :
    st_ssfcrescl-otfdata --
      CALL FUNCTION smartform_fonction_name
            EXPORTING
    *     ARCHIVE_INDEX              =
    *     ARCHIVE_INDEX_TAB          =
    *     ARCHIVE_PARAMETERS         =
          control_parameters         = st_ssfctrlop
    *     MAIL_APPL_OBJ              =
    *     MAIL_RECIPIENT             =
    *     MAIL_SENDER                =
          output_options             = st_ssfcompop
          user_settings              = ' '
        IMPORTING
         document_output_info        = st_ssfcrespd
         job_output_info             = st_ssfcrescl " This is the one which contains OTF data
         job_output_options          = st_ssfcresop
        TABLES
       EXCEPTIONS
         formatting_error           = 1
         internal_error             = 2
         send_error                 = 3
         user_canceled              = 4
         OTHERS                     = 5.
    -- Then you just have to convert, using something like that : --
    * Convert OTF to PDF
      LOOP AT otf_data INTO w_otf.
        CONCATENATE w_otf-tdprintcom w_otf-tdprintpar
        INTO w_pdf.
        APPEND w_pdf TO i_content_txt.
      ENDLOOP.
      CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
        EXPORTING
          format_src      = 'OTF'
          format_dst      = 'PDF'
        CHANGING
          transfer_bin    = w_transfer_bin
          content_txt     = i_content_txt
          content_bin     = i_content_bin
          objhead         = i_objhead
          len             = v_len_in
        EXCEPTIONS
          err_conv_failed = 1
          OTHERS          = 2.
      v_size = v_len_in.
      pdf_itab_size = v_size.
      it_pdfout[] = it_pdf[].
    * Create the PDF File
      CLEAR it_pdfdata.
      REFRESH it_pdfdata.
    *  it_pdfdata[] = it_pdfout[].
      LOOP AT it_pdfout.
        MOVE it_pdfout-tline TO it_pdfdata-line.
        APPEND it_pdfdata.
        CLEAR it_pdfdata.
      ENDLOOP.
    -- The smartform creation and the PDF creation are done in the same time...--
    OK, So what do'nt you want to use the RSTXPDFT4 program ?
    Hope this helps,
    Erwan
    Edited by: Erwan LE BRUN on Aug 28, 2008 12:02 PM
    Edited by: Erwan LE BRUN on Aug 28, 2008 12:03 PM

  • Want to create a function module  which will convert smartform into PDF .

    Hi All ,
    Requirement : I want to create a function module/report  which will convert smartform into PDF .
    Thanks in advance

    Hi All ,
    zsuresh_test : for converting smartform into pdf.
    when I am excuting this report(zsuresh_test) and by passing the smartform name FOPCR_STANDARD_F1
    I am getting error :
    Incorrect parameter with CALL FUNCTION
    Can you  please help me out..
    REPORT zsuresh_test.
    Variable declarations
    DATA:
    w_form_name TYPE tdsfname VALUE 'FOPCR_STANDARD_F1',
    w_fmodule TYPE rs38l_fnam,
    w_cparam TYPE ssfctrlop,
    w_outoptions TYPE ssfcompop,
    W_bin_filesize TYPE i, " Binary File Size
    w_FILE_NAME type string,
    w_File_path type string,
    w_FULL_PATH type string.
    Internal tables declaration
    Internal table to hold the OTF data
    DATA:
    t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
    Internal table to hold OTF data recd from the SMARTFORM
    t_otf_from_fm TYPE ssfcrescl,
    Internal table to hold the data from the FM CONVERT_OTF
    T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
    This function module call is used to retrieve the name of the Function
    module generated when the SMARTFORM is activated
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    formname = w_form_name
    VARIANT = ' '
    DIRECT_CALL = ' '
    IMPORTING
    fm_name = w_fmodule
    EXCEPTIONS
    no_form = 1
    no_function_module = 2
    OTHERS = 3
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Calling the SMARTFORM using the function module retrieved above
    GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF
    format of the output
    w_cparam-no_dialog = 'X'.
    w_cparam-preview = space. " Suppressing the dialog box
    " for print preview
    w_cparam-getotf = 'X'.
    Printer name to be used is provided in the export parameter
    OUTPUT_OPTIONS
    w_outoptions-tddest = 'LP01'.
    CALL FUNCTION w_fmodule
    EXPORTING
    ARCHIVE_INDEX =
    ARCHIVE_INDEX_TAB =
    ARCHIVE_PARAMETERS =
    control_parameters = w_cparam
    MAIL_APPL_OBJ =
    MAIL_RECIPIENT =
    MAIL_SENDER =
    output_options = w_outoptions
    USER_SETTINGS = 'X'
    IMPORTING
    DOCUMENT_OUTPUT_INFO =
    job_output_info = t_otf_from_fm
    JOB_OUTPUT_OPTIONS =
    EXCEPTIONS
    formatting_error = 1
    internal_error = 2
    send_error = 3
    user_canceled = 4
    OTHERS = 5
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    t_otf[] = t_otf_from_fm-otfdata[].
    Function Module CONVERT_OTF is used to convert the OTF format to PDF
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    FORMAT = 'PDF'
    MAX_LINEWIDTH = 132
    ARCHIVE_INDEX = ' '
    COPYNUMBER = 0
    ASCII_BIDI_VIS2LOG = ' '
    PDF_DELETE_OTFTAB = ' '
    IMPORTING
    BIN_FILESIZE = W_bin_filesize
    BIN_FILE =
    TABLES
    otf = T_OTF
    lines = T_pdf_tab
    EXCEPTIONS
    ERR_MAX_LINEWIDTH = 1
    ERR_FORMAT = 2
    ERR_CONV_NOT_POSSIBLE = 3
    ERR_BAD_OTF = 4
    OTHERS = 5
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    To display File SAVE dialog window
    CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
    WINDOW_TITLE =
    DEFAULT_EXTENSION =
    DEFAULT_FILE_NAME =
    FILE_FILTER =
    INITIAL_DIRECTORY =
    WITH_ENCODING =
    PROMPT_ON_OVERWRITE = 'X'
    CHANGING
    filename = w_FILE_NAME
    path = w_FILE_PATH
    fullpath = w_FULL_PATH
    USER_ACTION =
    FILE_ENCODING =
    EXCEPTIONS
    CNTL_ERROR = 1
    ERROR_NO_GUI = 2
    NOT_SUPPORTED_BY_GUI = 3
    others = 4
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
    presentation server
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE = W_bin_filesize
    filename = w_FULL_PATH
    FILETYPE = 'BIN'
    APPEND = ' '
    WRITE_FIELD_SEPARATOR = ' '
    HEADER = '00'
    TRUNC_TRAILING_BLANKS = ' '
    WRITE_LF = 'X'
    COL_SELECT = ' '
    COL_SELECT_MASK = ' '
    DAT_MODE = ' '
    CONFIRM_OVERWRITE = ' '
    NO_AUTH_CHECK = ' '
    CODEPAGE = ' '
    IGNORE_CERR = ABAP_TRUE
    REPLACEMENT = '#'
    WRITE_BOM = ' '
    TRUNC_TRAILING_BLANKS_EOL = 'X'
    WK1_N_FORMAT = ' '
    WK1_N_SIZE = ' '
    WK1_T_FORMAT = ' '
    WK1_T_SIZE = ' '
    IMPORTING
    FILELENGTH =
    tables
    data_tab = T_pdf_tab
    FIELDNAMES =
    EXCEPTIONS
    FILE_WRITE_ERROR = 1
    NO_BATCH = 2
    GUI_REFUSE_FILETRANSFER = 3
    INVALID_TYPE = 4
    NO_AUTHORITY = 5
    UNKNOWN_ERROR = 6
    HEADER_NOT_ALLOWED = 7
    SEPARATOR_NOT_ALLOWED = 8
    FILESIZE_NOT_ALLOWED = 9
    HEADER_TOO_LONG = 10
    DP_ERROR_CREATE = 11
    DP_ERROR_SEND = 12
    DP_ERROR_WRITE = 13
    UNKNOWN_DP_ERROR = 14
    ACCESS_DENIED = 15
    DP_OUT_OF_MEMORY = 16
    DISK_FULL = 17
    DP_TIMEOUT = 18
    FILE_NOT_FOUND = 19
    DATAPROVIDER_EXCEPTION = 20
    CONTROL_FLUSH_ERROR = 21
    OTHERS = 22
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  • Convert a web report into pdf and print (in BW 3.5)

    Hello gurus,
    i have few web reports ( created using WAD). i am looking for a possibility to convert a web report (viewed in a browser by a user) into pdf and print them and this should be done by pressing a button.
    Is it possible in BW 3.5 version?.
    could anyone please help me?
    Any how to docs. would be really helpful.
    thanks and regards
    kumar

    Here it is
    <HTML>
    <!-- BW data source object tags -->
    <object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="SET_DATA_PROVIDER"/>
             <param name="NAME" value="DATAPROVIDER_1"/>
             <param name="DATA_PROVIDER_ID" value=""/>
             DATA_PROVIDER:             DATAPROVIDER_1
    </object>
    <object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="SET_PROPERTIES"/>
             <param name="TEMPLATE_ID" value="ZPD_ADHOC_PAGE"/>
             <param name="MENU_BACK" value=""/>
             <param name="MENU_BACK_TO_START" value=""/>
             <param name="SUPPRESS_WARNINGS" value="X"/>
             <param name="MENU_FILTER" value=""/>
             <param name="MENU_FILTER_ON_AXIS" value=""/>
             <param name="MENU_SELECT_FILTER" value=""/>
             <param name="MENU_FILTER_ON_AXIS_CHART" value=""/>
             <param name="MENU_FILTER_CHART" value=""/>
             <param name="MENU_FILTER_DRILL_DOWN" value=""/>
             <param name="MENU_DRILL_UP_GIS" value=""/>
             <param name="MENU_DRILL_DOWN" value=""/>
             <param name="MENU_EXCHANGE_OBJECTS" value=""/>
             <param name="MENU_REMOVE_DRILL_DOWN" value=""/>
             <param name="MENU_SWITCH_AXIS" value=""/>
             <param name="MENU_HIERARCHY_NODE_DRILL" value=""/>
             <param name="MENU_HIERARCHY_DRILL" value=""/>
             <param name="MENU_HIERARCHY_STATE" value=""/>
             <param name="MENU_SORT" value=""/>
             <param name="MENU_CALCULATE_RESULT" value=""/>
             <param name="MENU_CALCULATE_VALUE" value=""/>
             <param name="MENU_CUMULATE_VALUE" value=""/>
             <param name="MENU_DISPLAY_DOCUMENTS" value=""/>
             <param name="MENU_DOCUMENT_CREATE" value=""/>
             <param name="MENU_DISPLAY_DOCUMENT_PROP" value=""/>
             <param name="MENU_DISPLAY_DOCUMENT_SELEC" value=""/>
             <param name="MENU_RRI" value=""/>
             <param name="MENU_EXPORT_TO_CSV" value=""/>
             <param name="MENU_EXPORT_TO_XLS" value=""/>
             <param name="MENU_BOOKMARK" value=""/>
             <param name="MENU_CHARACTERISTIC_PROPERTIES" value=""/>
             <param name="MENU_VALUE_PROPERTIES" value=""/>
             <param name="MENU_QUERY_PROPERTIES" value=""/>
             <param name="MENU_VARIABLE_SCREEN" value=""/>
             <param name="MENU_CURRENCY_CONVERSION" value=""/>
             <param name="MENU_ENHANCED" value=""/>
             TEMPLATE PROPERTIES
    </object>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft DHTML Editing Control">
    <TITLE>SAP BW Reporting Print Page</TITLE>
    <link href="/sap/bw/Mime/BEx/StyleSheets/BWReports.css" type="text/css" rel="stylesheet"/>
    <script type"text/javascript">
    <!--
    //   Global Variable Definition
    var dataTable = "";
    var pageRowCnt = 0;
    var prevPage = 0;
    var ColumnCnt = 0;
    var PrintDateTimeStamp = new Date();
    var rptWidth = 0;
    //DATE STAMP FUNCTION
    function datestamp(){
               var Today = new Date()
               document.write(Today);
    function getReportTitle() {
                    var myQueryString = window.location.search;
                    var startOfRptTitle = myQueryString.indexOf("QTITLE=");
                    if (startOfRptTitle != -1)
                         var endOfRptTitle = myQueryString.indexOf("&", startOfRptTitle + 7);
                         var myTitle = unescape(myQueryString.substring(startOfRptTitle + 7, endOfRptTitle));
                         var rpttitle = "";
                         for(i=0;i<myTitle.length;i++){
                             if (myTitle.substring(i,i+1) == "+"){
                                 rpttitle = rpttitle + ' ';
                             else
                                 rpttitle = rpttitle + (myTitle.substring(i,i+1));
                    else
                         var rpttitle =  "Unspecified Query Title";
                    return rpttitle;
    queryTitle=getReportTitle();
    function getHeading2() {
                    var myQueryString = window.location.search;
                    var startOfHdr2 = myQueryString.indexOf("HDR2=");
                    if (startOfHdr2 != -1)
                         var endOfHdr2 = myQueryString.indexOf("&", startOfHdr2 + 5);
                         var myHdr2 = unescape(myQueryString.substring(startOfHdr2 + 5, endOfHdr2));
                         var hdr2 = "";
                         for(i=0;i<myHdr2.length;i++){
                             if (myHdr2.substring(i,i+1) == "+"){
                                 hdr2 = hdr2 + ' ';
                             else
                                 hdr2 = hdr2 + (myHdr2.substring(i,i+1));
                    else
                         var hdr2 =  "#";
                    return hdr2;
    header2=getHeading2();
    function getHeading3() {
                    var myQueryString = window.location.search;
                    var startOfHdr3 = myQueryString.indexOf("HDR3=");
                    if (startOfHdr3 != -1)
                         var endOfHdr3 = myQueryString.indexOf("&", startOfHdr3 + 5);
                         var myHdr3 = unescape(myQueryString.substring(startOfHdr3 + 5, endOfHdr3));
                         var hdr3 = "";
                         for(i=0;i<myHdr3.length;i++){
                             if (myHdr3.substring(i,i+1) == "+"){
                                 hdr3 = hdr3 + ' ';
                             else
                                 hdr3 = hdr3 + (myHdr3.substring(i,i+1));
                    else
                         var hdr3 =  "#";
                    return hdr3;
    header3=getHeading3();
    function getAsOfDate() {
                    var myQueryString = window.location.search;
                    var startOfRelevance = myQueryString.indexOf("ASOFDATE=");
                    if (startOfRelevance != -1)
                         var endOfRelevance = myQueryString.indexOf("&", startOfRelevance + 9);
                         var myRelevance = unescape(myQueryString.substring(startOfRelevance + 9, endOfRelevance));
                         var asof = "";
                         for(i=0;i<myRelevance.length;i++){
                             if (myRelevance.substring(i,i+1) == "+"){
                                 asof = asof + ' ';
                             else
                                 asof = asof + (myRelevance.substring(i,i+1));
                    else
                         var asof =  "";
                    return asof;
    asofDateTime=getAsOfDate();
    function getPaperSize() {
                    var myQueryString = window.location.search;
                    var startOfPaperSize = myQueryString.indexOf("PSIZE=");
                    if (startOfPaperSize != -1)
                         var endOfPaperSize = myQueryString.indexOf("&", startOfPaperSize + 6);
                         var myPaperSize = unescape(myQueryString.substring(startOfPaperSize + 6, endOfPaperSize));
                         var psize = "";
                         for(i=0;i<myPaperSize.length;i++){
                                 psize = psize + (myPaperSize.substring(i,i+1));
                    else
                         var psize =  "0";    // default if none supplied  (normal 8x11)
                    return psize;
    varPaperSize=getPaperSize();
    var PaperSizeParamString='&PSIZE=' + escape(varPaperSize);
       switch(varPaperSize){
            case "0":    // Landscape - Letter
                           var WidthMax = 910;
                           var RowsPerPageMax = 38;
                           break;
            case "1":    // Landscape - Legal
                           var WidthMax = 1190;
                           var RowsPerPageMax = 38;
                           break;
            case "2":    // Portrait - Letter
                           var WidthMax = 660;
                           var RowsPerPageMax = 54;
                           break;
    function getTotalColumns() {
       var myHTML = dataTable.rows[1].innerHTML;
       var TotalTDs = 0;
       var nextTD = 0;
       for (i=0;i<myHTML.length;i++) {
           nextTD =  myHTML.indexOf("<TD", i);
           if (nextTD != -1) {
              i=nextTD;
              TotalTDs++;
           else break;
       return TotalTDs;
    function GetPageHeadings() {
       var headingHTM = "";
       var leftspancnt = 0;
       var rightspancnt = 0;
       var headingspancnt = 2;
       if (header2 != '#') headingspancnt = headingspancnt + 1;   // adjust for extra headings
       if (header3 != '#') headingspancnt = headingspancnt + 1;  
       if (currPage > 1) {
          headingHTM += '<TR style="page-break-before:always; display:none; visibility:hidden; "><TD Colspan="' + ColumnCnt + '"></td></tr>';
       else {
          headingHTM += '<TABLE  id="THEREPORT" name="MYREPORT" cellSpacing=0 cellPadding=0 width=' + WidthMax + ' border=0>';
       if (ColumnCnt == 1) {
          headingHTM += '<TR><TD vAlign=top align=left nowrap><font Size=3><STRONG>';
          headingHTM += queryTitle;
          headingHTM += '</STRONG></font></TD><TD Rowspan="' + headingspancnt + '" align="right" vAlign="top"><input type="image" border="0" name="SAPLogo" src="/sap/bw/Mime/Customer/Images/images.jpg" alt="SAP Logo"></TD></TR>';
          if (header2 != '#') headingHTM += '<TR><TD vAlign="top" align="left"><FONT Size=1>' + header2 + '</FONT></TD></TR>';
          if (header3 != '#') headingHTM += '<TR><TD vAlign="top" align="left"><FONT Size=1>' + header3 + '</FONT></TD></TR>';
          headingHTM += '<TR><TD vAlign="top" align="left"><FONT Size=1>' + asofDateTime + '</FONT></TD></TR>';
          headingHTM += '<TR><TD vAlign="top" align="left" Colspan="2"><hr size=2 color=black align=left></TD></TR>';
          headingHTM += '<tr>' + dataTable.rows[0].innerHTML + '<TD> </TD></TR>';
       else {
          leftspancnt = Math.floor(ColumnCnt/2);
          rightspancnt = ColumnCnt - leftspancnt;
          headingHTM += '<TR><TD vAlign=top align=left nowrap Colspan="' + leftspancnt + '"><font Size=3><STRONG>';
          headingHTM += queryTitle;
          headingHTM += '</STRONG></font></TD><TD Rowspan="' + headingspancnt + '" Colspan="' + rightspancnt  + '" align="right" vAlign="top"><input type="image" border="0" name="SAPLogo" src="/sap/bw/Mime/Customer/Images/images.jpg" alt="SAP Logo"></TD></TR>';
          if (header2 != '#') headingHTM += '<TR><TD vAlign="top" align="left" Colspan="' + leftspancnt + '"><FONT Size=1>' + header2 + '</FONT></TD></TR>';
          if (header3 != '#') headingHTM += '<TR><TD vAlign="top" align="left" Colspan="' + leftspancnt + '"><FONT Size=1>' + header3 + '</FONT></TD></TR>';
          headingHTM += '<TR><TD vAlign="top" align="left" Colspan="' + leftspancnt + '"><FONT Size=1>' + asofDateTime + '</FONT></TD></TR>';
          headingHTM += '<TR><TD vAlign="top" align="left" Colspan="' + ColumnCnt + '"><hr size=2 color=black align=left></TD></TR>';
          headingHTM += '<tr>' + dataTable.rows[0].innerHTML + '</TR>';
       return headingHTM;
    function GetPageFooting() {
       var footingHTM = "";
       var leftspancnt = 0;
       var rightspancnt = 0;
       if (ColumnCnt == 1) {
          footingHTM += '<TR><TD vAlign="top" align="left" Colspan="2"><hr size=2 color=black align=left></TD></TR>';
          footingHTM += '<TR><TD vAlign="top" align="left" nowrap><FONT Size=1>Prepared: ';
          footingHTM += PrintDateTimeStamp;
          footingHTM += '</FONT></TD><TD vAlign="top" align="right"><FONT Size=1>';
          footingHTM = footingHTM + 'Page ' + currPage.toString() + ' of ' + varPageTotal.toString();
          footingHTM += '</FONT></TD></TR>';
       else {
          leftspancnt = Math.floor(ColumnCnt/2);
          rightspancnt = ColumnCnt - leftspancnt;
          footingHTM += '<TR><TD vAlign="top" align="left" Colspan="' + ColumnCnt + '"><hr size=2 color=black align=left></TD></TR>';
          footingHTM += '<TR><TD vAlign="top" align="left" nowrap Colspan="' + leftspancnt + '"><FONT Size=1>Prepared: ';
          footingHTM += PrintDateTimeStamp;
          footingHTM += '</FONT></TD><TD vAlign="top" align="right" Colspan="' + rightspancnt + '"><FONT Size=1>';
          footingHTM = footingHTM + 'Page ' + currPage.toString() + ' of ' + varPageTotal.toString();
          footingHTM += '</FONT></TD></TR>';
       return footingHTM;
    function GetReportFooting() {
       var footingHTM = "";
       footingHTM += '</TABLE>';
       return footingHTM;
    function formatToPrint() {
       var PrintHTM = "";
       PrintHTM += GetPageHeadings();
       if (ColumnCnt != 1) {
          for (var i=1;i<dataTable.rows.length;i++) {
               (currPage > prevPage)?prevPage=currPage:"";  //increment current page count
               if ((pageRowCnt + 1)>RowsPerPageMax){
                   PrintHTM += GetPageFooting();
                   pageRowCnt = 0;
                   currPage++;
               if (prevPage != currPage) {
                   PrintHTM += GetPageHeadings();
               else
                   PrintHTM += '<tr>' + dataTable.rows<i>.innerHTML + '</tr>';
                   pageRowCnt++;
       PrintHTM += GetPageFooting();       
       PrintHTM += GetReportFooting();
       return PrintHTM;
    function DisplayPrintNotice() {
    // Paper Size "0" is Letter with Landscape
    // Paper Size "1" is Legal with Landscape
    // Paper Size "2" is Letter with Portrait
    if (varPaperSize == "0") {var varMessage ="nn From your browser File Menu, select Page Setup and do the following: nn 1) Adjust the Printer Orientation to Landscape n 2) select Print menu, then select the Print button.";}
    if (varPaperSize == "1") {var varMessage ="nn From your browser File Menu, select Page Setup and do the following: nn 1) Adjust the Paper Size to Legal n 2) Adjust the Printer Orientation to Landscape n 3) select Print menu, then select the Print button.";}
    //if (varPaperSize == "2") {var varMessage ="nn From your browser File Menu, select Page Setup and do the following: nn 1) Adjust the Paper Size to Letter n 2) Adjust the Paper Source (if necessary) n 3) Adjust the Orientation to Portrait (default) n 4) Select the Okay button nn Again select the File Menu, select Print, then select the Print button.";}
    alert(varMessage);
    //window.print()
    /*   SAP BW Reporting Stylesheet Revisions        */        
    function writeStyleRevisions() {
    function writeDynamicFontRevisions(dynafont) {
    //Writes the Dynamic Stylesheet
    -->
    </script>
    </HEAD>
    <BODY>
    <TABLE  id="tp1" cellSpacing=0 cellPadding=0 width=660 border=0 >
        <TR>
        <TD vAlign=top align=left nowrap>
    <object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="GET_ITEM"/>
             <param name="NAME" value="MYQUERY"/>
             <param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_GRID"/>
             <param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>
             <param name="GENERATE_CAPTION" value=""/>
             <param name="GENERATE_LINKS" value=""/>
             <param name="WIDTH" value="660"/>
             <param name="BORDER_STYLE" value="NO_BORDER"/>
             <param name="SUPPRESS_REPETITION_TEXTS" value=""/>
             <param name="BLOCK_SIZE" value="3500"/>
             <param name="SHOW_PAGING_AREA_TOP" value="X"/>
             <param name="TARGET_DATA_PROVIDER_1" value="DATAPROVIDER_1"/>
             ITEM:            MYQUERY
    </object>
        </TD>
      </TR>
    </TABLE>
    <SCRIPT type="text/javascript">
    <!--
            var tbls = document.body.getElementsByTagName("TABLE");
            for (var i=0;i<tbls.length;i++) {
                  if (tbls<i>.name == "MYQUERY"){
                        var dataTable = tbls<i>;
                        break;
            document.title = queryTitle;
            rptWidth = dataTable.clientWidth;
            rptHeight = dataTable.clientHeight;
            originalRptWidth = rptWidth;
            originalRptHeight = rptHeight;
            originalRowHeight = Math.floor(rptHeight/(dataTable.rows.length+1));
            rptPageHeightMax = 580;                                                                                //660 less basic header and footer of 80
            if (header2 != '#') rptPageHeightMax = rptPageHeightMax - 20;   // adjust for extra headings
            if (header3 != '#') rptPageHeightMax = rptPageHeightMax - 20;  
            if (dataTable.rows.length == 1) {
                ColumnCnt = 1;                //No Applicable Data found message
            else {
                ColumnCnt = getTotalColumns();
            startingFont = 65;
            varFontSize = startingFont;
            if (rptWidth > WidthMax) {
                while ((rptWidth > WidthMax) && (varFontSize > 15))
                    writeDynamicFontRevisions(varFontSize);
                    rptWidth = dataTable.clientWidth;
                    rptHeight = dataTable.clientHeight;
                    varFontSize = varFontSize - 5;
                // calculate max rows per page
                rowHeight = Math.floor(rptHeight/(dataTable.rows.length+1)) + 1;        // add 1 for 2 row heading, add 1 for padding
                RowsPerPageMax = Math.floor(rptPageHeightMax/rowHeight) - 2;   // adjust for column headings
            if (dataTable.rows.length == 1) {
                varPageTotal = 1;                //No Applicable Data found message
            else {
                totalRows = dataTable.rows.length-1;                                       // total rows less headings
                varPageTotal = Math.floor(totalRows/RowsPerPageMax);       // compute total pages
                if (totalRows != (varPageTotal * RowsPerPageMax)) {
                    varPageTotal = varPageTotal + 1;                                        // if not a complete last page, add 1 for partial page
            currPage = 1;
            document.write(formatToPrint());
            document.all.tp1.style.display = "none";
            document.all.tp1.style.visibility = "hidden";
    //        DisplayPrintNotice();
    -->
    </SCRIPT>
    <STYLE>
    input.ie55   { display: none }
    </STYLE>
    <!-- special style sheet for printing -->
    <STYLE media=print>
    .noprint     { display: none }
    </STYLE>
    <script defer>
    function window.onload() {
        if (!factory.object) {
            return
        else {
    //     factory.printing.header = "SAP"
    //     factory.printing.footer = "SAP"
            if ( varPaperSize == "2" ) { factory.printing.portrait = true; }
            else { factory.printing.portrait = false; }
            factory.printing.Print(true);
            // enable control buttons
      /*  var templateSupported = factory.printing.IsTemplateSupported();
           var controls = idControls.all.tags("input");
           for ( i = 0; i < controls.length; i++ ) {
               controls<i>.disabled = false;
               if ( templateSupported && controls<i>.className == "ie55" )
                  controls<i>.style.display = "inline";
    </script>
    <P>
    <div id=idControls class="noprint" style="VISIBILITY: hidden">
    <input disabled type="button" value="Print this page"
    onclick="factory.printing.Print(true)">
    <input disabled type="button" value="Page Setup..."
    onclick="factory.printing.PageSetup()">
    <input class=ie55 disabled type="button" value="Print Preview..."
    onclick="factory.printing.Preview()">
    <input class=ie55 disabled type="button" value="Landscape"
    onclick="factory.printing.portrait=false">
    <input class=ie55 disabled type="button" value="Portrait"
    onclick="factory.printing.portrait=true">
    </div>
    </BODY>
    </HTML>

  • I switched phones with my wife.  I went into "Settings" and "Store" to change the applid to mine but the phone still has my wife's applid when updating apps.  How do I get my phone to default to my applid?

    I SWITCHED PHONES WITH MY WIFE.   I WENT INTO SETTINGS AND STORE TO CHANGE THE APPLID BUT IT STILL USES MY WIFE'S APPLID WHEN UPDATING APPS.   HOW DO I GET THE APP STORE TO DEFAULT TO MY APPLID?

    Any apps that are on the iPhone which were bought / downloaded via your wife's account are tied to her account - so only her account can download updates to those apps. If you remove all her apps and just put yours on then you should be ok.

  • Convert xml file into .pdf and .html

    hi all,
    can any one let me know how can i show xml file values into pdf and html by using java
    thanks in advance

    sreeks27 wrote:
    hi all,
    can any one let me know how can i show xml file values into pdf and html by using java
    thanks in advanceTake a look at Apache FOP:
    http://xmlgraphics.apache.org/fop/

  • Export wiki pages into PDF AND/OR word document

    We are working on an Enterprise Wiki Site collection inside SharePoint 2013. and we need to be able to export existing wiki pages  into pdf and/or MS word ? so is this possible out-of-the-box to achieve using SharePoint ? if the answer is No , then
    are there any 3rd party tools that can achieve this ?
    Thanks

    Hi,
    Here is a blog from MSDN for your reference:
    Export SharePoint Wiki to Word/PDF without 3rd party tools
    http://blogs.msdn.com/b/thomsven/archive/2011/09/09/export-sharepoint-wiki-to-word-pdf-without-3rd-party-tools.aspx
    Or use 3rd party solutions, such as the
    Wiki Publisher from Bamboo solutions.
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected].
    thanks for the reply, i tried installing the Wiki Publisher from Bamboo , but i got the following error during installtion :-
    ***** Bamboo Core V2 (Prerequisite Component) *****
    ***** ERROR *****
    Timeout error
    CodePlex.SharePointInstaller.InstallException: Timeout error ---> CodePlex.SharePointInstaller.InstallException: Timeout error
    at CodePlex.SharePointInstaller.InstallProcessControl.WaitForJobCompletionCommand.Execute()
    --- End of inner exception stack trace ---
    at CodePlex.SharePointInstaller.InstallProcessControl.WaitForJobCompletionCommand.Execute()
    at CodePlex.SharePointInstaller.InstallProcessControl.TimerEventInstall(Object myObject, EventArgs myEventArgs)
    [17/04/2015 02:12:18] The Solution was not removed. Make sure all jobs against the solution are executed.
    ***** Bamboo SharePoint Wiki Publisher *****
    ***** ERROR *****
    Timeout error
    CodePlex.SharePointInstaller.InstallException: Timeout error ---> CodePlex.SharePointInstaller.InstallException: Timeout error
    at CodePlex.SharePointInstaller.InstallProcessControl.WaitForJobCompletionCommand.Execute()
    --- End of inner exception stack trace ---
    at CodePlex.SharePointInstaller.InstallProcessControl.WaitForJobCompletionCommand.Execute()
    at CodePlex.SharePointInstaller.InstallProcessControl.TimerEventInstall(Object myObject, EventArgs myEventArgs)
    [17/04/2015 02:27:38] The Solution was not removed. Make sure all jobs against the solution are executed
    not sure what could be casing this ?

Maybe you are looking for

  • Problem with movie in IE

    Im really lost now... I use Firefox as a browser and the flash code works fine, in preview mode inside flash and also in firefox. Its a menu on my homepage. But when I start it up with internet explorer something very very very annoying happens. The

  • How to restrict change to plant specific data in MM01 and MM02 transaction.

    Hi Experts, The requirements is to restrict the plant specific data change in one system. As of now we have 2 different system lets say sys-1 and sys-2. our requirement is if at all any of the users are trying to change/create the material in Sys-1 t

  • How do you get the keyboard to appear if it doesn't do so automatically?

    When I am using the iPad, the keyboard automatically appears when I put my finger on a text box. However, after the latest iOS upgrade, this stops working occasionally, and I don't know how to get the keyboard back. Then, when I attempt to put text i

  • Add image resource to the ".r" file

    Hi, I'd like to embed small (16x16 pix) image resources (ex. png, jpeg) into the ".r" file. How can I do this?

  • Cisco Professional Configuration Issue with SG 500 52P

    I have a new SG500-52P switch installed for a small business and am upgrading to a Cisco 2910 router this weekend. I am trying to view the new switch on CCPE but it keeps saying that the device is undiscoverable. I have HTTP and HTTPS enabled on the