SO_NEW_DOCUMENT_ATT_SEND_API1 pdf attachment sending thru mail ecc 6.0

Hi All,
I'm using ECC 6.0 version, I'm trying to attach a pdf file to a mail using the function module SO_NEW_DOCUMENT_ATT_SEND_API1. But gtting error as "wasn't decoded correctly", but the same coding is working fine in 4.6 version. What changes i should do while using this function module in ECC 6.0 to get it corrected.
Thanks & Regards,
Sabu.

Hi ,
I tried with SBWP, I'm able to see the pdf file attached while sending from SBWP.
Please see the below coding
      FORM make_the_message                                         *
FORM make_the_message.
Create Message Body
Title and Description
  CLEAR : docdata,
          objtxt[],
          objpack[],
          objbin[].
  docdata-obj_name  = sy-repid.
  docdata-obj_descr = p_subj.
Main Text
  LOOP AT gt_text INTO objtxt.
    APPEND objtxt.
  ENDLOOP.
Write Packing List (Main)
  DESCRIBE TABLE objtxt LINES tab_lines.
  READ     TABLE objtxt INDEX tab_lines.
  docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
  CLEAR objpack-transf_bin.
  objpack-head_start = 1.
  objpack-head_num   = 0.
  objpack-body_start = 1.
  objpack-body_num   = tab_lines.
Sabu
  objpack-doc_type   = 'RAW'.
objpack-doc_type   = 'PDF'.
End Sabu
  APPEND objpack.
*Start of Upgrade ECC 6.0
  Data: l_mi_bytecount TYPE i.
*End of Upgrade ECC 6.0
Create Message Attachment (As read earlier from frontend)
Write Packing List (Attachment)
Handle the attached file.
  objbin[] = gt_pdffile[].
  att_type = 'PDF'.
  DESCRIBE TABLE objbin LINES tab_lines.
  READ     TABLE objbin INDEX tab_lines.
  objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
  objpack-transf_bin = 'X'.
  objpack-head_start = 1.
*****Sabu 8496
objpack-head_num   = 0.
  objpack-head_num   = 1.
End Sabu
  objpack-body_start = 1.
  objpack-body_num   = tab_lines.
*Start of Upgrade ECC 6.0
  objpack-doc_type   = att_type.
  objpack-obj_name   = 'ATTACHMENT.pdf'.
  objpack-obj_descr  = 'Attached Document'.
*End of Upgrade ECC 6.0
  APPEND objpack.
Create receiver list
Generate ALV list for either Customers/Vendors/Contact persons etc.
ENDFORM.                    "make_the_message
      FORM fill_the_distribution_list                               *
FORM fill_the_distribution_list USING i_test
                                      i_fax
                                      i_faxcntry
                                      i_email.
Just as a test...
  CLEAR: reclist, reclist[].
  IF i_test EQ 'X'.
    CASE 'X'.
      WHEN p_sndfax.
      By Fax
        rec_fax-rec_fax   = i_fax.
        rec_fax-rec_state = i_faxcntry.
Start of Changes 07/09/2008
       reclist-receiver  = rec_fax.
        ASSIGN reclist-receiver TO <fs_reclist> CASTING.
        <fs_reclist> = rec_fax.
       rec_fax = <fs_reclist>.
End of Changes 07/09/2008
        reclist-rec_type  = 'F'.
        APPEND reclist.
      WHEN p_sndint.
      By Email
        reclist-receiver = i_email.
        reclist-rec_type = 'U'.
        reclist-BLIND_COPY = 'X'.
        APPEND reclist.
    ENDCASE.
  ELSE.
  This is not a test....
    LOOP AT gt_detail INTO gs_detail.
      CHECK gs_detail-flag EQ icon_green_light.
      CASE 'X'.
        WHEN p_sndfax.
        By Fax
          rec_fax-rec_fax   = gs_detail-faxnr.
          rec_fax-rec_state = gs_detail-land1.
Start of Changes 07/09/2008
          ASSIGN reclist-receiver TO <fs_reclist> CASTING.
          <fs_reclist> = rec_fax.
          rec_fax = <fs_reclist>.
         reclist-receiver  = rec_fax
End of Changes 07/09/2008
          reclist-rec_type  = 'F'.
          APPEND reclist.
        WHEN p_sndint.
        By Email
          reclist-receiver = gs_detail-email.
          reclist-rec_type = 'U'.
          reclist-BLIND_COPY = 'X'.
          APPEND reclist.
      ENDCASE.
    ENDLOOP.
  ENDIF.
ENDFORM.                    "fill_the_distribution_list
      FORM send_the_messages                                        *
FORM send_the_messages.
Send Message
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
          document_data                    = docdata
          put_in_outbox                    = 'X'
          commit_work                      = 'X'
    IMPORTING
        SENT_TO_ALL                      =
        NEW_OBJECT_ID                    =
      TABLES
          packing_list                     = objpack
          object_header                    = objhead
          contents_bin                     = objbin
          contents_txt                     = objtxt
        OBJECT_PARA                      =
        OBJECT_PARB                      =
          receivers                        = 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     'SO'
            TYPE   'S'
            NUMBER '023'
            WITH   docdata-obj_name.
  ELSE.
    PERFORM popup.
  ENDIF.
ENDFORM.                    "send_the_messages
Thanks & Regards,
Sabu

