Converting Smartforms to PDF and displaying Smartforms on print preview

Hi,
How to convert smartforms to pdf?
How to attach this pdf to email?
How to attach this pdf to the email and at the same time can print preview the smartforms?
Thanks.

Hi Navi,
Code Snippet for Simple Mail
*& Report  ZZ_TEST                                                     *
REPORT  zz_test                                 .
INCLUDE zz_test_top.
INCLUDE zz_test01.
      FORM entry                                                    *
-->  RETURN_CODE                                                   *
-->  US_SCREEN                                                     *
FORM entry USING return_code us_screen.
  CLEAR retcode.
  xscreen = us_screen.
  PERFORM processing USING us_screen.
  CASE retcode.
    WHEN 0.
      return_code = 0.
    WHEN 3.
      return_code = 3.
    WHEN OTHERS.
      return_code = 1.
  ENDCASE.
ENDFORM.                    "entry
*&  Include           ZZ_TEST_TOP                                      *
  TABLES : nast,
           tnapr.
TYPES : BEGIN OF t_SOUDNAMEI1.
        INCLUDE STRUCTURE SOUDNAMEI1.
TYPES : END OF t_SOUDNAMEI1.
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,
  i_lips LIKE lips OCCURS 0 WITH HEADER LINE,
  i_SOUDNAMEI1 TYPE STANDARD TABLE OF t_SOUDNAMEI1.
Work Area declarations
  DATA:w_objhead TYPE soli_tab,
  wa_control_parameters TYPE ssfctrlop,
  wa_output_options TYPE ssfcompop,
  w_return TYPE ssfcrescl,
  w_doc_chng TYPE sodocchgi1,
  w_data TYPE sodocchgi1,
  w_buffer TYPE string,"To convert from 132 to 255
  wa_SOUDNAMEI1 TYPE t_SOUDNAMEI1,
Variables declarations
  w_form_name TYPE rs38l_fnam,
  w_len_in LIKE sood-objlen,
  w_len_out LIKE sood-objlen,
  w_len_outn TYPE i,
  w_lines_txt TYPE i,
  w_lines_bin TYPE i,
  retcode      TYPE sy-subrc,
  xscreen      TYPE c,
  w_spld TYPE usr01-spld,
  w_receiver TYPE SOXNA-FULLNAME,
  w_OBJ_RECORD TYPE OBJ_RECORD,
  w_user type sy-uname,
  w_email TYPE ad_smtpadr.
Constants Declaration
  CONSTANTS : c_x TYPE c VALUE 'X',
              c_atrate(1) TYPE c VALUE '@'.
*&  Include           ZZ_TEST01                                        *
      FORM PROCESSING                                               *
FORM processing USING proc_screen.
  SELECT * FROM lips
    INTO TABLE i_lips
    WHERE vbeln = nast-objky.
Call Function module to Getfunction Module name Generated by Smartform
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname           = tnapr-sform
    IMPORTING
      fm_name            = w_form_name
    EXCEPTIONS
      no_form            = 1
      no_function_module = 2
      OTHERS             = 3.
  IF sy-subrc <> 0.
    retcode = sy-subrc.
  ENDIF.
  CLEAR : wa_control_parameters,
          wa_output_options.
  CASE nast-nacha.
    WHEN '1'.
      wa_control_parameters-device    = 'PRINTER'.
    WHEN '7'.
      DATA: l_email TYPE ad_smtpadr.
      wa_output_options-tdnoprev = c_x.
      wa_control_parameters-getotf  = c_x.
To get the default output device maintained in the
User profile
     SELECT SINGLE spld FROM usr01
      INTO w_spld
      WHERE bname EQ nast-usnam.
      IF sy-subrc EQ 0.
        MOVE w_spld TO  wa_output_options-tddest   .
      ENDIF.
      wa_output_options-tdnoprev = c_x.
      wa_control_parameters-getotf  = c_x.
To get the email address maintained for the particular output
      CALL FUNCTION 'NAST_GET_MESSAGE_OBJECT_RECV'
        EXPORTING
          pi_objkey             = nast-tdname
        IMPORTING
          pe_addr               = w_receiver
        CHANGING
          pc_objhandle          = w_obj_record
        EXCEPTIONS
          maildata_not_readable = 1
          OTHERS                = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
       WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      IF w_receiver NA c_atrate.
