How to send SD Invioce by email to customer?

Hello friends,
Since every day we need to spend 4 hours to collect invoice(SD) and send it by outlook manually, lot of time is wasted.
Requirement: when invoice (SD) is processing, or when invoice is saved, the invoice is converted to a pdf file and send it to the creater automaticlly, then the creater can edit and review the email, then creater sends the email to customer.
Could you please give me some suggestion or solution?
Thank you very much.
If really helpful, lots points will be given. Thanks again.

just take this example code and try to understand the scenario of converting the otf to pdf and then attaching the document in pdf format .
REPORT zmail2 LINE-SIZE 250 LINE-COUNT 250 .
TABLES : vbap.
SELECT-OPTIONS: s_vbeln FOR vbap-vbeln.
DATA : BEGIN OF itab_data OCCURS 1,
       vbeln LIKE vbap-vbeln,
       posnr LIKE vbap-posnr,
       matnr LIKE vbap-matnr,
       END OF itab_data.
DATA : v_date LIKE sy-datum.
DATA: tlines type i,
      len_in like SOOD-OBJLEN,
      len_out like SOOD-OBJLEN.
SELECT vbeln posnr matnr
       FROM vbap
       INTO TABLE itab_data
       WHERE vbeln IN s_vbeln.
PERFORM send_mail.
*       FORM SEND_MAIL                                                *
FORM send_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: objbin2    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.
* Creation of the document to be sent
* File Name
  doc_chng-obj_name = 'MAIL'.
* Mail Subject
  doc_chng-obj_descr = 'Mail Has Been Delivered'.
* Mail Contents
  objtxt = 'Check the orders along with the material numbers'.
  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 = 'XLS'.
  objpack-doc_type = 'PDF'.
  APPEND objpack.
* Creation of the document attachment
  LOOP AT itab_data.
  move itab_data-vbeln to objbin .
  move itab_data-posnr to objbin+18 .
  move itab_data-matnr to objbin+40.
  append objbin.
  clear objbin.
  ENDLOOP.
*CONVERT the output of itab from raw to OTf format.
  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            = OBJBIN
      content_out           = OBJBIN2
   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.
**convert the format from 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            = OBJBIN2
    content_out           = OBJBIN
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 OBJBIN2.
  DESCRIBE TABLE objbin LINES tab_lines.
  objhead = 'ORDERS'.
  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   = 'WEBSITE'.
  objpack-obj_descr  = 'Sales ORDERS'.
  objpack-doc_size   = tab_lines * 255.
  APPEND objpack.
* Completing the recipient list
* target recipent
  CLEAR reclist.
  reclist-receiver = '[email protected]'.
  reclist-express  = 'X'.
  reclist-rec_type = 'U'.
  reclist-rec_date = v_date.
  APPEND reclist.
* copy recipents
  CLEAR reclist.
  reclist-receiver = '[email protected]'.
  reclist-express  = 'X'.
  reclist-rec_type = 'U'.
  reclist-copy     = 'X'.
  APPEND reclist.
* Sending the document
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       EXPORTING
            document_data              = doc_chng
            PUT_IN_OUTBOX              = '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.
  CASE sy-subrc.
    WHEN 0.
      WRITE: / 'Result of the send process:'.
      LOOP AT reclist.
        WRITE: / reclist-receiver(48), ':'.
        IF reclist-retrn_code = 0.
          WRITE 'The document was sent'.
        ELSE.
          WRITE 'The document could not be sent'.
        ENDIF.
      ENDLOOP.
    WHEN 1.
      WRITE: / 'No authorization for sending to the specified number'.
    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
try to run this and see the mail in tcode SBWP in the outbox documents ..
regards,
vijay