Similar Messages

  • ME23N Script convert to PDF and send thru mail to the user created by

    Hi,
    I have created a custom PO SAP scirpt for the tcode ME23N and configured the same in tcode NACE Application 'EF' , output type 'NEU'
    But the client requirement is to send  this SAP Scipt PO converted to pdf & then send thru email to the user who created PO (ME23N)?
    How do u get this functionality please let me know?
    Regards,
    Anil

    Hello,
    that is easy, you only need to keep the steps to do in mind:
    1) find a suitable point to place in your code to do all this for you
    2) create a FM that will convert your form into PDF (search a little, this has been done like zillion times here)
    3) create a FM that will send the PDF stream (hex data which is accepted by the BCS class as the attachment data)
    4) check the email customizing in your system
    5) run and enjoy
    All the parts has been done here many times, shouldn´t be a problem.
    Otto

  • Send a remuneration statement (paystub) as a PDF attachment by e-mail

    Hi,
    Does anybody send to their employees remuneration statement (paystub) as a PDF attachment by e-mail?
    Could you please share the method that you using for it and advice why you choose this method?
    I need to analyse at least two options:
    u2022     Sending standard SAP Remuneration FORM
    u2022     Sending custom made Remuneration FORM (more relevant to my situation)
    Thank you in advance,
    Yutah

    Thank you Rohan,
    It may work for standard SAP payslip form but still need to find out how to send it out by e-mail automatically after pay-run is done to a bunch of employees.
    Is there any standard solution or I need to create custom program to do it?
    Any idea about custom made payslip form.
    Right now we create a text file which we send to third party for payslip printing and have a custom made report which reads this file if we need to display/print payslip in house.

  • How to convert sapscript(Purchage order) inot pdf format & send in  mail

    Dear Gentlemen,
    I got one req.
    <b>convertion of sapscript(purchage order) to pdf format and send converted pdf format in the mail.</b>
      Can anybody please give detail & proper way to achive this requriment.
    It is very useful to me, I am thankful to everybody, give help in this matter.
    Regards,
    Vasu

    chk this one
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    some function modules useful would be
    CONVERT_OTF
    SO_NEW_DOCUMENT_ATT_SEND_API1 to send mails with attachments
    plzz refer to this link..it will solve ur problem
    Re: Sending a PDF document as an attachment
    sending the mail with PDF attachment

  • Smartform - PDF attachment through E-mail issue

    Hi,
    A custom form and custom program was created to print the Purchase order information through ME21N, 22n and 23n.
    It also has E-mail option. when output medium 5(Simple mail) and 7(External send), email will be send to respective mail-id's with the PDF attachment.
    I have issue at the time of saving PO which processed with medium 5. when i save A popup appears "Express document update was terminated received from author". Brief message about it is
    "Error Info... 00 671: ABAP/4 processor: COMMIT_IN_POSTING"
    In Smartform driver program i am using below function modules to convert OTF into PDF and send through e-mail.
    Function Module: CONVERT_OTF.
    Function Module: SO_DOCUMENT_SEND_API1.
    I am not sure, what i missed out. Can you guys tell is this the correct way to send PDF attachment through E-mail or i missed out any function module for commit.
    Regards,
    Hemanth.
    Edited by: keerthipati hemanth on Jul 31, 2008 1:15 PM
    <MOVED BY MODERATOR TO THE CORRECT FORUM>
    Edited by: Alvaro Tejada Galindo on Jul 31, 2008 3:14 PM

    Hi Hemant,
    Below is the code for the  downloading of the smartform into the PDF Format.
    * Program Name : ZPPREP_SHOPFLOOR_VIEWER_ZOOM
    REPORT zppeerep_shorepfloor_viewer_zoom.
    * T A B L E S    D E C L A R A T I O N
    *---Tables Used.
    TABLES: afpo,
            mara,
            marc,
            aufk,
            afko,
            itcoo,
            nast,                          "Messages
            *nast,                         "Messages
            tnapr,                         "Programs & Forms
            addr_key,
            arc_params,                    "Archive parameters
            toa_dara.                      "Archive parameters
    * I N T E R N A L    T A B L E S     D E C L A R A T I O N
    *--Internal Tables Used.
    * D A T A     D E C L A R A T I O N
    *--Global Variables Used.
    DATA: ws_matnr LIKE afpo-matnr,
          ws_werks LIKE aufk-werks,
          ws_mtart LIKE mara-mtart,
          ws_wrkst LIKE mara-wrkst,
          ws_fname TYPE rs38l_fnam,
          ws_ctrlp TYPE ssfctrlop,
          ws_optns TYPE ssfcompop,
          w_padest LIKE tsp03l-padest.                          "BMC01+
    DATA: da_message_printed(1) TYPE c,
          da_preview_processed(1) TYPE c,
          repeat(1) TYPE c,
          da_subrc LIKE sy-subrc.
    DATA: w_otfdata  TYPE ssfcrescl.
    DATA: BEGIN OF it_itcoo OCCURS 0.
            INCLUDE STRUCTURE itcoo.
    DATA: END OF it_itcoo.
    DATA: w_otf  TYPE itcoo.
    *--Data Declaration for Printing Layout
    DATA: ls_itcpo     TYPE itcpo.
    DATA: lf_repid     TYPE sy-repid.
    DATA: lf_device    TYPE tddevice.
    DATA: cf_retcode   TYPE sy-subrc.
    DATA: ls_recipient TYPE swotobjid.
    DATA: ls_sender    TYPE swotobjid.
    DATA: ls_control_param   TYPE ssfctrlop.
    DATA: ls_composer_param  TYPE ssfcompop.
    DATA: ls_addr_key        LIKE addr_key.
    DATA: w_screen(1) TYPE c.
    DATA: xscreen(1) TYPE c.
    DATA: da_mess LIKE vbfs OCCURS 0 WITH HEADER LINE.
    * C O N S T A N T S
    CONSTANTS: c_fas1(8)  TYPE c VALUE 'PRINTFAS',
               c_fas2(15) TYPE c VALUE 'PRINTFASDRAWING',
               c_wip1(8)  TYPE c VALUE 'PRINTWIP',
               c_wip2(15) TYPE c VALUE 'PRINTWIPDRAWING'.
    * S E L E C T I O N - S C R E E N.
    SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-bl1.
    * Production order
    PARAMETERS: p_aufnr LIKE afpo-aufnr OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK bl1.
    START-OF-SELECTION.
    *--Begin of Commenting                   "
    *--Get Partially processed orders
      MOVE: sy-mandt         TO nast-mandt,
            'V1'             TO nast-kappl,
            p_aufnr          TO nast-objky,
            p_aufnr          TO nast-parnr,
            sy-langu         TO nast-spras,
            sy-datum         TO nast-erdat,
            '1'              TO nast-nacha,
            '3'              TO nast-vsztp,
            'X'              TO nast-manue,
            sy-uname         TO nast-usnam,
            'DFLT'           TO nast-ldest,
            sy-langu         TO nast-tdspras,
            'Shop Floor Papers' TO nast-tdcovtitle,
            '1'              TO nast-tdarmod,
            'BUS2032'        TO nast-objtype.
    *--Printer settings
      CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
        EXPORTING
          pi_nast       = nast
          pi_repid      = sy-repid
        IMPORTING
          pe_returncode = cf_retcode
          pe_itcpo      = ls_itcpo
          pe_device     = lf_device
          pe_recipient  = ls_recipient
          pe_sender     = ls_sender.
      MOVE-CORRESPONDING ls_itcpo TO ls_composer_param.
      ls_control_param-device      = 'PRINTER'.
      ls_control_param-no_dialog   = 'X'.
      ls_control_param-preview     = 'X'.
      ls_control_param-getotf      = ls_itcpo-tdgetotf.
      ls_control_param-langu       = sy-langu.
    *--End   of Commenting                   "
    *--Start of Addition                     "
      CLEAR:   ws_werks.
      SELECT   SINGLE werks
               INTO   ws_werks
               FROM   aufk
               WHERE  aufnr = p_aufnr.
      CLEAR:   ws_matnr.
      SELECT   SINGLE plnbez
               INTO   ws_matnr
               FROM   afko
               WHERE  aufnr = p_aufnr.
      CLEAR:   marc.
      SELECT   SINGLE matgr
               INTO   marc-matgr
               FROM   marc
               WHERE  matnr = ws_matnr
               AND    werks = ws_werks.
    *--End   of Addition                     "
    *  CHECK NOT ws_matnr IS INITIAL.       
      IF NOT ws_matnr IS INITIAL.          
    *--Start of Addition                    
        SELECT   SINGLE matgr
                 INTO   marc-matgr
                 FROM   marc
                 WHERE  matnr = ws_matnr
                 AND    werks = ws_werks.
    *--Start of Addition BY Rapidigm01_01+
      ELSE.
        marc-matgr = c_wip1.
      ENDIF.
    *--End Of Addition BY Rapidigm01_01+
    *--End   of Addition                     "
    END-OF-SELECTION.
      PERFORM call_smartform.
    * F O R M    R O U T I N E S
    *&      Form  call_smartform
    *       text
    FORM call_smartform.
      CLEAR: ws_ctrlp, ws_optns, ws_fname.
    *--Start of Addition                                 "
      TRANSLATE marc-matgr TO UPPER CASE.
      IF marc-matgr = c_fas1 OR
         marc-matgr = c_fas2.
        PERFORM call_paper_a.
      ELSEIF marc-matgr = c_wip1 OR
             marc-matgr = c_wip2.
        PERFORM call_paper_b.
      ENDIF.
    *--End   of Addition                                 "
    ENDFORM.                    "call_smartform
    *&      Form  call_paper_a
    *       text
    FORM call_paper_a.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
    *>>BC SPARTA03    DATE: 19/05/2008
    *      formname           = 'ZPPSF_SHOP_FLOOR_PAPER_A'  "Rapidigm03_01-
          formname           = 'ZPPSF_SHOP_FLOOR_PAPER_C'  "Rapidigm03_01-
    *<<EC SPARTA03    DATE: 19/05/2008
    *       formname  = 'ZPPSF_SHOP_FLOOR_PAPER_A_2893'   "Rapidigm03_01+
        IMPORTING
          fm_name            = ws_fname
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      CHECK NOT ws_fname IS INITIAL.
      CLEAR w_otfdata.
      ls_control_param-getotf = 'X'.
      CALL FUNCTION ws_fname
        EXPORTING
          archive_index      = toa_dara
          archive_parameters = arc_params
          control_parameters = ls_control_param
          mail_recipient     = ls_recipient
          mail_sender        = ls_sender
          output_options     = ls_composer_param
          user_settings      = ' '
          is_nast            = nast
          aufnr              = p_aufnr
          flag_orig          = 'X'
        IMPORTING
          job_output_info    = w_otfdata
        EXCEPTIONS
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4
          OTHERS             = 5.
      LOOP AT w_otfdata-otfdata INTO w_otf.
        APPEND w_otf TO it_itcoo.
      ENDLOOP.
      CALL FUNCTION 'HR_IT_DISPLAY_WITH_PDF'
        TABLES
          otf_table = it_itcoo.
    ENDFORM.                    "call_paper_a
    *&      Form  call_paper_b
    *       text
    FORM call_paper_b.
      DATA: ws_doknr TYPE draw-doknr,
            ws_dokvr TYPE draw-dokvr.
      CLEAR: ws_doknr, ws_dokvr.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = 'ZPPSF_SHOP_FLOOR_PAPER_B'
        IMPORTING
          fm_name            = ws_fname
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      CHECK NOT ws_fname IS INITIAL.
      CLEAR w_otfdata.
      ls_control_param-getotf = 'X'.
      CALL FUNCTION ws_fname
        EXPORTING
          archive_index      = toa_dara
          archive_parameters = arc_params
          control_parameters = ls_control_param
          mail_recipient     = ls_recipient
          mail_sender        = ls_sender
          output_options     = ls_composer_param
          user_settings      = ' '
          is_nast            = nast
          aufnr              = p_aufnr
          doknr              = ws_doknr
          dokvr              = ws_dokvr
          flag_orig          = 'X'
        IMPORTING
          job_output_info    = w_otfdata
        EXCEPTIONS
          formatting_error   = 1
          internal_error     = 2
          send_error         = 3
          user_canceled      = 4
          OTHERS             = 5.
      LOOP AT w_otfdata-otfdata INTO w_otf.
        APPEND w_otf TO it_itcoo.
      ENDLOOP.
      CALL FUNCTION 'HR_IT_DISPLAY_WITH_PDF'
        TABLES
          otf_table = it_itcoo.
    ENDFORM.                    "call_paper_b

  • How to open a pdf attachment in imac mail

    I am unable to open a PDF attachment in Mac Mail. There is not a PDF Icon in the email message. Is there a setting that should be checked?
    I have a new iMac (less than a month old) with Mountain Lion.
    Help would be greatly appreciated. Thanks

    It is an actual PDF that is an attachment to an email. There is not a link to click on to open the attachment.
    The attachment is a statement that I normally open, then print..
    What I am seeing on the monitor is the heading portion of the email with the statement image, all on one page..It prints exactly as seen on the screen.
    I have checked my Mail>Preferences>Viewing Tab."Display remote images in HTML" messages is checked..
    Thanks for the help.

  • Error during sending a PDF attachment of a mail

    Hi everebody,
                      I'm using a custom program [ see below ] ( in which there is the call to the std function SO_DOCUMENT_SEND_API1) to send a PDF attachment to an user's SAPOFFICE: in release 4.6C it works correctly but the same programm in ECC6 it doesn't work correctly.  I mean: the mail is sent correctly with the attachment, but when I try to open the attachment this one doesn't open correctly showing a PDF error message.
    Any help?
                gino bonfiglioli
    *& Report  Z_UT_CONVERT_SPOOL_PDF
    REPORT  z_ut_convert_spool_pdf.
    TABLES: tsp01.
    variabili globali
    *data: fm_name            type rs38l_fnam,
         output_options     type ssfcompop,
         control_parameters type ssfctrlop,
         job_output_info    type ssfcrescl,
         job_output_options type ssfcresop,
    DATA: spoolno            LIKE tsp01-rqident,
          dir_pdf            LIKE rlgrap-filename,
          numbytes           TYPE i,
          pagecount          TYPE i,
          w_cnt              TYPE i,
          wk_subrc           LIKE sy-subrc,
          pdfspoolid         LIKE tsp01-rqident,
          gd_buffer          TYPE string,
          pdf                LIKE tline OCCURS 100 WITH HEADER LINE,
          stampante          LIKE usr01-spld,
          tot_line   TYPE sy-tabix,
          tot_line2  TYPE sy-tabix,
          start_line TYPE sy-tabix.
    tabelle interne per 1a mail
    DATA: BEGIN OF it_email OCCURS 100.
            INCLUDE STRUCTURE solisti1.
    DATA: END OF it_email.
    DATA: BEGIN OF email_data.
            INCLUDE STRUCTURE sodocchgi1.
    DATA: END OF email_data.
    DATA: BEGIN OF email_send OCCURS 10.
            INCLUDE STRUCTURE somlreci1.
    DATA: END OF email_send.
    DATA: packing_list TYPE STANDARD TABLE OF sopcklsti1 WITH HEADER LINE,
          it_mess_att  LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          receivers    TYPE STANDARD TABLE OF somlreci1 WITH HEADER LINE.
    fine tabelle interne per 1a mail
    PARAMETER: p_spool LIKE tsp01-rqident.
    START-OF-SELECTION.
      PERFORM conversione_spool_pdf USING wk_subrc.
      IF wk_subrc EQ 0.
        PERFORM invio_mail.
      ENDIF.
    *&      Form  CONVERSIONE_SPOOL_PDF
          text
         -->P_P_SUBRC  text
    FORM conversione_spool_pdf  USING    p_subrc.
    **- Conversione in PDF
      CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
          EXPORTING
            src_spoolid                    = p_spool
            no_dialog                      = ' '
          DST_DEVICE                     =
          PDF_DESTINATION                =
          IMPORTING
            pdf_bytecount                  = numbytes
            pdf_spoolid                    = pdfspoolid
            otf_pagecount                  = pagecount
           btc_jobname                    = jobname
           btc_jobcount                   = jobcount
          TABLES
            pdf                            = pdf
          EXCEPTIONS
            err_no_otf_spooljob            = 1
            err_no_spooljob                = 2
            err_no_permission              = 3
            err_conv_not_possible          = 4
            err_bad_dstdevice              = 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.
      p_subrc = sy-subrc.
    ENDFORM.                    " CONVERSIONE_SPOOL_PDF
    *&      Form  invio_mail
          text
    -->  p1        text
    <--  p2        text
    FORM invio_mail .
    Transfer the 132-long strings to 255-long strings
      LOOP AT pdf.
        TRANSLATE pdf USING ' ~'.
        CONCATENATE gd_buffer pdf 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.
    Testo della mail
      CLEAR it_email. REFRESH it_email.
      it_email-line = 'Testo della mail'.
      APPEND it_email.
    Creazione messaggio
      email_data-obj_name      = 'MESSAGE'.
      email_data-obj_descr     = 'Conversione spool n.'.
      email_data-obj_descr+26  = p_spool.
      email_data-obj_langu     = 'I'.
      email_data-sensitivty    = 'F'.
      READ TABLE it_mess_att INDEX w_cnt.
      email_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_mess_att ).
      start_line = 1.
      DESCRIBE TABLE it_email LINES tot_line.
      packing_list-transf_bin = ' '.
      packing_list-doc_type   = 'RAW'.
      packing_list-head_start = 1.
      packing_list-head_num   = 0.
      packing_list-body_start = 1.
      packing_list-body_num   = tot_line.
      packing_list-obj_langu  = sy-langu.
      APPEND packing_list.
      APPEND LINES OF it_mess_att TO it_email.
      CLEAR packing_list.
    Riga iniziale = ultima riga messaggio precedente + 1
      start_line = tot_line + 1.
      DESCRIBE TABLE it_mess_att LINES tot_line.
      packing_list-transf_bin = 'X'.
      packing_list-head_start = 1.
      packing_list-head_num   = 1.
      packing_list-body_start = 1.
      DESCRIBE TABLE it_mess_att LINES packing_list-body_num.
      packing_list-doc_type   = 'PDF'.
      packing_list-obj_descr  = 'Allegato PDF.'.
      packing_list-doc_size   =  packing_list-body_num * 255.
      packing_list-obj_langu  = sy-langu.
      APPEND packing_list.
    destinatario interno a SAP
      receivers-receiver = sy-uname.
      receivers-rec_type = 'B'.
      receivers-express = 'X'.
      APPEND receivers.
    destinatario esterno a SAP: deve essere un idirizzo email:
    receivers-receiver = '[email protected]'.
    receivers-rec_type = 'U'.
    APPEND receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
      EXPORTING
        document_data                    = email_data
        put_in_outbox                    = 'X'
       SENDER_ADDRESS                   = SY-UNAME
        sender_address_type              = 'B'
       COMMIT_WORK                      = 'X'
    IMPORTING
      SENT_TO_ALL                      =
      NEW_OBJECT_ID                    =
      SENDER_ID                        =
      TABLES
        packing_list                   = packing_list
        contents_bin                   = it_mess_att
        contents_txt                   = it_email
        receivers                      = 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.
      IF sy-subrc <> 0.
    errore invio mail
      ENDIF.

    Hi,
    Try to use fm 'SO_NEW_DOCUMENT_ATT_SEND_API1' instead of SO_DOCUMENT_SEND_API1.
    Please check documentation of fm SO_DOCUMENT_SEND_API1 in ECC 6.

  • Send smartform as pdf attachment through Email on ECC 5.0

    I have been trying hard to do this, but am not able to send attachment. Below are the problems -
    1. If sometimes the mail goes, the attachment is empty.
    2. if i use COMMIT_WORK = 'X' in FM SO_NEW_DOCUMENT_ATT_SEND_API1 , it throws a dump - ' Invalid COMMIT WORK in an update function module.'
    3. If i comment COMMIT_WORK = 'X', it gets executed successfully but, in the program i get a dump 'UC_OBJECTS_NOT_CHAR' exception.
    Can someone suggest, what settings are required in SAP to send smartforms as PDF attachments. Also, please suggest how can i remove the dump. If anyone can give me a working program, it will be very very helpful.
    here is the code,
    REPORT  zrsmfmail.
    TYPE-POOLS: addi.
    Tables defination.
    TABLES : vbpa,vbak,nast, stxl, stxh.
    Data Decleration .
    DATA: lf_fm_name  TYPE rs38l_fnam,
          l_lines TYPE i.
    DATA: output_options TYPE ssfcompop.
    DATA: fcodem TYPE sy-ucomm.
    DATA: i_id LIKE thead-tdid VALUE 'V002',
          i_object LIKE thead-tdobject VALUE 'VBBK' ,
          i_tdname LIKE thead-tdname ,
          i_lang LIKE thead-tdspras VALUE 'E' .
    Internal Table declration.
    DATA: int_vbak LIKE vbak OCCURS 0 WITH HEADER LINE,
          int_vbap LIKE vbap OCCURS 0 WITH HEADER LINE.
    DATA : itline1 LIKE tline OCCURS 0 WITH HEADER LINE .
    DATA: retcode   LIKE sy-subrc.         "Returncode
    DATA: repeat(1) TYPE c.
    DATA: xscreen(1) TYPE c.               "Output on printer or screen
    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,
    lt_att_content_hex 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,
    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.
    DATA: BEGIN OF zlines2 OCCURS 0,
    tline TYPE char255,
    END OF zlines2,
    size TYPE i,
    zdata TYPE sodocchgi1.
    *&      Form  entry
    FORM entry USING return_code TYPE i
                     us_screen TYPE c.
      CLEAR retcode.
      xscreen = us_screen.
      PERFORM processing.
      IF retcode NE 0.
        return_code = 1.
      ELSE.
        return_code = 0.
      ENDIF.
    ENDFORM.                    "ENTRY
    *&      Form  PROCESSING
          text
    FORM processing.
      SELECT *
      INTO   CORRESPONDING FIELDS OF TABLE int_vbak
      FROM   vbak
      WHERE  vbeln = nast-objky.
      LOOP AT int_vbak .
        i_tdname = int_vbak-vbeln .
        SELECT SINGLE * FROM stxh WHERE tdobject = i_object
                                    AND tdname = i_tdname
                                    AND tdid = i_id
                                    AND tdspras = i_lang.
        IF sy-subrc = 0 .
          CALL FUNCTION 'READ_TEXT'
            EXPORTING
              id       = i_id
              language = i_lang
              name     = i_tdname
              object   = i_object
            TABLES
              lines    = itline1.
          IF sy-subrc NE 0 .
            APPEND itline1 .
          ENDIF .
        ENDIF .
        DESCRIBE TABLE int_vbak LINES l_lines.
        l_lines = l_lines .
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
          EXPORTING
            formname           = 'ZORDER_QUOTE'
          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
            l_lines            = l_lines
            control_parameters = w_ctrlop
            output_options     = w_compop
            user_settings      = 'X'
          IMPORTING
            job_output_info    = w_return
          TABLES
            int_vbak           = int_vbak
            int_vbap           = int_vbap
            itline1            = itline1
          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          = size
          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.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    Change the PDF format from 132 to 255.
        CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
          EXPORTING
            transfer_bin = 'X'
          TABLES
            content_in   = i_tline
            content_out  = zlines2
          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 ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    Attachment
        REFRESH:
        i_reclist,
        i_objtxt,
        i_objbin,
        i_objpack.
        CLEAR wa_objhead.
        i_objtxt = 'TEST 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-no_change = 'X'.
        wa_doc_chng-obj_langu = sy-langu.
        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.
    (pdf-Attachment)
        i_objbin[] = zlines2[].
        i_objpack-transf_bin = 'X'.
        i_objpack-head_start = 1.
        i_objpack-head_num = 1.
        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 = 'SMARTFORM'.
        i_objpack-obj_descr = 'TEST'.
        APPEND i_objpack.
        CLEAR i_reclist.
        i_reclist-receiver = 'abc at aa.com'.
        i_reclist-rec_type = 'F'.
        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 = 'X'
        TABLES
          PACKING_LIST = I_OBJPACK
          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.
        CASE sy-subrc.
          WHEN 0.
          WHEN 1. RAISE too_many_receivers.
          WHEN 2. RAISE document_not_sent .
          WHEN 3. RAISE document_type_not_exist.
          WHEN 4. RAISE operation_no_authorization.
          WHEN 5. RAISE parameter_error.
          WHEN 7. RAISE enqueue_error .
          WHEN OTHERS. RAISE x_error.
        ENDCASE.
    COMMIT WORK.
      ENDLOOP.
    ENDFORM.                    "entry
    Please suggest ASAP, it has come to a critical stage now, a fruitful help will be a great saviour.
    Thanks !

    Hi Guys,
    You can even try this 'CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            format                = 'PDF'
          IMPORTING
            bin_filesize          = bin_filesize
            bin_file              = xstring
          TABLES
            otf                   = it_otf_final
            lines                 = it_pdfdata[]
          EXCEPTIONS
            err_max_linewidth     = 1
            err_format            = 2
            err_conv_not_possible = 3
            err_bad_otf           = 4
            OTHERS                = 5.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
          EXPORTING
            buffer                = xstring
          APPEND_TO_TABLE       = ' '
        IMPORTING
          OUTPUT_LENGTH         =
          TABLES
            binary_tab            = it_pdf
    Use Cl_BSC Class for easy way to send mail.
    Either u can Distribution list Tcode so23.
    This is the way i have implemted .. !

  • Send PDF Attachment to SAP Mail Inbox.

    Dear all,
    I have problem please help me out.
    i have to  create an PDF file  with
    my own data and that created PDF file
    i have to send it to SAP mail inbox
    (Transaction code : so01).

    hi sudheer,
    Let the data be populated into ur itab ,
    Now in the code just concentrate on
    Perform fill structure.
    the process u need to do is from ur layout convert from
    itab o/p format itab>OTF/OTF->PDF .
    see the function modules .
    on execution of this a mail will be in ur outbox .
    regards,
    vijay.
    tables : vbak.
    type-pools:slis.
    data: begin of it_t1 occurs 0,
          vbeln like vbak-vbeln,
          erdat like vbak-erdat,
          ernam like vbak-ernam,
          netwr like vbak-netwr,
          waerk like vbak-waerk,
          end of it_t1.
          select-options : so_vbeln for vbak-vbeln.
         DATA :  it_fieldcat TYPE slis_t_fieldcat_alv,
                 it_sort TYPE slis_t_sortinfo_alv,
                 it_listheader TYPE slis_t_listheader,
                 it_alvevent TYPE slis_t_event.
         DATA : wa_fieldcat TYPE slis_fieldcat_alv,
                w_pos TYPE i VALUE 1,
                wa_listheader TYPE slis_listheader,
                wa_alvevent TYPE slis_alv_event,
                wa_sort TYPE slis_sortinfo_alv.
         Data:  it_outtab like it_t1 occurs 0 with header line.
    DATA : MAILREC LIKE SOMLRECI1 occurs 0 WITH HEADER LINE,
           MAILBIN LIKE SOLISTI1 occurs 0 WITH HEADER LINE,
           MAILBIN2 LIKE SOLISTI1 occurs 0 WITH HEADER LINE,
           MAILTXT LIKE SOLISTI1 occurs 0 WITH HEADER LINE,
           MAILHEAD LIKE SOLISTI1 occurs 0 WITH HEADER LINE,
           MAILSTRUC LIKE SOPCKLSTI1 occurs 0 WITH HEADER LINE,
           MAILDATA LIKE SODOCCHGI1 occurs 0 WITH HEADER LINE.
    DATA: BEGIN OF GT_OTF OCCURS 0.
            INCLUDE STRUCTURE ITCOO .
    DATA: END OF GT_OTF.
    DATA: ITCPO LIKE ITCPO,
          ITCPP LIKE ITCPP.
    DATA: tlines type i,
          len_in like SOOD-OBJLEN,
          len_out like SOOD-OBJLEN.
    data: gt_pdf    like solisti1   occurs 0  with header line.
    DATA: gt_otfdata LIKE SOLISTI1 occurs 0 WITH HEADER LINE.
        CONSTANTS: c_formname_top_of_page TYPE slis_formname
                              VALUE 'F_TOP_OF_PAGE'.
    select vbeln
           erdat
           ernam
           netwr
           waerk into corresponding fields of table
           it_outtab from vbak where vbeln in so_vbeln.
          loop at it_t1.
            write:/ it_t1-vbeln,
                    it_t1-erdat,
                    it_t1-ernam,
                    it_t1-netwr,
                    it_t1-waerk.
          endloop.
       perform alv_disp.
    *&      Form  alv_disp
          text
    -->  p1        text
    <--  p2        text
    FORM alv_disp.
    PERFORM build_fcat USING '1' 'VBELN' 'IT_OUTTAB' ' ' ' ' ' '
    'SALESNO'.
      PERFORM build_fcat USING '2' 'ERDAT' 'IT_OUTTAB' ' ' ' ' ' '
    'CRTNDATE'.
    PERFORM build_fcat USING '3' 'ERNAM' 'IT_OUTTAB' ' ' ' ' ' '
    'CRNAME'.
    PERFORM build_fcat USING '4' 'NETWR' 'IT_OUTTAB' ' ' ' ' ' '
    'NETPRICE'.
    PERFORM build_fcat USING '5' 'WAERK' 'IT_OUTTAB' ' ' ' ' ' '
    'CURRENCY'.
    ***Top of Page Heading purpose " u can add the date and column over here
    PERFORM buildtop USING it_listheader[].
    perform top_of_page.
    *------Sort The Catalog
    PERFORM sort_cat  TABLES it_outtab USING it_sort[].
    *------Display Table In GRID
    PERFORM disp_grid TABLES it_outtab[].
    **For email stuff follow the perform
         perform fill_struct.
         CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        DOCUMENT_DATA                    = MAILDATA
        PUT_IN_OUTBOX                    = 'X'
      TABLES
        PACKING_LIST                     = MAILSTRUC
        OBJECT_HEADER                    = MAILHEAD
        CONTENTS_BIN                     = MAILBIN
        CONTENTS_TXT                     = MAILTXT
      CONTENTS_HEX                     =
      OBJECT_PARA                      =
      OBJECT_PARB                      =
        RECEIVERS                        = MAILREC
    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.
    ENDFORM.                    " alv_disp
    *&      Form  build_fcat
          text
         -->P_0104   text
         -->P_0105   text
         -->P_0106   text
         -->P_0107   text
         -->P_0108   text
         -->P_0109   text
         -->P_0110   text
    FORM build_fcat USING     value(col_pos)
                              value(fieldname)
                              value(tabname)
                              value(key)
                              value(no_zero)
                              value(do_sum)
                              value(reptext_ddic).
    CLEAR wa_fieldcat.
      wa_fieldcat-col_pos       = col_pos.
      wa_fieldcat-fieldname     = fieldname.
      wa_fieldcat-tabname       = tabname.
      wa_fieldcat-key           = key.
      wa_fieldcat-no_zero       = no_zero.
      wa_fieldcat-do_sum        = do_sum.
      wa_fieldcat-reptext_ddic  = reptext_ddic.
      APPEND wa_fieldcat TO it_fieldcat.
    ENDFORM.                    " build_fcat
    *&      Form  Top_Of_Page
    Top of page for Grid.
    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                it_list_commentary = it_listheader
                I_LOGO             = 'MY_SAP_ENJOY'.
    ENDFORM.                    "top_of_page
          text
         -->P_IT_LISTHEADER[]  text
    FORM buildtop USING IT_LISTHEADER type slis_t_listheader.
    DATA : text(100) TYPE c.
      CLEAR  it_listheader.
      CLEAR wa_listheader.
      wa_listheader-typ  = 'H'.
      wa_listheader-info = 'Sales Details' .
      APPEND wa_listheader TO it_listheader.
      CLEAR wa_listheader.
      wa_listheader-typ  = 'S'.
      wa_listheader-info =  'Demo'.
      APPEND wa_listheader TO it_listheader.
    *CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
       IT_LIST_COMMENTARY       =  it_listheader
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
    ENDFORM.                    " Top_Of_Page
    *&      Form  sort_cat
          text
         -->P_IT_OUTTAB  text
         -->P_IT_SORT[]  text
    FORM sort_cat TABLES   IT_OUTTAB STRUCTURE  IT_OUTTAB  USING IT_SORT
    TYPE
    slis_t_sortinfo_alv.
    CLEAR wa_sort.
      wa_sort-fieldname       = 'VBELN'.
      wa_sort-tabname         = 'IT_OUTTAB'.
      wa_sort-spos            = 1.
      wa_sort-up              = 'X'.
      wa_sort-subtot          = ' '.
      APPEND wa_sort TO it_sort.
    ENDFORM.                    " sort_cat
    *&      Form  disp_grid
          text
         -->P_IT_OUTTAB[]  text
    FORM disp_grid TABLES  IT_OUTTAB STRUCTURE  IT_OUTTAB.
       CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
           I_CALLBACK_PROGRAM                = 'ZEX2' "sy-repid
           I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
           IT_FIELDCAT                       =  IT_FIELDCAT
          IT_SORT                          =  IT_SORT
         TABLES
           T_OUTTAB                          = IT_OUTTAB
        EXCEPTIONS
          PROGRAM_ERROR                     = 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.
    ENDFORM.                    " disp_grid
    *&      Form  fill_struct
          text
    -->  p1        text
    <--  p2        text
    FORM fill_struct.
    Text
      MOVE 'Hi vijay ' TO MAILTXT-LINE.
      APPEND MAILTXT.
    Data
      MAILDATA-OBJ_NAME = 'Document'.
      MAILDATA-OBJ_DESCR = 'E-maiL From vij'.
      MAILDATA-OBJ_PRIO = '1'.
      MAILDATA-DOC_SIZE = strlen( MAILTXT ).
    Structure
      MAILSTRUC-HEAD_START = 1.
      MAILSTRUC-HEAD_NUM = 0.
      MAILSTRUC-BODY_START = 1.
      MAILSTRUC-BODY_NUM = 1.
      mailstruc-obj_name = 'Vijay Simha'.
      MAILSTRUC-DOC_TYPE = 'RAW'.
      APPEND MAILSTRUC.
    Receivers
    **u can use ur mail id(s) overhere
        MOVE '[email protected]' TO MAILREC-RECEIVER.
        MAILREC-REC_TYPE  = 'U'.
      APPEND MAILREC.
      CLEAR ITCPO.
      ITCPO-TDGETOTF = 'X'.
    ***moving to the output/format of the attachment.
    final pdf format in the mail attachemnt
      LOOP AT it_outtab.
       MOVE it_outtab-vbeln TO MAILBIN.
       MOVE it_outtab-erdat TO MAILBIN+18.
       MOVE it_outtab-ernam TO MAILBIN+40.
      MOVE it_outtab-netwr TO MAILBIN+70.
      MOVE it_outtab-waerk TO MAILBIN+78.
       APPEND MAILBIN.
       CLEAR MAILBIN.
      ENDLOOP.
    **convert the scrap to otf.
    CALL FUNCTION 'SX_OBJECT_CONVERT_SCR_OTF'
      EXPORTING
        format_src            = 'RAW'
        format_dst            = 'OTF'
        devtype               = 'POSTSCPT'
        funcpara              = ' '
        len_in                = LEN_IN
    IMPORTING
       LEN_OUT               =  LEN_OUT
      tables
        content_in            = MAILBIN
        content_out           = MAILBIN2
    EXCEPTIONS
      ERR_CONV_FAILED       = 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.
    REFRESH MAILBIN.
    CONVERT OTF to PDF
      CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
        EXPORTING
          FORMAT_SRC            = 'OTF'
          FORMAT_DST            = 'PDF'
          DEVTYPE               = 'POSTSCPT'
      FUNCPARA              =
          LEN_IN                = LEN_IN
        IMPORTING
          LEN_OUT               = LEN_OUT
        TABLES
          CONTENT_IN            = MAILBIN2
          CONTENT_OUT           = MAILBIN
    EXCEPTIONS
      ERR_CONV_FAILED       = 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.
    REFRESH MAILBIN2.
    DESCRIBE TABLE MAILBIN LINES TLINES.
    Structure
      MAILSTRUC-HEAD_START = 1.
      MAILSTRUC-HEAD_NUM = 1.
      MAILSTRUC-BODY_START = 1.
      MAILSTRUC-BODY_NUM = TLINES.
      MAILSTRUC-TRANSF_BIN = 'X'.
      MAILSTRUC-DOC_TYPE = 'PDF'.
    MAILSTRUC-DOC_TYPE = 'XLS'.
      mailstruc-obj_name = 'Vijay.S.Reddy'.
      MAILSTRUC-DOC_SIZE = tlines * 255.
      APPEND MAILSTRUC.
    ENDFORM.                    " fill_struct

  • Can I edit an Adobe Acrobat .pdf attachment in Mac Mail before I hit send?

    I have numerous .pdf approval sheets that I attach to a client’s ad in order for each client to approve, sign and fax back to me. I have many different .pdfs made up with only different counties the client will advertise in already in the .pdf. Now the publisher wants the name of each client to appear on each sheet (I have 130 clients). Is there a way of editing the text (to add client name) in .pdf attachment before hitting send in Mac Mail? I don’t want to have to redo so many different .pdf approval sheets each time in order to keep changing just client’s name on the .pdf.
    Thanks,
    Mickie
    Here’s what the body looks like:
    Client  ___________________________________________________
    County     PALM BEACH_______________________________________________
    Signature  _________________________________________________
    Date  ______________________________________________________

    You can only edit PDF file in PDF editor, If you are using Adobe Acrobat PDF editor then follow this video tutorial to know how to edit PDF file?

  • Sending smartforms as PDF attachement via e mail

    Hello all:
    I have configured PPF actions to send smartforms as PDF attchment via e mail it works fine in one client.
    But when I copied the transport to another client, the entries in field 'Recipient' in the configuration step 'Define Conditions and Output Parameters for Comm. of Cust.Shipm. & Cust.Dcl'  are not copied to the new client. I had maintained the name of the inbox folder that has e mail addresses in this field. Any one has a similar issue ? Or is this similar to the number ranges and not transportable and we have to maintain them in every client. Any insight into this very much appreciated.

    Hello:
    If you want to send the smartform as a PDF attachment, configure your PPF action as described below:
    Step 1: Define Techn. Medium for Msgs (PPF Actions) f. Cust. Shipm. and Cust. Decl.
                In the action definition, choose processing type as 'External Communication'
                                                             form type:  'Smart Forms'
                                                             format: /SAPSLL/FORM_PROC
                                                             personalization type: 2 object specific....
                Make this action definition partner function dependent and create a Z partner function. Maintain that  
                partner function in this definition.
    Step 2: Define Conditions and Output Parameters for Comm. of Cust.Shipm. & Cust.Dcl
                Select Communication Method: Internet Mail
                          Mail Settings: send status: 3
    Configure the reamaining PFF actions as usual.
    This will work if that configured partner function is maintained in the customs declaration. And for that business partner, maintain the e mail address in the address dependent section via txn BP.

  • Change Font Size with PDF attachment  via e--mail

    Hi experts,
    I want to send mail with PDF attachment . Now the attachment is ok but only the font size in PDF is a little small.
    Is that possible to Change the font size of PDF
    Below is my code:
    first the data comes from an internal table, then changed to an ABAP Pool.
    * Create a new spool from the data in gt_data_pdf
      new-page print on
      destination c_local               "<<== my printer
      cover text text-027               "<<== Title or Spool req. name
      list name space
      list dataset space
      immediately space                 " X means print now
      keep in spool c_checked           " X means keep spool
      new list identification c_checked
      line-size 255
      line-count 65
      no dialog .
      loop at gt_data_pdf.
        write: / gt_data_pdf-line.
      endloop.
      new-page print off.
      lv_spoolid = lv_spdel-rqident = sy-spono.
      lv_spdel-sys = sy-sysid.
    *Convert ABAP Spool to PDF
      call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
        exporting
          src_spoolid   = lv_spoolid
          no_dialog     = c_checked
        importing
          pdf_bytecount = lv_pdf_fsize
        tables
          pdf           = lt_pdf_table
        exceptions
          others        = 0.
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        exporting
          document_data              = lv_doc_chng
          put_in_outbox              = space
          commit_work                = c_checked
        tables
          packing_list               = lt_objpack
          object_header              = lt_objhead
          contents_bin               = lt_objbin
          contents_txt               = lt_objtxt
          receivers                  = lt_reclist
        exceptions
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          others                     = 99.
    Anyone could help me?
    Thanks a lot.
    Sincerely
    Julie

    Hi,
    we don´t have many options for setting the font type and size in an ABAP list. One option is that you print the output using either SmartForms or AdobeForms, where you can control font type as well as size. This one requires additional work.
    Another option is to use the instruction Print-Control:
    NEW-PAGE PRINT ON.
    PRINT-CONTROL FONT 1 SIZE 1 LPI 6 CPI 10.
    WRITE: /10   'FONT 1 size 1 LPI 6 cpi 10'.
    SKIP.
    PRINT-CONTROL FONT 1 SIZE 5 LPI 6 CPI 5.
    WRITE: /10   'FONT 1 size 5 LPI 6 cpi 5'.
    SKIP.
    PRINT-CONTROL FONT 2 SIZE 5 LPI 6 CPI 10.
    WRITE: /10   'FONT 2 size 5 LPI 6 cpi 10'.
    SKIP.
    NEW-PAGE PRINT OFF.

  • Conversion SAPSCRIPT to PDF and send per mail

    Hi all,
    I would like to send a sapscript per mail as PDF attachment. I checked on the forum and followed some threads for that, but I still have a problem :
    - I'm using the open_form function with ITCPO-TDGETOTF = 'X'
    - in the CLOSE_FORM i get the OTF data in the internal table it_otf
    CALL FUNCTION 'CLOSE_FORM'
    TABLES
       OTFDATA                        = it_otf
    - than I'm using the function: (it_otf as input it_pdf as output table): 
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
       FORMAT                      = 'PDF'
       MAX_LINEWIDTH               = 132
        PDF_DELETE_OTFTAB           = 'X'
    IMPORTING
        BIN_FILESIZE                = W_bin_filesize
        BIN_FILE                    = g_binfile
      TABLES
        OTF                         = it_otf
        LINES                       = it_pdf
    this function dumps with the message : "*255" nicht als Zahl interpretierbar
    what' wrong ?
    thank you in advance for your help.

    Hi Fred,
    I'm with this issue and doing exactly what you said, but it is not working.
    Below my code. Is it missing something?
    1 - tb_otf is retrieving the correct values.
    CALL FUNCTION 'CLOSE_FORM'
           IMPORTING
             RESULT  = RESULT
           tables
             otfdata = tb_otf.
    2 - c_binfile is populated correctly but nothing happens with table lt_otf 
    CALL FUNCTION 'CONVERT_OTF'
         EXPORTING
           FORMAT                      = 'PDF'
           MAX_LINEWIDTH               = 132
           PDF_DELETE_OTFTAB           = ' '
         IMPORTING
           BIN_FILESIZE                = L_SIZE
           BIN_FILE                    = c_binfile
         TABLES
           OTF                         = tb_otf
           LINES                       = lt_otf.
    3 - lt_solix is populated correctly
    DATA : BEGIN OF lt_solix OCCURS 0,
             line TYPE x LENGTH 255,
             END OF lt_solix.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
       EXPORTING
         buffer                = c_binfile
       TABLES
         binary_tab            = lt_solix.
    4 - data packing all right
    *   E-mail body
        CLEAR lt_packing_list.
        REFRESH lt_packing_list.
        lt_packing_list-transf_bin = ''.
        lt_packing_list-head_start = 1.
        lt_packing_list-head_num   = 0.
        lt_packing_list-body_start = 1.
        lt_packing_list-body_num   = l_numbytes.
        lt_packing_list-doc_type   = 'RAW'.
        lt_packing_list-obj_name   = 'BODY'.
        lt_packing_list-obj_descr  = 'CORPO'.
        lt_packing_list-doc_size   = l_numbytes.
        APPEND lt_packing_list.
    *   E-mail attachment
        lt_packing_list-transf_bin = 'X'.
        lt_packing_list-head_start = 1.
        lt_packing_list-head_num   = 0.
        lt_packing_list-body_start = 1.
        lt_packing_list-body_num   = l_numbytes.
        lt_packing_list-doc_type   = 'PDF'.
        lt_packing_list-obj_descr  = nast-objky.
        lt_packing_list-obj_name   = 'PICTURE'.
        lt_packing_list-doc_size   = l_numbytes.
        APPEND lt_packing_list.
    5 - send e-mail
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
             document_data              = wa_document_data
             put_in_outbox              = 'X'
            commit_work                = 'X'
          TABLES
            packing_list               = lt_packing_list
            object_header              = lt_object_header
    *        contents_bin               = lt_objbin
    contents_HEX = lt_solix
            contents_txt               = lt_contents_txt
            receivers                  = lt_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.
    When I check SOST transaction I see the e-mail but the body content I cant see and the attachment I cant open.
    The same logic was working in version 5.0 (now we're in 6.0). But it was using content_bin parameter which is obsolete now, from now we need to use to content_hex parameter.
    Please, could you help me?
    Thanks

  • Smartform as PDF attachment to a mail.

    Hi,
    Can anyonce briefly explain me how the output of a smartform can be attached as a PDF file to a mail.
    Ques 1: Do we need to pass any explicit value to the smart form generated function module.  If so, what is the value and to which parameter do we need to pass.
    Ques 2: As far as i know OTF is converted to PDF. If this is so please explain how this is  done.
    Ques 3: How can a PDF document be made as an attachment, to a mail.
    If anyone can provide me an example it would be very great.
    Thanks & Regards,
    Goutham.

    Hi,
    Go through the following code:
    REPORT  z_smtf_pdf_and_email_aks01.
    DATA: x_ctrl_p       TYPE ssfctrlop,
          x_output_data  TYPE ssfcrescl.
    DATA: it_docs    LIKE docs       OCCURS 0 WITH HEADER LINE,
          it_lines   LIKE tline      OCCURS 0 WITH HEADER LINE,
          it_packing LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
    *-----Initialisation
    x_ctrl_p-no_dialog = 'X'.
    x_ctrl_p-getotf    = 'X'.
    x_ctrl_p-langu     = sy-langu.
              Internal Tables  Declaration                              *
    DATA: it_record    LIKE solisti1   OCCURS 0 WITH HEADER LINE,
          it_pcklist   LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
          it_mess      LIKE solisti1   OCCURS 0 WITH HEADER LINE,
          it_objbin    LIKE solisti1   OCCURS 0 WITH HEADER LINE,
          it_receivers LIKE somlreci1  OCCURS 0 WITH HEADER LINE,
          it_table     LIKE solix      OCCURS 0 WITH HEADER LINE.
    DATA: it_soli      LIKE soli OCCURS 0 WITH HEADER LINE.
    *-----Work area declaration
    DATA: wa_doc_data  TYPE  sodocchgi1.
              Variable  Declaration                                     *
    DATA: v_lines_txt  TYPE  i,
          v_lines_bin  TYPE  i,
          v_lines      TYPE  i,
          v_fname TYPE rs38l_fnam,
          v_size TYPE i,
          v_filename TYPE rlgrap-filename.
              Start of selection event                                  *
    START-OF-SELECTION.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname = 'Z_SMTF_TEST_AKS01'
        IMPORTING
          fm_name  = v_fname.
      CALL FUNCTION v_fname
        EXPORTING
          control_parameters = x_ctrl_p
        IMPORTING
          job_output_info    = x_output_data.
    *-----Calling fumction module to convert output to pdf.
    CALL FUNCTION 'CONVERT_OTF_2_PDF'
       IMPORTING
         bin_filesize   = v_size
       TABLES
         otf            = x_output_data-otfdata
         doctab_archive = it_docs
         lines          = it_lines.
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
          max_linewidth         = 134
        IMPORTING
          bin_filesize          = v_size
        TABLES
          otf                   = x_output_data-otfdata
          lines                 = it_lines
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          OTHERS                = 4.
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
        EXPORTING
          line_width_dst              = 255
        TABLES
          content_in                  = it_lines
          content_out                 = it_soli
        EXCEPTIONS
          err_line_width_src_too_long = 1
          err_line_width_dst_too_long = 2
          err_conv_failed             = 3
          OTHERS                      = 4.
      CALL FUNCTION 'ZFUNC_CONVERT_DATA_ODC01'
       EXPORTING
         iv_byte_mode       = 'X'
       TABLES
         it_data            = it_lines
         et_data            = it_table.
    *-----To caluculate total number of lines of internal table
      DESCRIBE TABLE it_table LINES v_lines.
    *-----Function module to download the output file.
      CALL FUNCTION 'DOWNLOAD'
        EXPORTING
          bin_filesize = v_size
          filename     = ' '
          filetype     = 'BIN'
        IMPORTING
          act_filename = v_filename
        TABLES
          data_tab     = it_lines.
    *-----Create Message Body and Title and Description
      it_mess =
    'i have successfully converted smartform from otf format to pdf' .
      " and i have attached that in mail'.
      APPEND it_mess.
      wa_doc_data-obj_name   = 'smartform'.
      wa_doc_data-expiry_dat = sy-datum + 10.
      wa_doc_data-obj_descr  = 'smartform'.
      wa_doc_data-sensitivty = 'F'.
      wa_doc_data-doc_size   = v_lines * 255.
      APPEND it_pcklist.
    *-----PDF Attachment
      it_pcklist-transf_bin = 'X'.
      it_pcklist-head_start = 1.
      it_pcklist-head_num = 0.
      it_pcklist-body_start = 1.
      it_pcklist-doc_size =  v_lines_bin * 255 .
      it_pcklist-body_num = v_lines.
      it_pcklist-doc_type = 'PDF'.
      it_pcklist-obj_name = 'smartform'.
      it_pcklist-obj_descr = 'smart_desc'.
      it_pcklist-obj_langu  = 'E'.
      it_pcklist-doc_size   = v_lines * 255.
      APPEND it_pcklist.
    *-----Giving the receiver email-id
      CLEAR it_receivers.
      it_receivers-receiver = '[email protected]'
      it_receivers-rec_type = 'U'.
      APPEND it_receivers.
      CLEAR it_receivers.
      it_receivers-receiver = '[email protected]'.
      it_receivers-rec_type = 'U'.
      APPEND it_receivers.
      CLEAR it_receivers.
      it_receivers-receiver = '[email protected]'.
      it_receivers-rec_type = 'U'.
      APPEND it_receivers.
    *-----Calling the function module to sending email
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = wa_doc_data
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = it_pcklist
          contents_txt               = it_mess
          contents_hex               = it_table
          receivers                  = it_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.
      IF sy-subrc = 0.
        SUBMIT rsconn01   WITH mode       = 'INT'
                          WITH output     = 'X'
                          WITH rfcgroup   = 'iwdf7ytc_YD3_94'
                          AND RETURN.
        REFRESH: it_receivers,
                 it_mess,
                 it_pcklist.
      ENDIF.
    Reward points if helpful answer.
    Ashvender

  • Create pdf attachment to the mail

    Hi folks,
    My requirement is to attach pdf document to the mail step in workflow programatically and document is on presentation server.
         i have tried with SOFM object type, but it is asking for document number , but i could not  provide it because it is not in SAP system.
       how to acheive this.
    Thanks, 
    janakiram.

    try this  copy and paste is and make changes as required
    Enjoy.............
    To create pdf from internal table.
    Two steps
    1. get spool no.
    2. create pdf.
    1. get spool no.
    SELECT *
      FROM zwftrack
      INTO TABLE it_zwftrack
    WHERE wf_id = p_wf_id
       AND action = 'FYA'.
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING destination            = 'LP01'               " 'LT50'
                  copies                 =  1
                  list_name              = g_rq2name
                  list_text              = 'COMM-PDF NEW-PAGE PRINT ON'
                  immediately            = ' '
                  release                = ' '
                  new_list_id            = 'X'
                  expiration             = g_days
                  line_size              = g_ln_size              " 255 ZTG12
                  line_count             = g_ln_count             " 65 ZTG12
                  layout                 = g_layout " 'X_PAPER'ZTG12
                 SAP_COVER_PAGE         = 'X'
                 RECEIVER               = 'SAP*'
                 DEPARTMENT             = 'System'
                 SAP_OBJECT             = 'RS'
                 AR_OBJECT              = 'TEST'
                 ARCHIVE_ID             = 'XX'
                 ARCHIVE_INFO           = 'III'
                 ARCHIVE_TEXT           = 'Description'
                  no_dialog              = 'X'
        IMPORTING out_parameters         = g_params
                  out_archive_parameters = g_arparams
                  valid                  = g_valid.
    "end of get
      NEW-PAGE PRINT ON
                        NEW-SECTION
                        NO-TITLE
                        PARAMETERS g_params
                        ARCHIVE PARAMETERS g_arparams
                  NO DIALOG.
    ***add at top of comments list
    WRITE:/ 'Contract Analysis Worksheet', 150 'Current Data ( ', l_date, ' ', l_time, ' )'.
    WRITE:/150 'Run # :', wa_zzbedsheet-bdshnum.
    WRITE:/ 'Project ID      :',g_object_no.
    WRITE:/ 'Project         :',g_psr_desc.
    WRITE:/ 'Profit Center   :',g_prctr.
    WRITE:/ 'Project Manager :',g_final_abb_contact.
    WRITE:/ 'RA key          :',g_abgsl.
    WRITE:/ 'Customer        :',l_cust.
    WRITE:/ 'Project Start   :',l_proj_start.
    SKIP 3.
    SORT it_zwftrack BY approver_level.
      LOOP AT it_zwftrack INTO wa_zwftrack.
        AT FIRST.
    WRITE:/ 'Approvers Comments:'.
    SKIP 1.
    WRITE:/1 'Role', 35 'Approved By', 50 'Signature', 75 'Comments'.
    ULINE.
    ENDAT.
        IF wa_zwftrack IS INITIAL.
          SKIP.
        ELSE.
    PERFORM f_get_name USING    wa_zwftrack-approved_by
                       CHANGING g_final_abb_contact.
          WRITE :/ wa_zwftrack-role UNDER 'Role',
                   g_final_abb_contact UNDER 'Approved By',
                   wa_zwftrack-signature UNDER 'Signature',
                   wa_zwftrack-comments UNDER 'Comments'.
        ENDIF.
        CLEAR: g_final_abb_contact.
    insert page break
        IF sy-tabix = w_lines  .
          NEW-PAGE .
        w_lines = 2 * w_lines.
        ENDIF.
      ENDLOOP.
        NEW-PAGE PRINT OFF .
    CLEAR w_tsp01.
    SELECT SINGLE *
      FROM tsp01
      INTO w_tsp01
    WHERE rqowner = sy-uname
       AND rq2name = g_rq2name.        "'COMM-PDF' .
    g_spool_comm = w_tsp01-rqident.
    2. create pdf
        CLEAR g_lines .
        REFRESH it_tab1 .
    ****get comments page from spool
        CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
          EXPORTING
            rqident              = g_spool_comm                      "spool1
          TABLES
            buffer               = it_tab1
          EXCEPTIONS
            no_such_job          = 1
            job_contains_no_data = 2
            selection_empty      = 3
            no_permission        = 4
            can_not_access       = 5
            read_error           = 6
            OTHERS               = 8.
        IF sy-subrc = 0.
        ENDIF.
    to record line no  for page break .
        DESCRIBE TABLE it_tab1 LINES g_lines.
        MOVE g_lines TO wa_eof-line .
        APPEND  wa_eof TO it_eof .
        CLEAR g_lines .
        APPEND LINES OF it_tab1 TO it_tab.
        REFRESH it_tab1 .
    SELECT SINGLE spld INTO w_spld FROM usr01 WHERE bname = sy-uname.
    SHIFT g_wf_id LEFT DELETING LEADING '0'.
    CONCATENATE g_wf_id '-ONEPDF' INTO g_list_name.
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING destination            = w_spld               " 'LT50'
                  copies                 =  1
                  list_name              = g_list_name
                  list_text              = 'PM-PDF NEW-PAGE PRINT ON'
                  immediately            = ' '
                  release                = ' '
                  new_list_id            = 'X'
                  expiration             = g_days
                  line_size              = g_ln_size              " 255 ZTG12
                  line_count             = g_ln_count             " 65 ZTG12
                  layout                 = g_layout " 'X_PAPER'ZTG12
                 SAP_COVER_PAGE         = 'X'
                 RECEIVER               = 'SAP*'
                 DEPARTMENT             = 'System'
                 SAP_OBJECT             = 'RS'
                 AR_OBJECT              = 'TEST'
                 ARCHIVE_ID             = 'XX'
                 ARCHIVE_INFO           = 'III'
                 ARCHIVE_TEXT           = 'Description'
                  no_dialog              = 'X'
        IMPORTING out_parameters         = g_params
                  out_archive_parameters = g_arparams
                  valid                  = g_valid.
      NEW-PAGE PRINT ON
                      NEW-SECTION
                      NO-TITLE
                      PARAMETERS g_params
                      ARCHIVE PARAMETERS g_arparams
               NO DIALOG.
      w_idx =  1 . " for reading EOF line no .
      w_tabix  = 0  .
      READ TABLE it_eof INTO wa_eof INDEX w_idx .
      MOVE  wa_eof-line TO g_lines .
      w_lines = w_tabix + g_lines .
      DATA: w_linestr LIKE sy-tabix .                           "#EC NEEDED
      LOOP AT it_tab INTO wa_tab.
        IF wa_tab-line CP   'Current Budget'  .
          w_linestr  =  sy-tabix .
        ENDIF .
        IF wa_tab IS INITIAL OR wa_tab-line CA '?' .        " ZTG15
          SKIP  .                                               " ZTG15
        ELSE .   " ZTXX
          WRITE /  wa_tab  .
        ENDIF .                                                 " ZTG15
    insert page break
        IF sy-tabix = w_lines  .
          NEW-PAGE .
          w_idx = w_idx + 1 .
          w_tabix =  sy-tabix + w_tabix .
          READ TABLE it_eof INTO wa_eof INDEX w_idx .
          MOVE  wa_eof-line TO g_lines .
          w_lines = w_tabix + g_lines .
          CLEAR: w_tabix.
        ENDIF .
      ENDLOOP .
      NEW-PAGE PRINT OFF .
      CLEAR w_tsp01.
    SELECT * INTO TABLE t_tsp01 FROM tsp01
      WHERE rqowner = sy-uname
      AND rq2name = g_list_name .
    IF sy-subrc = 0  .
       SORT t_tsp01 BY rqcretime DESCENDING . "RBE24 rqident DESCENDING .
    ENDIF .
    READ TABLE t_tsp01 INTO W_TSP01 INDEX 1 .
    CLEAR w_tsp01.
    SELECT SINGLE *
      FROM tsp01
      INTO w_tsp01
    WHERE rqowner = sy-uname
       AND rq2name = g_list_name.        "'COMM-PDF' .
      WHILE  g_numbytes  = 0 .
        CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
            EXPORTING
              src_spoolid                    = w_tsp01-rqident  "spoolno
              no_dialog                      = ' '
          DST_DEVICE                     =
          PDF_DESTINATION                =
            IMPORTING
              pdf_bytecount                  = g_numbytes
              pdf_spoolid                    = g_pdfspoolid
          LIST_PAGECOUNT                 =
              btc_jobname                    = g_jobname
              btc_jobcount                   = g_jobcount
            TABLES
              pdf                            = it_pdf
            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.
      ENDWHILE.
    **DATA : DATA_TAB TYPE TABLE.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
         bin_filesize                    = g_numbytes
          filename                        = g_lv_file
         filetype                        = 'BIN'
       IMPORTING
         filelength                      = g_numbytes
        TABLES
          data_tab                        = it_pdf
      FIELDNAMES                      =
       EXCEPTIONS
         file_write_error                = 1
         no_batch                        = 2
         gui_refuse_filetransfer         = 3
         invalid_type                    = 4
         no_authority                    = 5
         unknown_error                   = 6
         header_not_allowed              = 7
         separator_not_allowed           = 8
         filesize_not_allowed            = 9
         header_too_long                 = 10
         dp_error_create                 = 11
         dp_error_send                   = 12
         dp_error_write                  = 13
         unknown_dp_error                = 14
         access_denied                   = 15
         dp_out_of_memory                = 16
         disk_full                       = 17
         dp_timeout                      = 18
         file_not_found                  = 19
         dataprovider_exception          = 20
         control_flush_error             = 21
         OTHERS                          = 22
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    report ZTEST12345678.
    tables:
    tsp01.
    *STRUCTURES
    parameters:
    p_repid like sy-repid, " Report to execute
    p_linsz like sy-linsz default 255, " Line size
    p_paart like sy-paart default 'X_65_132'. " Paper Format
    data:
    mstr_print_parms like pri_params,
    mc_valid(1) type c,
    mi_bytecount type i,
    mi_length type i,
    mi_rqident like tsp01-rqident.
    *INTERNAL TABLES
    data:
    mtab_pdf like tline occurs 0 with header line,
    mc_filename TYPE string.
    *----Data for Mail
    DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
    DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
    DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
    DATA: DOC_CHNG LIKE SODOCCHGI1.
    DATA: TAB_LINES LIKE SY-TABIX.
    DATA: V_MAILID(241) TYPE C .
    DATA: BEGIN OF DATA_TAB OCCURS 20,
    LINE(255),
    END OF DATA_TAB.
    start-of-selection.
    concatenate 'c:\abap\'
    p_repid
    '.pdf'
    into mc_filename.
    *Setup the Print Parmaters
    call function 'GET_PRINT_PARAMETERS'
    exporting
    authority = space
    copies = '1'
    cover_page = space
    data_set = space
    department = space
    destination = space
    expiration = '1'
    immediately = space
    *in_archive_parameters = space
    *in_parameters = space
    layout = space
    mode = space
    new_list_id = 'X'
    no_dialog = 'X'
    user = sy-uname
    importing
    out_parameters = mstr_print_parms
    valid = mc_valid
    exceptions
    archive_info_not_found = 1
    invalid_print_params = 2
    invalid_archive_params = 3
    others = 4.
    *Make sure that a printer destination has been set up
    *If this is not done the PDF function module ABENDS
    if mstr_print_parms-pdest = space.
    mstr_print_parms-pdest = 'LP01'.
    endif.
    *Explicitly set line width, and output format so that
    *the PDF conversion comes out OK
    mstr_print_parms-linsz = p_linsz.
    mstr_print_parms-paart = p_paart.
    submit (p_repid) to sap-spool without spool dynpro
    spool parameters mstr_print_parms
    via selection-screen
    and return.
    CALL FUNCTION 'ENQUE_SLEEP'
    EXPORTING
    seconds = 2.
    *Find out what the spool number is that was just created
    P_REPID = SY-REPID.
    perform get_spool_number using p_repid sy-uname
    changing mi_rqident.
    *Convert Spool to PDF
    call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
    exporting
    src_spoolid = mi_rqident
    no_dialog = space
    dst_device = mstr_print_parms-pdest
    importing
    pdf_bytecount = mi_bytecount
    tables
    pdf = mtab_pdf
    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.
    perform create_mail_data.
    PERFORM SEND_MAIL.
    *FORM get_spool_number
    *Get the most recent spool created by user/report *
    *--> F_REPID *
    *--> F_UNAME *
    *--> F_RQIDENT *
    form get_spool_number using f_repid
    f_uname changing f_rqident.
    data: lc_rq2name like tsp01-rq2name.
    concatenate f_repid+0(8)
    f_uname+0(3)
    into lc_rq2name separated by '_'.
    concatenate f_repid+0(9)
    f_uname+0(3)
    into lc_rq2name.
    select * from tsp01 where rq2name = lc_rq2name
    order by rqcretime descending.
    f_rqident = tsp01-rqident.
    exit.
    endselect.
    if sy-subrc ne 0.
    clear f_rqident.
    endif.
    endform." get_spool_number
    **& Form create_mail_data
    form create_mail_data.
    *Creation of the document to be sent
    DOC_CHNG-OBJ_NAME = 'TEST MAIL ATTACHMENTS'.
    DOC_CHNG-OBJ_DESCR = 'Test for PDF'.
    OBJTXT = 'Contents of mail'.
    APPEND OBJTXT.
    OBJTXT = 'PDF'.
    APPEND OBJTXT.
    OBJTXT = 'PDF'.
    APPEND OBJTXT.
    DESCRIBE TABLE OBJTXT LINES TAB_LINES.
    READ TABLE OBJTXT INDEX TAB_LINES.
    DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    *Creation of the entry for the compressed document
    CLEAR OBJPACK-TRANSF_BIN.
    OBJPACK-HEAD_START = 1.
    OBJPACK-HEAD_NUM = 0.
    OBJPACK-BODY_START = 1.
    OBJPACK-BODY_NUM = TAB_LINES.
    OBJPACK-DOC_TYPE = 'RAW'.
    APPEND OBJPACK.
    *-DOWNLOADING AND AGAIN UPLOADINGIN BIN FORMAT TO TRANSFER TO OBJBIN
    *MC_FILENAME = 'c:\test.doc' .
    *--pdf--
    *MC_FILENAME = 'c:\test.pdf'.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
       BIN_FILESIZE                    = MI_BYTECOUNT
        filename                        = MC_FILENAME
       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                      = ' '
      WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
      SHOW_TRANSFER_STATUS            = ABAP_TRUE
    IMPORTING
      FILELENGTH                      =
      tables
        data_tab                        = MTAB_PDF[]
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    *CALL FUNCTION 'GUI_DOWNLOAD'
    *EXPORTING
    *BIN_FILESIZE = MI_BYTECOUNT
    *FILENAME = MC_FILENAME
    *FILETYPE = 'BIN'
    *TABLES
    *DATA_TAB = MTAB_PDF
    *EXCEPTIONS
    *FILE_OPEN_ERROR = 1
    *FILE_WRITE_ERROR = 2
    *INVALID_FILESIZE = 3
    *INVALID_TYPE = 4
    *NO_BATCH = 5
    *UNKNOWN_ERROR = 6
    *INVALID_TABLE_WIDTH = 7
    *GUI_REFUSE_FILETRANSFER = 8
    *CUSTOMER_ERROR = 9
    *OTHERS = 10.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = MC_FILENAME
       FILETYPE                      = 'BIN'
      HAS_FIELD_SEPARATOR           = ' '
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      tables
        data_tab                      = OBJBIN
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    *CALL FUNCTION 'GUI_UPLOAD'
    *EXPORTING
    *FILENAME = MC_FILENAME
    *FILETYPE = 'BIN'
    *TABLES
    *DATA_TAB = OBJBIN.
    *--uncommnet this for pdf--
    DESCRIBE TABLE OBJBIN LINES TAB_LINES.
    OBJHEAD = 'TEST.pdf'. APPEND OBJHEAD.
    *Creation of the entry for the compressed attachment
    OBJPACK-TRANSF_BIN = 'X'.
    OBJPACK-HEAD_START = 1.
    OBJPACK-HEAD_NUM = 1.
    OBJPACK-BODY_START = 1.
    OBJPACK-BODY_NUM = TAB_LINES.
    OBJPACK-DOC_TYPE = 'PDF'.
    OBJPACK-OBJ_NAME = 'Testing PDF Attachment'.
    OBJPACK-OBJ_DESCR = 'Customes Ageing report PDF Output Attachment'.
    OBJPACK-DOC_SIZE = TAB_LINES * 255.
    APPEND OBJPACK.
    CLEAR V_MAILID.
    V_MAILID = <mail id>.
    RECLIST-RECEIVER = V_MAILID.
    RECLIST-REC_TYPE = 'U'.  "B for SAP Inbox
    APPEND RECLIST.
    endform. " create_mail_data
    **& Form SEND_MAIL
    form SEND_MAIL.
    Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = DOC_CHNG
    PUT_IN_OUTBOX = 'X'
    commit_work = 'X'
    TABLES
    PACKING_LIST = OBJPACK
    OBJECT_HEADER = OBJHEAD
    CONTENTS_BIN = OBJBIN
    CONTENTS_TXT = OBJTXT
    RECEIVERS = RECLIST
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    OPERATION_NO_AUTHORIZATION = 4
    OTHERS = 99.
    *EXCEPTION HANDLING
    CASE SY-SUBRC.
    WHEN 0.
    WRITE: / 'Mail sent with attachment'.
    WHEN 1.
    WRITE: / 'No authorization for sending to the specified number',
    'of recipients'.
    WHEN 2.
    WRITE: / 'Document could not be sent to any recipient'.
    WHEN 4.
    WRITE: / 'No send authorization'.
    WHEN OTHERS.
    WRITE: / 'Error occurred while sending'.
    ENDCASE.
    endform. " SEND_MAIL

Maybe you are looking for

  • How can I get rid of the duplicate entries in icalendar?

    How can I get rid of the duplicate entries in icalendar?

  • How can i put my ipod on my pc

    my wife already has her ipod on our pc & i am afraid i will corrupt her songs & end up with me being divorced So my question is how do i put on 2 ipods without conflict please

  • Why won't mpeg files work in FCP 7?

    I was given mpeg movie files (codecs: MPEG-2 Video, MPEG Layer 3) to edit in FCP 7. I tried opening them up in FCP but it woldn't play. So I decided to convert the files in MPEG STREAMCLIP to Apple ProRes 422. Now when I import it into Final cut, I c

  • Oracle Installed failed

    I am trying to install Oracle database on Linux and install failed with the following error: genclntsh: genclntsh: Could not locate /oracle/product/10g/network/admin/shrept.lst *** Error exit code 1

  • Undo Personalization

    Hello, I created a query with several variable selection for dates and once I entered those date values, I hit Personalize all Variables on the variable screen.  And, I copied this query to different sheets in a workbook.  But, now when I want to ref