To retrieve the E-Mail Id in case we get the User name from NAST
        CLEAR wa_soudnamei1.
        REFRESH i_soudnamei1.
        MOVE w_receiver TO wa_soudnamei1-fullname.
To get the user name
        CALL FUNCTION 'SO_NAME_CONVERT_API1'
          EXPORTING
            name            = wa_soudnamei1
          TABLES
            names           = i_soudnamei1
          EXCEPTIONS
            user_not_exist  = 1
            parameter_error = 2
            x_error         = 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.
        CLEAR wa_soudnamei1.
        READ TABLE i_soudnamei1 INTO wa_soudnamei1 INDEX 1.
        MOVE wa_soudnamei1-sapname TO w_user.
To get the e-mail Id maintained in the user profile
        CALL FUNCTION 'FTR_CORR_CHECK_EMAIL_SAP_USER'
          EXPORTING
            i_user              = w_user
          IMPORTING
            e_email_address     = l_email
          EXCEPTIONS
            mail_address        = 1
            determination_error = 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.
        MOVE l_email TO w_receiver.
      ENDIF.
      MOVE  w_receiver TO w_email.
  ENDCASE.
  wa_control_parameters-no_dialog = c_x.
  wa_control_parameters-langu     = nast-spras .
  wa_output_options-tdteleland    = nast-tland.
  wa_output_options-tdtelenum     = nast-telfx .
  wa_output_options-tdsenddate    = nast-erdat .
  wa_output_options-tdsendtime    = nast-eruhr .
  wa_output_options-tddataset     = nast-dsnam .
  wa_output_options-tdsuffix1     = nast-dsuf1 .
  wa_output_options-tdsuffix2     = nast-dsuf2 .
  wa_output_options-tdimmed       = nast-dimme .
  wa_output_options-tddelete      = nast-delet .
  wa_output_options-tdautority    = nast-tdautority.
  wa_output_options-tdcovtitle    = nast-tdcovtitle .
  wa_output_options-tdcover       = nast-tdocover .
  wa_output_options-tdreceiver    = nast-tdreceiver.
  wa_output_options-tddivision    = nast-tddivision.
  wa_output_options-tdcopies      = nast-anzal .
  wa_output_options-tdnewid       = c_x.
  wa_output_options-tdarmod       = nast-tdarmod.
  wa_output_options-tdnoarmch     = c_x.
  CALL FUNCTION w_form_name
    EXPORTING
     archive_index      = toa_dara
     archive_parameters = arc_params
      control_parameters = wa_control_parameters
      output_options     = wa_output_options
      user_settings      = ' '
    IMPORTING
      job_output_info    = w_return
    TABLES
      it_lips            = i_lips
    EXCEPTIONS
      formatting_error   = 1
      internal_error     = 2
      send_error         = 3
      user_canceled      = 4
      OTHERS             = 5.
  IF nast-nacha EQ 7 AND sy-subrc EQ 0.
    i_otf[] = w_return-otfdata[].
    CALL FUNCTION 'CONVERT_OTF'
      EXPORTING
        format                = 'PDF'
        max_linewidth         = 132
      IMPORTING
        bin_filesize          = w_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 <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
Convert PDF from 132 to 255.
    LOOP AT i_tline.
Replacing space by ~
      TRANSLATE i_tline USING ' ~'.
      CONCATENATE w_buffer i_tline INTO w_buffer.
    ENDLOOP.
Replacing ~ by space
    TRANSLATE w_buffer USING '~ '.
    DO.
      i_record = w_buffer.
Appending 255 characters as a record
      APPEND i_record.
      SHIFT w_buffer LEFT BY 255 PLACES.
      IF w_buffer IS INITIAL.
        EXIT.
      ENDIF.
    ENDDO.
    REFRESH: i_reclist,
    i_objtxt,
    i_objbin,
    i_objpack.
    CLEAR w_objhead.
Object with PDF.
    i_objbin[] = i_record[].
    DESCRIBE TABLE i_objbin LINES w_lines_bin.
Document information.
    w_doc_chng-obj_name = 'Smartform'.
    w_doc_chng-expiry_dat = sy-datum + 10.
    CONCATENATE 'Delivery' 'Note'
    INTO w_doc_chng-obj_descr.
*w_doc_chng-obj_descr = 'Smart form output'.
    w_doc_chng-sensitivty = 'F'. "Functional object
    w_doc_chng-doc_size = w_lines_txt * 255.