Similar Messages

  • How to send active links in email from firefox. Works in IE but not Firefox... Is there a setting to change?

    how to send active links in email from firefox. Works in IE but not Firefox... Is there a setting to change?
    == This happened ==
    Every time Firefox opened
    == Always

    Check with your web mail service provider for help with that issue.

  • How to send a delayed notification email?

    How to send a delayed notification email?
    I have a requirement to send an email to the service requestor 2 days after the main fulfillment task is completed.  I know I can create a task that auto-completes using the Dummy adapter, but is there a way to make it auto complete after a certain amount of time has elapsed?  I was thinking about creating a second fulfillment task that would send this email upon completion, but I can't figure out how to delay its start or its end. 

    Hi Tylor,
    James is onto a potential approach here. However, the only way I know of that could work is to use the Scheduled Start feature. This would require that you compute/project the start date of the auto-complete task before the delivery moment begins.
    You would need to do a date calculation and then store the projected date in a hidden field. You could then have your auto-complete task fire on that computed date, using the Scheduled Start feature.
    The wrinkle here, of course, is t

  • How to send active links in email from firefox

    how to send active links in email from firefox. Works in IE but not Firefox... Is there a setting to change?
    == Operating system ==
    Windows 7

    Check with your web mail service provider for help with that issue.

  • How to send puchase report in email ?

    how to send puchase report in email ?

    Search SCN, you will get lot of post for this.
    Here is an example.
    http://scn.sap.com/thread/321890

  • How to send .CSV file via email in Oracle10g/11g PL/SQL

    Hi Guys,
    Can any one let me know or suggest me how to send .csv file via email attachment using Oracle PL/SQL.
    Thanks in advance!
    Regards,
    LRK

    A FAQ. Use UTL_MAIL (if attachment is 32KB less). Else use UTL_SMTP. Search this forum. Search using google.

  • How to send PDF attachment through Email For Purchase Order

    Hi,
         Can you please tell me how to send the Purchase Order with PDF attachment. Thank you.
    Thanks & Regards,
    Rani.

    Find the below example
    *& Report  ZSPOOLTOPDF                                                 *
    *& Converts spool request into PDF document and emails it to           *
    *& recipicant.                                                         *
    *& Execution                                                           *
    *& This program must be run as a background job in-order for the write *
    *& commands to create a Spool request rather than be displayed on      *
    *& screen                                                              *
    REPORT  zspooltopdf.
    PARAMETER: p_email1 LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_sender LIKE somlreci1-receiver
                                        DEFAULT '[email protected]',
               p_delspl  AS CHECKBOX.
    *DATA DECLARATION
    DATA: gd_recsize TYPE i.
    Spool IDs
    TYPES: BEGIN OF t_tbtcp.
            INCLUDE STRUCTURE tbtcp.
    TYPES: END OF t_tbtcp.
    DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
          wa_tbtcp TYPE t_tbtcp.
    Job Runtime Parameters
    DATA: gd_eventid LIKE tbtcm-eventid,
          gd_eventparm LIKE tbtcm-eventparm,
          gd_external_program_active LIKE tbtcm-xpgactive,
          gd_jobcount LIKE tbtcm-jobcount,
          gd_jobname LIKE tbtcm-jobname,
          gd_stepcount LIKE tbtcm-stepcount,
          gd_error    TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    DATA:  w_recsize TYPE i.
    DATA: gd_subject   LIKE sodocchgi1-obj_descr,
          it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          gd_sender_type     LIKE soextreci1-adr_typ,
          gd_attachment_desc TYPE so_obj_nam,
          gd_attachment_name TYPE so_obj_des.
    Spool to PDF conversions
    DATA: gd_spool_nr LIKE tsp01-rqident,
          gd_destination LIKE rlgrap-filename,
          gd_bytecount LIKE tst01-dsize,
          gd_buffer TYPE string.
    Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
            INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    CONSTANTS: c_dev LIKE  sy-sysid VALUE 'DEV',
               c_no(1)     TYPE c   VALUE ' ',
               c_device(4) TYPE c   VALUE 'LOCL'.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    Write statement to represent report output. Spool request is created
    if write statement is executed in background. This could also be an
    ALV grid which would be converted to PDF without any extra effort
      WRITE 'Hello World'.
      new-page.
      commit work.
      new-page print off.
      IF sy-batch EQ 'X'.
        PERFORM get_job_details.
        PERFORM obtain_spool_id.
    Alternative way could be to submit another program and store spool
    id into memory, will be stored in sy-spono.
    *submit ZSPOOLTOPDF2
           to sap-spool
           spool parameters   %_print
           archive parameters %_print
           without spool dynpro
           and return.
    Get spool id from program called above
    IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
        PERFORM convert_spool_to_pdf.
        PERFORM process_email.
        if p_delspl EQ 'X'.
          PERFORM delete_spool.
        endif.
        IF sy-sysid = c_dev.
          wait up to 5 seconds.
          SUBMIT rsconn01 WITH mode   = 'INT'
                          WITH output = 'X'
                          AND RETURN.
        ENDIF.
      ELSE.
        SKIP.
        WRITE:/ 'Program must be executed in background in-order for spool',
                'request to be created.'.
      ENDIF.
          FORM obtain_spool_id                                          *
    FORM obtain_spool_id.
      CHECK NOT ( gd_jobname IS INITIAL ).
      CHECK NOT ( gd_jobcount IS INITIAL ).
      SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                     AND        jobcount    = gd_jobcount
                     AND        stepcount   = gd_stepcount
                     AND        listident   <> '0000000000'
                     ORDER BY   jobname
                                jobcount
                                stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        MESSAGE s004(zdd) WITH gd_spool_nr.
      ELSE.
        MESSAGE s005(zdd).
      ENDIF.
    ENDFORM.
          FORM get_job_details                                          *
    FORM get_job_details.
    Get current job details
      CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    ENDFORM.
          FORM convert_spool_to_pdf                                     *
    FORM convert_spool_to_pdf.
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount            = gd_bytecount
           TABLES
                pdf                      = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
      CHECK sy-subrc = 0.
    Transfer the 132-long strings to 255-long strings
      LOOP AT it_pdf_output.
        TRANSLATE it_pdf_output USING ' ~'.
        CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.
          FORM process_email                                            *
    FORM process_email.
      DESCRIBE TABLE it_mess_att LINES gd_recsize.
      CHECK gd_recsize > 0.
      PERFORM send_email USING p_email1.
    perform send_email using p_email2.
    ENDFORM.
          FORM send_email                                               *
    -->  p_email                                                       *
    FORM send_email USING p_email.
      CHECK NOT ( p_email IS INITIAL ).
      REFRESH it_mess_bod.
    Default subject matter
      gd_subject         = 'Subject'.
      gd_attachment_desc = 'Attachname'.
    CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
      it_mess_bod        = 'Message Body text, line 1'.
      APPEND it_mess_bod.
      it_mess_bod        = 'Message Body text, line 2...'.
      APPEND it_mess_bod.
    If no sender specified - default blank
      IF p_sender EQ space.
        gd_sender_type  = space.
      ELSE.
        gd_sender_type  = 'INT'.
      ENDIF.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_mess_bod
                                          it_mess_att
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'PDF'
                                          gd_attachment_name
                                          gd_attachment_desc
                                          p_sender
                                          gd_sender_type
                                 changing gd_error
                                          gd_reciever.
    ENDFORM.
          FORM delete_spool                                             *
    FORM delete_spool.
      DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
      ld_spool_nr = gd_spool_nr.
      CHECK p_delspl <> c_no.
      CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
           EXPORTING
                spoolid = ld_spool_nr.
    ENDFORM.
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    FORM send_file_as_email_attachment tables it_message
                                              it_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
    data:   t_packing_list like sopcklsti1 occurs 0 with header line,
            t_contents like solisti1 occurs 0 with header line,
            t_receivers like somlreci1 occurs 0 with header line,
            t_attachment like solisti1 occurs 0 with header line,
            t_object_header like solisti1 occurs 0 with header line,
            w_cnt type i,
            w_sent_all(1) type c,
            w_doc_data like sodocchgi1.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = it_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    Reward if helpful.
    Thanks,
    Kishore S N

  • How to send a link via email

    how do I send a link via email with my ipa

    LIke this:
    http://i1224.photobucket.com/albums/ee374/Diavonex/1906911d.jpg

  • How to send ALV report by Email

    Hi.
    we have developed a block ALV report which has 3 reports i.e Detail report , summary report and Error report. Currently user run the report in background.However there is need to send this report by Email . I can use FM:SO_OBJECT_SEND . I want how to pass this report to FM and how to handle if there are multiple email ids. I think we can create a group of the user with email id in business workplace and pass the group to FM.
    I need help in how to assign the report and user group to this FM

    Hi,
    You may use the code given by Amit in this link -
    MAil Attachment.
    It is perfect to handle any type of email requirement.
    Regards,
    Amit
    Reward all helpful replies.

  • How to send task content as email?

    Hi all,
    I have task list, need to send task content as email to a person like:
    How to achieve this?

    Hello,
    create a workflow with SharePoint Designer that sends an email when an item is created.
    Or edit the list form with InfoPath and create a special email view. Include all the fields you want to send in the email. Then create a data connection to submit to email and configure who it is sent to and what the subject line is based on the form values.
    Use a button to submit the form and add a rule to submit the form data, then switch to the email view, submit to the email connection and then close the form.
    This way, the recipient will see the exact form you defined in InfoPath  in the email view.
    cheers, teylyn

  • How to send smartform as an email or fax

    Hi Friends,
    Problem is i am getting smartform output, but how to send the output as an email or fax( say for ex it should be sent to vendor). Also kindly explain how to convert smartform to PDF output. Thanks in advance.

    Hi,
    The below sample code is for 4.6C.Try this out.
    Kindly reward points by clicking the star on the left of reply,if it helps.
    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.

  • How To Send ALV Output By Email.

    Hi !
    I wanted to ask how to send ALV output of report by email.
    I know that i have to use the fms :
    1. 'WWW_HTML_FROM_LISTOBJECT' - in order to convert the table to HTML.
    2. 'SO_NEW_DOCUMENT_ATT_SEND_API1' - in order to  send the HTML file.
    My problem is how to convert the ALV screen output to the apropriate table parameter of the function 'WWW_HTML_FROM_LISTOBJECT' to listobject type ?
    thanks
    moshe

    Hi look at the following program.
    *& Report  ZSM17_EMAIL1
    REPORT  zsm17_email.
    tables : mara.
    data: begin of it_mara occurs 0,
          matnr like  mara-matnr,
          ernam like mara-ernam,
          mtart like mara-mtart,
          matkl like mara-matkl,
          end of it_mara.
    data: begin of it_final occurs 0,
          v_string(255),
          end of it_final.
    *DATA: objpack LIKE sopcklsti1 OCCURS  2 WITH HEADER LINE,
         objhead LIKE solisti1   OCCURS  1 WITH HEADER LINE,
         objbin  LIKE solisti1   OCCURS 10 WITH HEADER LINE,
         objtxt  LIKE solisti1   OCCURS 10 WITH HEADER LINE,
         reclist LIKE somlreci1  OCCURS  5 WITH HEADER LINE.
    DATA: objpack LIKE sopcklsti1 OCCURS  0 with header line,
          objhead LIKE solisti1   OCCURS  0 WITH HEADER LINE,
          objbin  LIKE solisti1   OCCURS 0 WITH HEADER LINE,
          objtxt  LIKE solisti1   OCCURS 0 WITH HEADER LINE,
          reclist LIKE somlreci1  OCCURS  0 WITH HEADER LINE.
    data: wa_objbin like line of objbin.
    DATA: doc_chng LIKE sodocchgi1.
    DATA: tab_lines LIKE sy-tabix.
    select-options s_matnr for mara-matnr.
    *--- Selecting data from mara
    select matnr
           ernam
           mtart
           matkl
           into table it_mara
           from mara
           where matnr in s_matnr.
    if sy-subrc ne 0.
    write:/ 'no data found'.
      exit.
    else.
    loop at it_mara.
       concatenate it_mara-matnr
                   it_mara-ernam
                   it_mara-mtart
                   it_mara-matkl
         into it_final-v_string separated by '~'.
        append it_final.
        clear it_final.
    endloop.
    endif.
    Creating the document to be sent
    doc_chng-obj_name = 'TEST'.   "name of the document
    title of document or subject
    doc_chng-obj_descr = 'Test Email program'.
    body of the mail
    objtxt = 'A test report'.
    APPEND objtxt.
    objtxt = 'is enclosed as an attachment.'.
    APPEND objtxt.
    *clear objtxt.
    DESCRIBE TABLE objtxt LINES tab_lines.
    Size of SAPoffice Document (for API1)
    doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    Creating the entry for the compressed attachment
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num   = 0.
    objpack-body_start = 1.
    objpack-body_num   = tab_lines.
    objpack-doc_type   = 'RAW'.
    *objpack-obj_name   = 'ATTACHMENT'.
    *objpack-obj_descr = 'Test Email Program'.
    *objpack-doc_size   = tab_lines * 255.
    APPEND objpack..
    *--- Populating the records in the attachment
    data: w_str(255) TYPE c.
    loop at it_final into wa_objbin.
    append wa_objbin to objbin.
    append objbin.
    clear wa_objbin.
    endloop.
    DESCRIBE TABLE objbin LINES tab_lines.
    tab_lines = tab_lines + 1.
    objhead = 'test_report.txt'.
    append objhead.
    Creating 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   = 'txt'.
    objpack-obj_name   = 'txt'.
    objpack-obj_descr = 'Test Email Program'.
    objpack-doc_size   = tab_lines * 255.
    APPEND objpack..
    *write:/ 'object text', objtxt.
    Entering names in the distribution list
    reclist-receiver = '[email protected]'.
    reclist-rec_type = 'U'.
    APPEND reclist.
    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.
    CASE sy-subrc.
      WHEN 0.
        WRITE: / 'Result of the send process:'.
        LOOP AT reclist.
          WRITE:  reclist-receiver(48), ':'.
          IF reclist-retrn_code = 0.
            WRITE 'sent successfully'.
          ELSE.
            WRITE 'not sent'.
          ENDIF.
        ENDLOOP.
       loop at objbin.
         write: objbin-line.
       endloop.
      WHEN 1.
        WRITE: / 'no authorization to send to the specified number of' .
        "'recipients!'.
      WHEN 2.
        WRITE: / 'document could not be sent to any of the recipients!'.
      WHEN 4.
        WRITE: / 'no authorization to send !'.
      WHEN OTHERS.
        WRITE: / 'error occurred during sending !'.
    ENDCASE.

  • How to send pdf's by email automatically using report RSTXPDF4

    Hi gurus!!
    I need some aditional information about the report RSTXPDF4 and how should we use it to send our billing documents by mail to an specific customer. We are not sure but we think that we have to create an output type which is determined automatically only for this customer and include the code to convert the spool to pdf. On the other hand we also know that we have to set the medium as 5.
    Do we have to make any aditional set up?
    Thanks in advance.

    Please check whether this link could be of helpful to you
    [How to send SAP reports in PDF format|http://searchsap.techtarget.com/tip/0,289483,sid21_gci1185359,00.html]
    thanks
    G. Lakshmipathi

  • How to send smartform output through email

    Hi,
    I want to send smartform output through email.....
    can u give me sample program to send it through email......
    Regards,
    Jenifer
    MOderator Message: Basic and Frequently asked question. Please search before posting.
    Edited by: kishan P on Nov 26, 2010 11:11 AM

    Hi Jenifer,
    There are many threads available on SDN.
    Just have a look at this thread
    <<link removed by moderator>>
    Kindly search before you post.
    Regard
    Abhii
    Moderator Message: You have been warned many times against point-hunting. Continuing ignoring of the Moderator warnings will lead to account deletion. Consider this your last warning
    Edited by: kishan P on Nov 26, 2010 11:09 AM

  • How to send a ttachment with email.

    Dear all ,
    i have written the below code to send mails ..it is workiing fine
    my problem is data to be shown in the mail is contained in itab
    mailtxt77 .... but i want the data contained in this itab
    to be sent as attachment ... how to do dat.
    *& Report  ZTRANSPORTER_EMAIL                                          *
    REPORT  ZTRANSPORTER_EMAIL                      .
    data: maildata type sodocchgi1.
    data: entries like sy-tabix.
    data: newid like sofolenti1-object_id.
    data: sent like sonv-flag.
    data: BEGIN OF mailtxt OCCURS 0,
          LINE(300),
          END OF MAILTXT.
    data: mailrec  type table of SOMLRECI1 WITH HEADER LINE .
    DATA : MAILREC1 type table of SOMLRECI1.
    *data: mailrec type string.
    data: lt_transporter like ztransporter occurs 0 with header line.
    data: begin of lt_transporter2 occurs 0,
          transporter(18),
          end of lt_transporter2.
    DATA : MAILTXT1(10),
    MAILTXT2(30),
    MAILTXT3(4),
    MAILTXT4(18),
    MAILTXT5(10),
    MAILTXT6(35),
    MAILTXT7(30),
    MAILTXT8(40),
    MAILTXT9(10),
    MAILTXT10(5),
    MAILTXT11(8),
    MAILTXT12(10),
    mail1 type string,
    mail2 type string,
    mail3 type string,
    mail4 type string,
    mail5 type string,
    mail6 type string,
    mail7 type string,
    mail8 type string,
    mail9 type string,
    mail10 type string,
    mail11 type string,
    mail12 type string.
    DATA : MAILTXT77 TYPE TABLE OF SOLISTI1 WITH HEADER LINE.
    data: begin of lt_transporter1 occurs 0,
          Sr_no(10),
          transporter(30),
          plant(4),
          material(18),
          VENDOR(10),
          vendor_name(35),
          vendor_place(30),
          material_desc(40),
          sched_agreement(10),
          sched_line_item(5),
          delivery_date(8),
          delivery_qty(10),
          end of lt_transporter1.
    data: lt_email like ztrans_email occurs 0 with header line.
    DATA: BEGIN OF MAILTXT13 OCCURS 0 ,
    LINE(300),
    END OF MAILTXT13.
    data: var1 type i,
          var2 type i,
          var3 type i,
    var4 type i,
    var5 type i,
    var6 type i,
    var7 type i,
    var8 type i,
    var9 type i,
    var10 type i,
    var11 type i,
    var12 type i.
    start-of-selection.
      clear:    maildata, mailtxt,  mailrec.
      refresh:  mailtxt. "mailrec.
    select * from ztransporter into table lt_transporter.
    select distinct transporter from ztransporter into table lt_transporter2
    loop at lt_transporter.
    move-corresponding lt_transporter to lt_transporter1.
    append lt_transporter1.
    clear lt_transporter1.
    endloop.
    if not lt_transporter[] is initial.
    select * from ztrans_email into table lt_email
    for all entries in lt_transporter
    where transporter = lt_transporter-transporter.
    endif.
    loop at lt_transporter2.
      maildata-obj_name = 'TEST'.
      maildata-obj_descr = 'Test'.
      maildata-obj_langu = sy-langu.
    MAIL1 = 'SR NO-'.
    MAIL2 = '---TRANSPORTER--
    mail3 = 'plant'.
    mail4 = '---material---'.
    mail5 = '-vendor'.
    mail6 = '--vendor_name--
    mail7 = '--vendor_place--
    mail8 = '--material_desc--
    mail9 = 'sched_agrt'.
    mail10 = 'item-'.
    mail11 = 'del. date'.
    mail12 = '-del. qty-'.
    concatenate mail1 ',' mail2 ',' mail3 ',' mail4 ',' mail5 ',' mail6 ','
    mail7 ',' mail8 ',' mail9 ',' mail10 ',' mail11 ',' mail12  into
    mailtxt77-line
    separated by space.
    *mailtxt = '  Srno  Transporter  plant  material  vendor  vendorplace
    *materialdesc  schedagreement  LINEITEM  DELIVERYDATE  DELIVERYQTY'.
      append mailtxt77.
      clear mailtxt77.
    loop at lt_transporter1 where transporter = lt_transporter2-transporter.
    *MOVE  LT_TRANSPORTER1+(10) TO MAILTXT(10).
    MAILTXT1 = LT_TRANSPORTER1+(10).
    *MAILTXT33 = '  '.
    var1 = strlen( mailtxt1 ).
    var1 = 10 - var1.
    shift mailtxt1 right by var1 places.
    MAILTXT2 = LT_TRANSPORTER1+10(30).
    var2 = strlen( mailtxt2 ).
    var2 = 30 - var2.
    shift mailtxt2 right by var2 places.
    *concatenate mailtxt1 mailtxt2 into mailtxt13-line respecting blanks.
    MAILTXT3 = LT_TRANSPORTER1+40(4).
    var3 = strlen( mailtxt3 ).
    var3 = 4 - var3.
    shift mailtxt3 right by var3 places.
    MAILTXT4 = LT_TRANSPORTER1+44(18).
    var4 = strlen( mailtxt4 ).
    var4 = 18 - var4.
    shift mailtxt4 right by var4 places.
    MAILTXT5 = LT_TRANSPORTER1+62(10).
    var5 = strlen( mailtxt5 ).
    var5 = 10 - var5.
    shift mailtxt5 right by var5 places.
    MAILTXT6 = LT_TRANSPORTER1+72(35).
    var6 = strlen( mailtxt6 ).
    var6 = 35 - var6.
    shift mailtxt6 right by var6 places.
    MAILTXT7 = LT_TRANSPORTER1+107(30).
    var7 = strlen( mailtxt7 ).
    var7 = 30 - var7.
    shift mailtxt7 right by var7 places.
    MAILTXT8 = LT_TRANSPORTER1+137(40).
    var8 = strlen( mailtxt8 ).
    var8 = 40 - var8.
    shift mailtxt8 right by var8 places.
    MAILTXT9 = LT_TRANSPORTER1+177(10).
    var9 = strlen( mailtxt9 ).
    var9 = 10 - var9.
    shift mailtxt9 right by var9 places.
    MAILTXT10 =  LT_TRANSPORTER1+187(5).
    var10 = strlen( mailtxt10 ).
    var10 = 5 - var10.
    shift mailtxt10 right by var10 places.
    MAILTXT11 = LT_TRANSPORTER1+192(8).
    var11 = strlen( mailtxt11 ).
    var11 = 8 - var11.
    shift mailtxt11 right by var11 places.
    MAILTXT12 = LT_TRANSPORTER1+200(10).
    var12 = strlen( mailtxt12 ).
    var12 = 10 - var12.
    shift mailtxt12 right by var12 places.
    *CONCATENATE LT_TRANSPORTER1(10) LT_TRANSPORTER112(30)
    *LT_TRANSPORTER142(4) LT_TRANSPORTER148(18)
    *LT_TRANSPORTER166(10) LT_TRANSPORTER178(35)
    *LT_TRANSPORTER1115(30) LT_TRANSPORTER1147(40)
    *LT_TRANSPORTER1189(10) LT_TRANSPORTER1201(5)
    *LT_TRANSPORTER1208(10) LT_TRANSPORTER1220(10) INTO MAILTXT-LINE.
    CONCATENATE MAILTXT1 ',' MAILTXT2 ',' MAILTXT3 ',' MAILTXT4 ','
    MAILTXT5 ','
    MAILTXT6 ',' MAILTXT7 ',' MAILTXT8 ',' MAILTXT9 ',' MAILTXT10 ','
    MAILTXT11
    ',' MAILTXT12 INTO MAILTXT77-LINE SEPARATED BY SPACE.
    mailtxt = lt_transporter1.
      append mailtxt77.
       clear mailtxt77.
    endloop.
    clear lt_email.
    read table lt_email with key transporter = lt_transporter2-transporter.
    if sy-subrc = 0.
      mailrec-receiver = lt_email-main_email.
      mailrec = lt_email-main_email.
      mailrec-rec_type  = 'U'.
    mailrec-com_type = 'INT'.
    mailrec-notif_del = 'X'.
    mailrec-notif_ndel = 'X'.
      append mailrec.
    *perform email.
       clear mailrec.
       if not lt_email-email2 = ''.
      mailrec-receiver = lt_email-email2.
      mailrec-rec_type  = 'U'.
       mailrec-com_type = 'INT'.
    mailrec-notif_del = 'X'.
    mailrec-notif_ndel = 'X'.
    *mailrec = lt_email-email2.
    perform email.
      append mailrec.
       clear mailrec.
       endif.
       if not lt_email-email3 = ''.
      mailrec-receiver = lt_email-email3.
      mailrec-rec_type  = 'U'.
       mailrec-com_type = 'INT'.
    mailrec-notif_del = 'X'.
    mailrec-notif_ndel = 'X'.
      append mailrec.
    *mailrec = lt_email-email3.
    perform email.
       clear mailrec.
       endif.
        if not lt_email-email4 = ''.
      mailrec-receiver = lt_email-email4.
      mailrec-rec_type  = 'U'.
       mailrec-com_type = 'INT'.
    mailrec-notif_del = 'X'.
    mailrec-notif_ndel = 'X'.
      append mailrec.
    *mailrec = lt_email-email4.
    perform email.
       clear mailrec.
       endif.
       if not lt_email-email5 = ''.
      mailrec-receiver = lt_email-email5.
      mailrec-rec_type  = 'U'.
      append mailrec.
    mailrec = lt_email-email5.
    perform email.
       clear mailrec.
       endif.
    endif.
        call function 'SO_NEW_DOCUMENT_SEND_API1'
             exporting
                  document_data              = maildata
                  document_type              = 'RAW'
                  put_in_outbox              = 'X'
                  commit_work                = 'X'
             importing
                  sent_to_all                = sent
                  new_object_id             = newid
             tables
                  object_content             = mailtxt77
                  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.

    dear all,
      i  am now able to get attachments with the mail
      but there are 2 attachments
      1.     . raw
      2.     .ali -  this attachment shows junk characters
    i need only one .html file as attachement
    if you can kindly find the fault in this code
    *& Report  ZTRANSPORTER_EMAIL                                          *
    REPORT  ZTRANSPORTER_EMAIL                      .
    data: maildata type sodocchgi1.
    DATA:
    l_datum(10),
    ls_docdata TYPE sodocchgi1,
    lt_objpack TYPE TABLE OF sopcklsti1 WITH HEADER LINE,
    lt_objhead TYPE TABLE OF solisti1 WITH HEADER LINE,
    lt_objtxt TYPE TABLE OF solisti1 WITH HEADER LINE,
    lt_objbin TYPE TABLE OF solisti1 WITH HEADER LINE,
    lt_reclist TYPE TABLE OF somlreci1 WITH HEADER LINE,
    lt_listobject TYPE TABLE OF abaplist WITH HEADER LINE,
    l_tab_lines TYPE i,
    l_att_type LIKE soodk-objtp.
    data: entries like sy-tabix.
    data: newid like sofolenti1-object_id.
    data: sent like sonv-flag.
    data: BEGIN OF mailtxt OCCURS 0,
          LINE(300),
          END OF MAILTXT.
    data: mailrec  type table of SOMLRECI1 WITH HEADER LINE .
    DATA : MAILREC1 type table of SOMLRECI1.
    *data: mailrec type string.
    data: lt_transporter like ztransporter occurs 0 with header line.
    data: begin of lt_transporter2 occurs 0,
          transporter(18),
          end of lt_transporter2.
    DATA : MAILTXT1(10),
    MAILTXT2(30),
    MAILTXT3(4),
    MAILTXT4(18),
    MAILTXT5(10),
    MAILTXT6(35),
    MAILTXT7(30),
    MAILTXT8(40),
    MAILTXT9(10),
    MAILTXT10(5),
    MAILTXT11(8),
    MAILTXT12(10),
    mail1 type string,
    mail2 type string,
    mail3 type string,
    mail4 type string,
    mail5 type string,
    mail6 type string,
    mail7 type string,
    mail8 type string,
    mail9 type string,
    mail10 type string,
    mail11 type string,
    mail12 type string.
    DATA : MAILTXT77 TYPE TABLE OF SOLISTI1 WITH HEADER LINE.
    data: begin of lt_transporter1 occurs 0,
          Sr_no(10),
          transporter(30),
          plant(4),
          material(18),
          VENDOR(10),
          vendor_name(35),
          vendor_place(30),
          material_desc(40),
          sched_agreement(10),
          sched_line_item(5),
          delivery_date(8),
          delivery_qty(10),
          end of lt_transporter1.
    data: lt_email like ztrans_email occurs 0 with header line.
    DATA: BEGIN OF MAILTXT13 OCCURS 0 ,
    LINE(300),
    END OF MAILTXT13.
    data: var1 type i,
          var2 type i,
          var3 type i,
    var4 type i,
    var5 type i,
    var6 type i,
    var7 type i,
    var8 type i,
    var9 type i,
    var10 type i,
    var11 type i,
    var12 type i.
    start-of-selection.
      clear:    maildata, mailtxt,  mailrec.
      refresh:  mailtxt. "mailrec.
    select * from ztransporter into table lt_transporter.
    select distinct transporter from ztransporter into table lt_transporter2
    loop at lt_transporter.
    move-corresponding lt_transporter to lt_transporter1.
    append lt_transporter1.
    clear lt_transporter1.
    endloop.
    if not lt_transporter[] is initial.
    select * from ztrans_email into table lt_email
    for all entries in lt_transporter
    where transporter = lt_transporter-transporter.
    endif.
    loop at lt_transporter2.
      maildata-obj_name = 'TEST'.
      maildata-obj_descr = 'Test'.
      maildata-obj_langu = sy-langu.
    MAIL1 = 'SR NO-'.
    MAIL2 = '---TRANSPORTER--
    mail3 = 'plant'.
    mail4 = '---material---'.
    mail5 = '-vendor'.
    mail6 = '--vendor_name--
    mail7 = '--vendor_place--
    mail8 = '--material_desc--
    mail9 = 'sched_agrt'.
    mail10 = 'item-'.
    mail11 = 'del. date'.
    mail12 = '-del. qty-'.
    concatenate mail1 ',' mail2 ',' mail3 ',' mail4 ',' mail5 ',' mail6 ','
    mail7 ',' mail8 ',' mail9 ',' mail10 ',' mail11 ',' mail12  into
    mailtxt77-line
    separated by space.
    *mailtxt = '  Srno  Transporter  plant  material  vendor  vendorplace
    *materialdesc  schedagreement  LINEITEM  DELIVERYDATE  DELIVERYQTY'.
      append mailtxt77.
      clear mailtxt77.
    loop at lt_transporter1 where transporter = lt_transporter2-transporter.
    *MOVE  LT_TRANSPORTER1+(10) TO MAILTXT(10).
    MAILTXT1 = LT_TRANSPORTER1+(10).
    *MAILTXT33 = '  '.
    var1 = strlen( mailtxt1 ).
    var1 = 10 - var1.
    shift mailtxt1 right by var1 places.
    MAILTXT2 = LT_TRANSPORTER1+10(30).
    var2 = strlen( mailtxt2 ).
    var2 = 30 - var2.
    shift mailtxt2 right by var2 places.
    *concatenate mailtxt1 mailtxt2 into mailtxt13-line respecting blanks.
    MAILTXT3 = LT_TRANSPORTER1+40(4).
    var3 = strlen( mailtxt3 ).
    var3 = 4 - var3.
    shift mailtxt3 right by var3 places.
    MAILTXT4 = LT_TRANSPORTER1+44(18).
    var4 = strlen( mailtxt4 ).
    var4 = 18 - var4.
    shift mailtxt4 right by var4 places.
    MAILTXT5 = LT_TRANSPORTER1+62(10).
    var5 = strlen( mailtxt5 ).
    var5 = 10 - var5.
    shift mailtxt5 right by var5 places.
    MAILTXT6 = LT_TRANSPORTER1+72(35).
    var6 = strlen( mailtxt6 ).
    var6 = 35 - var6.
    shift mailtxt6 right by var6 places.
    MAILTXT7 = LT_TRANSPORTER1+107(30).
    var7 = strlen( mailtxt7 ).
    var7 = 30 - var7.
    shift mailtxt7 right by var7 places.
    MAILTXT8 = LT_TRANSPORTER1+137(40).
    var8 = strlen( mailtxt8 ).
    var8 = 40 - var8.
    shift mailtxt8 right by var8 places.
    MAILTXT9 = LT_TRANSPORTER1+177(10).
    var9 = strlen( mailtxt9 ).
    var9 = 10 - var9.
    shift mailtxt9 right by var9 places.
    MAILTXT10 =  LT_TRANSPORTER1+187(5).
    var10 = strlen( mailtxt10 ).
    var10 = 5 - var10.
    shift mailtxt10 right by var10 places.
    MAILTXT11 = LT_TRANSPORTER1+192(8).
    var11 = strlen( mailtxt11 ).
    var11 = 8 - var11.
    shift mailtxt11 right by var11 places.
    MAILTXT12 = LT_TRANSPORTER1+200(10).
    var12 = strlen( mailtxt12 ).
    var12 = 10 - var12.
    shift mailtxt12 right by var12 places.
    *CONCATENATE LT_TRANSPORTER1(10) LT_TRANSPORTER112(30)
    *LT_TRANSPORTER142(4) LT_TRANSPORTER148(18)
    *LT_TRANSPORTER166(10) LT_TRANSPORTER178(35)
    *LT_TRANSPORTER1115(30) LT_TRANSPORTER1147(40)
    *LT_TRANSPORTER1189(10) LT_TRANSPORTER1201(5)
    *LT_TRANSPORTER1208(10) LT_TRANSPORTER1220(10) INTO MAILTXT-LINE.
    CONCATENATE MAILTXT1 ',' MAILTXT2 ',' MAILTXT3 ',' MAILTXT4 ','
    MAILTXT5 ','
    MAILTXT6 ',' MAILTXT7 ',' MAILTXT8 ',' MAILTXT9 ',' MAILTXT10 ','
    MAILTXT11
    ',' MAILTXT12 INTO MAILTXT77-LINE SEPARATED BY SPACE.
    mailtxt = lt_transporter1.
      append mailtxt77.
       clear mailtxt77.
    Create receiver list
    **LOOP AT s_name.
    *lt_reclist-receiver = s_name-low.
    **lt_reclist-rec_type = 'B'.
    **APPEND lt_reclist.
    **ENDLOOP.
    Send Message
    endloop.
    submit zreport with transporter = lt_transporter2-transporter
       exporting list to memory and return.
    *REFRESH LT_LISTOBJECT.
       CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = lt_listobject
    EXCEPTIONS
    not_found = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    Error in function module &1
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'LIST_FROM_MEMORY'.
    ENDIF.
    Because listobject is of size RAW(1000)
    and objbin is of size CHAR(255) we make this table copy
    CALL FUNCTION 'TABLE_COMPRESS'
    TABLES
    in = lt_listobject
    out = lt_objbin
    EXCEPTIONS
    compress_error = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    Error in function module &1
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'TABLE_COMPRESS'.
    ENDIF.
    ls_docdata-obj_name = 'USERS_LIST'.
    CONCATENATE 'List of Users' sy-sysid '-' l_datum "#EC *
    INTO ls_docdata-obj_descr SEPARATED BY space.
    Main Text
    lt_objtxt = 'List of Users According to Logon Date' &
    ' and Password Change'. "#EC *
    APPEND lt_objtxt.
    Write Packing List (Main)
    DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
    READ TABLE lt_objtxt INDEX l_tab_lines.
    ls_docdata-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
    CLEAR lt_objpack-transf_bin.
    lt_objpack-head_start = 1.
    lt_objpack-head_num = 0.
    lt_objpack-body_start = 1.
    lt_objpack-body_num = l_tab_lines.
    lt_objpack-doc_type = 'RAW'.
    APPEND lt_objpack.
    Create Message Attachment
    Write Packing List (Attachment)
    l_att_type = 'ALI'.
    DESCRIBE TABLE lt_objbin LINES l_tab_lines.
    READ TABLE lt_objbin INDEX l_tab_lines.
    lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objbin ).
    lt_objpack-transf_bin = 'X'.
    lt_objpack-head_start = 1.
    lt_objpack-head_num = 0.
    lt_objpack-body_start = 1.
    lt_objpack-body_num = l_tab_lines.
    lt_objpack-doc_type = l_att_type.
    lt_objpack-obj_name = 'ATTACHMENT'.
    lt_objpack-obj_descr = 'List_of_Users'. "#EC *
    APPEND lt_objpack.
    clear lt_email.
    read table lt_email with key transporter = lt_transporter2-transporter.
    if sy-subrc = 0.
      mailrec-receiver = lt_email-main_email.
      mailrec = lt_email-main_email.
      mailrec-rec_type  = 'U'.
    mailrec-com_type = 'INT'.
    mailrec-notif_del = 'X'.
    mailrec-notif_ndel = 'X'.
      append mailrec.
    *perform email.
       clear mailrec.
       if not lt_email-email2 = ''.
      mailrec-receiver = lt_email-email2.
      mailrec-rec_type  = 'U'.
       mailrec-com_type = 'INT'.
    mailrec-notif_del = 'X'.
    mailrec-notif_ndel = 'X'.
    *mailrec = lt_email-email2.
    perform email.
      append mailrec.
       clear mailrec.
       endif.
       if not lt_email-email3 = ''.
      mailrec-receiver = lt_email-email3.
      mailrec-rec_type  = 'U'.
       mailrec-com_type = 'INT'.
    mailrec-notif_del = 'X'.
    mailrec-notif_ndel = 'X'.
      append mailrec.
    *mailrec = lt_email-email3.
    perform email.
       clear mailrec.
       endif.
        if not lt_email-email4 = ''.
      mailrec-receiver = lt_email-email4.
      mailrec-rec_type  = 'U'.
       mailrec-com_type = 'INT'.
    mailrec-notif_del = 'X'.
    mailrec-notif_ndel = 'X'.
      append mailrec.
    *mailrec = lt_email-email4.
    perform email.
       clear mailrec.
       endif.
       if not lt_email-email5 = ''.
      mailrec-receiver = lt_email-email5.
      mailrec-rec_type  = 'U'.
      append mailrec.
    mailrec = lt_email-email5.
    perform email.
       clear mailrec.
       endif.
    endif.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = ls_docdata
    put_in_outbox = ''
    commit_work = 'X'
    TABLES
    packing_list = lt_objpack
    object_header = lt_objhead
    contents_bin = lt_objbin
    contents_txt = lt_objtxt
    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.
    Document sent
    MESSAGE ID 'SO' TYPE 'S' NUMBER '022'.
    ELSE.
    Document <&> could not be sent
    MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
    WITH ls_docdata-obj_name.
    ENDIF.
    kindly help..
    APT POINTS WILL BE GIVEN..

Maybe you are looking for