Pack to main body as RAW.
Obj. to be transported not in binary form
    CLEAR i_objpack-transf_bin.
Start line of object header in transport packet
    i_objpack-head_start = 1.
Number of lines of an object header in object packet
    i_objpack-head_num = 0.
Start line of object contents in an object packet
    i_objpack-body_start = 1.
Number of lines of the object contents in an object packet
    i_objpack-body_num = w_lines_txt.
Code for document class
    i_objpack-doc_type = 'RAW'.
    APPEND i_objpack.
Packing as PDF.
    i_objpack-transf_bin = 'X'.
    i_objpack-head_start = 1.
    i_objpack-head_num = 1.
    i_objpack-body_start = 1.
    i_objpack-body_num = w_lines_bin.
    i_objpack-doc_type = 'PDF'.
    i_objpack-obj_name = 'Smartform'.
    CONCATENATE 'Delivery' 'Note' '.pdf'
    INTO i_objpack-obj_descr.
    i_objpack-doc_size = w_lines_bin * 255.
    APPEND i_objpack.
Document information.
    CLEAR i_reclist.
e-mail receivers.
    i_reclist-receiver = w_email.
    i_reclist-express = 'X'.
    i_reclist-rec_type = 'U'. "Internet address
    APPEND i_reclist.
sending mail.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        document_data              = w_doc_chng
        put_in_outbox              = 'X'
      TABLES
        packing_list               = i_objpack
        object_header              = w_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 <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
  ENDIF.
ENDFORM.                    "processing
OTF to PDF
========================================================================
Program1
*& REPORT  zpmm_print1
REPORT  zpmm_print1.
DATA : gw_ssfcrescl TYPE ssfcrescl.
DATA: gt_otf TYPE STANDARD TABLE OF itcoo ,
      gt_tline TYPE STANDARD TABLE OF tline,
      gv_len LIKE sood-objlen,
      gw_ssfctrlop TYPE ssfctrlop, "for CONTROL_PARAMETERS
      gw_ssfcompop TYPE ssfcompop. "for OUTPUT_OPTIONS
DATA  fm_name TYPE rs38l_fnam.
gw_ssfctrlop-getotf = 'X'.
gw_ssfctrlop-no_dialog = 'X'.
gw_ssfcompop-tdnoprev = 'X'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    formname           = 'ZPMM_1'
  IMPORTING
    fm_name            = fm_name
  EXCEPTIONS
    no_form            = 1
    no_function_module = 2
    OTHERS             = 3.
IF sy-subrc <> 0.
<error handling>
ENDIF.
CALL FUNCTION fm_name
EXPORTING
  ARCHIVE_INDEX              =
  ARCHIVE_INDEX_TAB          =
  ARCHIVE_PARAMETERS         =
   control_parameters         = gw_ssfctrlop
  MAIL_APPL_OBJ              =
  MAIL_RECIPIENT             =
  MAIL_SENDER                =
   output_options             = gw_ssfcompop
   user_settings              = 'X'
IMPORTING
  DOCUMENT_OUTPUT_INFO       =
   job_output_info            = gw_ssfcrescl
  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.
gt_otf[] = gw_ssfcrescl-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
  EXPORTING
    format                = 'PDF'
    max_linewidth         = 132
  IMPORTING
    bin_filesize          = gv_len
  TABLES
    otf                   = gt_otf
    lines                 = gt_tline
  EXCEPTIONS
    err_max_linewidth     = 1
    err_format            = 2
    err_conv_not_possible = 3
    OTHERS                = 4.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
DATA : gv_filename LIKE rlgrap-filename VALUE 'C:\swet.pdf'.
CALL FUNCTION 'DOWNLOAD'
  EXPORTING
    bin_filesize     = gv_len
    filename         = gv_filename
    filetype         = 'BIN'
    filetype_no_show = 'X'
  IMPORTING
    act_filename     = gv_filename
    filesize         = gv_len
   cancel           = ''
  TABLES
    data_tab         = gt_tline.
Program 2
*& REPORT  zpmm_print2
REPORT  zpmm_print2.
DATA : gw_ssfcrescl TYPE ssfcrescl.
DATA: gt_otf TYPE STANDARD TABLE OF itcoo ,
      gt_tline TYPE STANDARD TABLE OF tline,
      gv_len LIKE sood-objlen,
      gw_ssfctrlop TYPE ssfctrlop, "for CONTROL_PARAMETERS
      gw_ssfcompop TYPE ssfcompop. "for OUTPUT_OPTIONS
DATA  fm_name TYPE rs38l_fnam.
gw_ssfctrlop-getotf = 'X'.
gw_ssfctrlop-no_dialog = 'X'.
gw_ssfcompop-tdnoprev = 'X'.
CALL FUNCTION '/1BCDWB/SF00000041'
EXPORTING
  ARCHIVE_INDEX              =
  ARCHIVE_INDEX_TAB          =
  ARCHIVE_PARAMETERS         =
   control_parameters         = gw_ssfctrlop
  MAIL_APPL_OBJ              =
  MAIL_RECIPIENT             =
  MAIL_SENDER                =
   output_options             = gw_ssfcompop
   user_settings              = 'X'
IMPORTING
  DOCUMENT_OUTPUT_INFO       =
   job_output_info            = gw_ssfcrescl
  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.
gt_otf[] = gw_ssfcrescl-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
  EXPORTING
    format                = 'PDF'
    max_linewidth         = 132
  IMPORTING
    bin_filesize          = gv_len
  TABLES
    otf                   = gt_otf
    lines                 = gt_tline
  EXCEPTIONS
    err_max_linewidth     = 1
    err_format            = 2
    err_conv_not_possible = 3
    OTHERS                = 4.
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
DATA : gv_filename LIKE rlgrap-filename VALUE 'C:\swet.pdf'.
CALL FUNCTION 'DOWNLOAD'
  EXPORTING
    bin_filesize     = gv_len
    filename         = gv_filename
    filetype         = 'BIN'
    filetype_no_show = 'X'
  IMPORTING
    act_filename     = gv_filename
    filesize         = gv_len
   cancel           = ''
  TABLES
    data_tab         = gt_tline.
=========================================================================
Cheers
Mohinder Singh Chauhan

Similar Messages

  • Web Reporting - Converting HTML to PDF and displaying

    Does any know of a method to convert the html data stream to a PDF format so it may be returned to the browser for printing?

    i created an Help Service which can convert the current Web Application State to Pdf and it displays it automatical in the browser window. Charts and all the other stuff is also converted.
    This is only on-top of a complex PDF Framework which offers features you request for example.
    Batch support. Load balancing. Stylesheet support. Report Books. There are Convenience Classes in ABAP which support Template ID in PDF-Bytestream out. Sent PDF as mail. publish to Portal. Information Broadcasting integration etc.
    the advatnage of this solution is that the conversion is performed on the Server and not on the client which means you need only one license, and not for each client...
    i hope this helps.
    best regards.
    Kai Wachter

  • 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

  • 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

  • Convert ABAP Spool to PDF and display in BSP

    Hello SDNers,
    I have a requirement to display an R/3 report in Portal as PDF. I have chosen the route of creating a BSP which will show the report as PDF.
    I will then create a BSP iView in Portal pointing to this application.
    I am following the weblog /people/sap.user72/blog/2004/11/10/bsphowto-generate-pdf-output-from-a-bsp
    and few SDN forums:
    Display result of standard report RPTEDT00 within BSP
    Re: PDF Output
    I am new to BSP development and I am not able to put all the pieces of code together.
    I would really appreciate if you can help me put the pieces together and help me out with this.
    More details:
    This custom report displays the summary of Benefits Cost Accounting (by PERNR and current year).
    Once the report is run, I would like to get hold of the spool and convert the spool to PDF.
    In my BSP I would like to get the spool (or the binary of the PDF) and display the report as PDF in the BSP application.
    I have created the BSP application using the code given in the above weblog.
    I am not sure how to proceed further with the requirement.
    Looking forward for your suggestions and help.
    Thanks,
    Kalyan

    Hi kalyan,
    go thru this wiki and you will have what you need all at one place. the piece you might want to look at is ABAP spool to PDF. It even contains complete code.
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/bsp/pdf
    hope this helps.

  • Convert spool to PDF and send as email attachment

    When i try to convert SAP spool to PDF and send it as email attachment,  size of PDF document becomes large as compared to size of the PDF cocument i download using the same spool.
    I am using following FMs.
    CONVERT_ABAPSPOOLJOB_2_PDF to convert spool to PDF
    and
    SO_NEW_DOCUMENT_ATT_SEND_API1 to send email with attchment.
    some times size of attchment exceeds 2MB and email results in error in SAP connect (SOST).
    Any idea on how to compress the PDF attchment??
    Thanks

    Hi Venkat,
    Can you plesae assist me.
    I have a requirement to convert spool to pdf
    send an email to users
    issue is that attachement is big cant go through
    I have used compress, but when I open the pdf file error that file was not correclty decoded
    please assist, anyone

  • Photoshop: How to save as a pdf and display description?

    The only other Photoshop I ever used was CS3, and when I clicked "print" it saved as a pdf first, and I could choose to make it display different metadata. That feature has been removed for all newer versions for some reason, and I have no idea how to do what I want to do.
    I need to save it as a pdf, and display the description/subject metadata under the photo. I can't find anything online on how to do this.

    BlazeHeatnix,
    Due to the current unavailability of clairvoyants and mind-readers in the forum, we respectfully request you supply sensible, complete details.
    Please understand that "CS5" does not clear up the issue of what version of Photoshop you are using.  "Photoshop CS5 12.0.1" would.
    A screen capture would be very helpful.
    Also, have you trued the Print command, then Save As PDF?
    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • How to merge multiple PDFs and display in a new window

    Hi,
    I'm trying to merge multiple PDFs into one PDF and display the output in a new window using PeopleCode. I have a button on a page, which when clicked should open a new window with the merged PDFs. I am able to succussfully merge the PDFs using the PDFmerger class (mergePDFs) but unable to display the result in a new window.
    Please help.

    Thanks.
    I also found this piece of code very helpful.
    Local PSXP_RPTDEFNMANAGER:Utility &oUtil;
    Local boolean &bRtn;
    /* send the output to client */
    /* &sFileName = the file path /file_name.extension */
    &oUtil = create PSXP_RPTDEFNMANAGER:Utility();
    &bRtn = &oUtil.zipAndViewAttachment(&sFileName);
    Edited by: user8260115 on Sep 9, 2009 4:57 PM

  • How do I convert .txt to .pdf and keep the formatting

    I have a large .txt file that I would like to convert to .pdf.  I have tried to print the file and choose Adobe PDF but the output is just a mess.  I loose all the formatting and get blank pages every so often.  Does anyone know if is possible to convert .txt to .pdf and keep the formatting.  I would try a virtual printer application but I am not able to just install any application on my office computer.  Any help would be greatly appreciated.

    It may be a bit late for you now but in future (and for anyone else interested) I would recommend copying the text into a word document and changing the text font to Consolas. Adjust the size to fit the page again and it should match the original notepad formatting.

  • When converting word to PDF and reducing the size, the formatting changes how can i keep the format but reduce the size?

    When converting word to PDF and reducing the size, the formatting changes how can i keep the format but reduce the size?

    The original file is 32 MB:
    15 MB is images
    15 MB is Content stream
    2 MB is everything else
    After the PDF/A-1B save as:
    The file is 182 MB
    Almost 100% is Images
    It is an architecture portfolio with many complex images.  Is there a setting when I change to PDF/A that can limit the growth of the image files?

  • Standard text displayed correctly in print preview but not in print

    Hi,
    I have a script in which a standard text has to be printed in the output.
    The standard text contains some german characters.
    These characters are displayed correctly in print preview but not in print.
    The text is maintained in 3 languages DE,EN and Russian.
    The same text is being printed in some standard report. But that is displayed correctly both in print and print preview.
    Please suggest something.
    Regards,
    Richa Aggarwal

    Hi Richa,
    Check this document from SAP: [help doc|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0652a95-5f0b-2a10-5aba-c085f8bbe6d6?QuickLink=index&overridelayout=true]
    It indicates that you have to be sure to select "Unicode" fonts for your SAPScript form to ensure the proper printing of "Unicode" characters.  If a character does not display then that means it does not exist in the font that you are using.
    Regards,
    Ryan Crosby

  • Deleted items also to be displayed in PO print preview

    Hi
        I want the deleted items also to be displayed in PO print preview..
       If it is possible  What should i do in configuration ?
    Regards,
    Alagesan

    Thanks.
    It can be made appear directly in print out? 
    What may be the solution bcoz we need the send customer the revised PO indicating the deleted items also ?
    Alagesan

  • 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

  • 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 to PDF and send as email attachment

    Hi
    I want to send the Smartform to mail as PDF attachment.
    I found the program in code gallery., it name was 'ZTEST_NREDDY_PDF_MAIL' .
    I used this program and it send the Smartform to mail as PDF attachment but when open the pdf file it gave me error.
    error : 'An unrecognized token Qq was found'.
    Please help me out.
    Thanks
    Anina

    Hi,
    Following is the code logic:
        Tables for OTF to PDF Conversion
    DATA: g_t_docs      TYPE STANDARD TABLE OF docs,                      " Table for Stored Document
          g_t_lines     TYPE STANDARD TABLE OF tline.                     " Table for Text lines
        Objects to send mail.
    DATA: g_t_objpack   LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,        " SAPoffice: Description of Imported Object Components
          g_t_objtxt    LIKE solisti1   OCCURS 0 WITH HEADER LINE,
          g_t_objbin    LIKE solisti1   OCCURS 0 WITH HEADER LINE,
          g_t_contout   LIKE solisti1   OCCURS 0 WITH HEADER LINE,
          g_t_reclist   LIKE somlreci1  OCCURS 0 WITH HEADER LINE.        " SAPoffice: Structure of the API Recipient List
        Addresses (Business Address Services)
    DATA: g_t_adrc      LIKE adrc  OCCURS 0,
          g_t_adrc2     LIKE adrc  OCCURS 0,
          g_t_adrc3     LIKE adrc  OCCURS 0,
          g_t_adrc_wa   TYPE adrc,
          g_t_adrc2_wa  TYPE adrc,
          g_t_adrc3_wa  TYPE adrc.
        Sales Document: Partner
    DATA: g_t_vbpa_wa   TYPE vbpa.
        E-Mail Addresses (Business Address Services)
    DATA: g_t_adr6      LIKE adr6  OCCURS 0,
          g_t_adr6_2    LIKE adr6  OCCURS 0,
          g_t_adr6_wa   TYPE adr6,
          g_t_adr6_2_wa TYPE adr6.
    DATA:
        Work Area declarations
          g_wa_objhead   TYPE soli_tab,                                    " Work Area for Objcont and Objhead as Table Type
          g_wa_doc_chng  TYPE sodocchgi1,                                  " Work Area - Data of an object which can be changed
        Variables declarations
          g_lines_txt    TYPE i,
          g_lines_bin    TYPE i,
          g_email_id(40) VALUE '',                         " E-mail Address
        PDF related data declarations
          g_wa_job_output_info      TYPE   ssfcrescl,                      " Smart Forms: Return value at end of form printing
          g_wa_control_parameters   TYPE   ssfctrlop,"#EC NEEDED           " Smart Forms: Control structure
          g_name                    TYPE   string,
          g_path                    TYPE   string,
          g_fullpath                TYPE   string,
          g_filename                TYPE   string,
          g_filter                  TYPE   string,
          g_bin_filesize            TYPE   i,
          g_uact                    TYPE   i,
          g_guiobj                  TYPE   REF TO cl_gui_frontend_services.
      PERFORM f0100_download_pdf.    
      PERFORM f200_convert_to_pdf.
      PERFORM f300_attach_and_mail_pdf.   
    *&      Form  f0100_download_pdf
          To Download the PDF Format of SmartForm on
          Presentation Server
    FORM f0100_download_pdf.                                    "#EC CALLED
    Downloading PDF File
      CREATE OBJECT g_guiobj.
      CALL METHOD g_guiobj->file_save_dialog
        EXPORTING
          default_extension = 'pdf'
          default_file_name = g_name
          file_filter       = g_filter
        CHANGING
          filename          = g_name
          path              = g_path
          fullpath          = g_fullpath
          user_action       = g_uact.
      IF g_uact = g_guiobj->action_cancel.
        EXIT.
      ENDIF.
      MOVE g_fullpath TO g_filename.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          bin_filesize = g_bin_filesize
          filename     = g_filename
          filetype     = 'BIN'
        TABLES
          data_tab     = g_t_lines.
    ENDFORM.                    "f0100_download_pdf
    *&      Form  f0200_convert_to_pdf
          To convert the SmartForm to PDF format
    FORM f0200_convert_to_pdf .                                 "#EC CALLED
      CALL FUNCTION 'CONVERT_OTF_2_PDF'
        IMPORTING
          bin_filesize   = g_bin_filesize
        TABLES
          otf            = g_wa_job_output_info-otfdata
          doctab_archive = g_t_docs
          lines          = g_t_lines.
      CONCATENATE text-001 g_sales_order_no '.pdf' INTO g_name.
    ENDFORM.                    " f0200_convert_to_pdf
    *&      Form  f0300_attach_and_mail_pdf
          To E-Mail the PDF form as an Attachment
    FORM f0300_attach_and_mail_pdf .                            "#EC CALLED
    Attachment
      REFRESH: g_t_reclist,
               g_t_objtxt,
               g_t_objbin,
               g_t_objpack.
      CLEAR g_wa_objhead.
    Create Message Body Title and Description
      g_t_objtxt = g_name.
      APPEND g_t_objtxt.
      DESCRIBE TABLE g_t_objtxt LINES g_lines_txt.
      READ TABLE g_t_objtxt INDEX g_lines_txt.
      g_wa_doc_chng-obj_name = g_name.
      g_wa_doc_chng-expiry_dat = sy-datum + 10.
      g_wa_doc_chng-obj_descr = g_name.
      g_wa_doc_chng-sensitivty = 'F'.
      g_wa_doc_chng-doc_size = g_lines_txt * 255.
    Main Text
      CLEAR g_t_objpack-transf_bin.
      g_t_objpack-head_start = 1.
      g_t_objpack-head_num = 0.
      g_t_objpack-body_start = 1.
      g_t_objpack-body_num = g_lines_txt.
      g_t_objpack-doc_type = 'RAW'.
      APPEND g_t_objpack.
    Attachment (PDF-Attachment)
      g_t_objpack-transf_bin = 'X'.
      g_t_objpack-head_start = 1.
      g_t_objpack-head_num = 0.
      g_t_objpack-body_start = 1.
    Convert TLINE to SOLISTI1
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
        EXPORTING
          line_width_src              = 134
          line_width_dst              = 255
        TABLES
          content_in                  = g_t_lines
          content_out                 = g_t_contout
        EXCEPTIONS
          err_line_width_src_too_long = 1
          err_line_width_dst_too_long = 2
          err_conv_failed             = 3
          OTHERS                      = 4.
      IF sy-subrc <> 0.
        MESSAGE s000(0k) WITH text-002.
        EXIT.
      ENDIF.
    Create Message Attachment
      APPEND LINES OF g_t_contout[] TO g_t_objbin[].
      DESCRIBE TABLE g_t_objbin LINES g_lines_bin.
      READ TABLE g_t_objbin INDEX g_lines_bin.
      g_t_objpack-doc_size = g_lines_bin * 255 .
      g_t_objpack-body_num = g_lines_bin.
      g_t_objpack-doc_type = 'PDF'.
      g_t_objpack-obj_name = text-003.
      g_t_objpack-obj_descr = text-004.
      APPEND g_t_objpack.
      CLEAR g_t_reclist.
      g_t_reclist-receiver = g_email_id.
      g_t_reclist-rec_type = 'U'.
      APPEND g_t_reclist.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data = g_wa_doc_chng
          put_in_outbox = 'X'
          commit_work   = 'X'
        TABLES
          packing_list  = g_t_objpack
          object_header = g_wa_objhead
          contents_bin  = g_t_objbin
          contents_txt  = g_t_objtxt
          receivers     = g_t_reclist.
    ENDFORM.                    " f0300_attach_and_mail_pdf

Maybe you are looking for

  • Captivate icon bounces but won't open.

    Captivate button bounces but won't open. It's a subscription and I can't figure out how to reinstall. Any ideas?

  • Fields from screen are not known by program.

    Hi All. I have this problem since I started using Dialog programming. Since I didn't attended any course I might be doing something wrong. When you define a field in a Dialog screen and you want to refer to it in the program that calls that screen yo

  • Can you mix roaming and extended airport networks as such:

    I have my main aebs connected to the cable modem.  I want to conenct several airport expresses to the aebs via powerlien adapters to form a roaming network.  One airport express I cant connect conveniently to powerline so I want to set it up to exten

  • Security and permissions issue

    I don't know if what happened with me is a problem or just a normal thing! I have Windows Server 2003, PCs, and MACs, the following scenario happening: 1-A Mac (MacBook) bind (Joined) the domain (Windows Server 2003). 2-Log in to the Mac using networ

  • SCCM-Windows Update

    SCCM 2012 SP1 CU3 Issue:  When a user goes to Windows update it shows Windows is up to Date, even using "Check for updates" but when selects "Check online for updates from Microsoft Update" it comes back with available updates. We always when deployi