Random /td in output of db.mail

below is the code and a forward copy of the email it sends out, I am getting a random < /td> in the output as well as in the bags column 1 6 is spaced strange anything glaring wrong with
my coding 
USE [SQLCAFE2010]
GO
/****** Object: StoredProcedure [dbo].[sp_nakedsigma] Script Date: 3/26/2014 8:38:41 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter procedure [dbo].[sp_nakedsigma]
as
begin
declare @query nvarchar (max)
set @query =
N'<h1>Naked Sigma</h1>'+
N'<style type=''text/css''>'+
N'table{border-collapse:collapse;border:1px solid #3399FF; font:10pt verdana; color:#343434;}'+
N'table td,table th, table caption {border:1px solid #3399FF;}'+
N'table caption {font-weight:bold; background-color:white;}'+
N'table th {background-color:#3399FF; font-weight:bold;}'+
N'</style>' +
N'<table>'+
N'<caption>Naked Sigma</caption>' +
N'<tr><th>Company</th><th>Reff Number</th><th>Sigma Check</th><th>H-Index</th><th>Coffee Name</th><th>Bags</th><th>Sold By</th></tr>'+
CAST(
(SELECT
td=Roaster.company, '',
td=OrderDetails.[REFF NUMBER],'',
td=OrderDetails.Scheckbox,'',
td=Inventory.[H-INDEX],'',
td=TypesofCoffee.[COFFEE NAME],'',
td=OrderDetails.NOBAGS,'',
td=OrderDetails.OrgSoldBy,''
FROM OrderDetails INNER JOIN
Orders ON OrderDetails.ORDERID = Orders.ORDERID INNER JOIN
Roaster ON Orders.COMP_ID = Roaster.COMP_ID INNER JOIN
Inventory ON OrderDetails.[REFF NUMBER] = Inventory.[REFF NUMBER] INNER JOIN
Inventory AS Inventory_1 ON OrderDetails.[REFF NUMBER] = Inventory_1.[REFF NUMBER] INNER JOIN
TypesofCoffee ON Inventory_1.CAFETYPE = TypesofCoffee.ID
WHERE (OrderDetails.Scheckbox = 1) AND (Inventory.[H-INDEX] = 0)
for xml path ('tr'),type) as nvarchar(max))+
N'</table>'
select @query
end
go
Naked Sigma
Naked Sigma
Company
Reff Number
Sigma Check
H-Index
Coffee Name
Bags
Sold By
Royal Coffee NY, Inc. -R NY- S.Plainfield, NJ
19460
1
0
Organic Costa Rican La Amistad
1
marilyn
Royal Coffee NY, Inc. -RNY- S.Plainfield, NJ
19846
1
0
Uganda Robusta scrn 15
1 6
marilyn
New Hampshire Coffee Roasting
21710
1
0
Organic Nicaraguan Segovia PRODECOOP - FAIR TRADE
3
Richard
MRT Foods Specialists
21765
1
0< /td>
Organic Guatemalan HB Huehuetenango-FAIR TRADE
25
Richard
Noble Coyote Coffee Roasters
21766
1
0
Organic Guatemalan SHB Huehuetenango-FAIR TRADE
10
joe
Little Flower Coffee Inc dba Strongtree Organic
21996
1
0
Organic Sumatra Mandheling Sipangan Bolon
6
james
(1 rows affected) 

Check this thread:
http://stackoverflow.com/questions/7086393/create-html-table-with-sql-for-xml
and try this:
--for xml path ('tr'),type
FOR XML RAW('tr'), ELEMENTS

Similar Messages

  • Sending report output via E-mail (excel pivoted format)

    Hi all,
    i have a written a report where i need to send the report output to somebody via
    E-mail.i am sending this report output via E-mail successfully.The receiver receives, my output in excel format.but this excel is not <b>pivoted</b>.
    i want , the receiver should get my output in pivoted excel format.i.e my output data should be exactly fit in the excel sheet.
    now the columns in excel sheet are overlapping.once i double clicked, the columns are getting separated.i do not want to double click.i want all the columns should come properly i.e excel field  length should be adjusted as per the output field length.
    i am giving my coding below.plz suggest how i can do the above thing .it's urgent.
    any idea will be highly appreaciated.
    Regards
    if not p_email1 is initial.
         perform fill_report_csv.
         perform f_send_internet_mail.
      endif.
    FORM fill_report_csv.
       data :   l_text(232) type c,
               v_matnr1(21) type c,
               v_matnr(21) type c,
               v_matkl(14) type c,
               v_maktx(45) type c,
               v_ttlstk(14) type c,
               v_verpr(14) type c,
               v_werks(14) type c,
               v_lgort(14) type c,
               v_char(10) type c,
               v_stks type p ,
               v_po(40) type c,
               v_qty(13) type c,
                v_qty1 type sy-datum,
               v_date(15) type c,
               v_date1(15) TYPE C,
               v_name(35) type c,
               v_eknam(18) type c,
               v_lifnr(15) type c,
            l_po(40) type c,
            v_matnr(20) type c,
             l_rate(11) type  p decimals 5,
             l_flag type c.
      concatenate c_equal c_colon 'PO no.' c_colon
                    into v_po.
      concatenate c_equal c_colon 'Material no.' c_colon
                    into v_matnr.
      concatenate c_equal c_colon 'Description.' c_colon
                    into v_maktx.
      concatenate c_equal c_colon 'Due Qty.' c_colon
                    into v_qty.
      concatenate c_equal c_colon 'Del Date.' c_colon
                    into v_date.
      concatenate c_equal c_colon 'Vendor.' c_colon
                    into v_name.
      concatenate c_equal c_colon 'Buyer.' c_colon
                    into v_eknam.
      concatenate c_equal c_colon 'Vendor Code.' c_colon
                    into v_lifnr.
    concatenate
             v_po v_matnr v_maktx v_qty
             v_date v_name v_eknam v_lifnr
             into i_download
             SEPARATED BY con_tab.
      append i_download .
    clear : v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
    clear wa_output.
    loop at i_output into wa_output.
       on change of wa_output-ebeln.
         clear v_lines.
         loop at i_eket into wa_eket
                 where ebeln = wa_output-ebeln.
           v_lines = v_lines + 1.
           clear wa_eket.
         endloop.
    **-- Checking of page break
         v_lines = sy-linno + v_lines .
         if 55 < v_lines  .
           write:/0(161) sy-uline.
           new-page.
         endif.
      clear v_lines.
          loop at i_eket into wa_eket
                  where ebeln = wa_output-ebeln.
            v_lines = v_lines + 1.
            clear wa_eket.
          endloop.
    *-- Calculating the due qty.
        wa_output-dumng = wa_output-menge - wa_output-wemng.
    *-- Writing the Line items of the PO.
        read table i_ekpo into wa_ekpo
              with key ebeln = wa_output-ebeln
                       ebelp = wa_output-ebelp.
         l_rate = wa_ekpo-netpr / wa_ekpo-peinh.
    *-- Writing of PO detail
         if wa_output-dumng gt 0 .
         v_qty = wa_output-dumng.
        v_date1 = wa_output-eindt.
        v_maktx = wa_output-maktx.
         if wa_output-maktx+0(1) = '"' .
                concatenate  c_equal wa_output-maktx
                   into v_maktx  .
             else .
                concatenate  c_equal c_colon wa_output-maktx c_colon
                   into v_maktx  .
             endif .
       if wa_output-name1+0(1) = '"' .
                concatenate  c_equal wa_output-name1
                   into v_name  .
             else .
                concatenate  c_equal c_colon wa_output-name1 c_colon
                   into v_name  .
             endif .
        v_name = wa_output-name1.
        v_lifnr = wa_output-lifnr.
         write wa_output-eindt to v_date1 DD/MM/YYYY.
         concatenate '="' wa_output-ebeln '/'
                wa_output-ebelp '"' into v_po .
         concatenate '="' wa_output-matnr '"' into v_matnr .
             concatenate  c_equal c_colon wa_output-maktx c_colon
               into v_maktx  .
              concatenate  c_equal c_colon wa_output-dumng c_colon
               into v_qty1  .
               concatenate  c_equal c_colon wa_output-eindt c_colon
               into v_date1  .
              concatenate  c_equal c_colon wa_output-name1 c_colon
               into v_name  .
                concatenate  c_equal c_colon wa_output-eknam c_colon
                into v_eknam  .
              concatenate  c_equal c_colon wa_output-lifnr c_colon
               into v_lifnr  .
              concatenate  c_equal c_colon wa_mard-werks '/'
               wa_mard-lgort c_colon
               into v_lgort .
                 concatenate '="' wa_output-lifnr '"' into v_lifnr .
    condense:v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
         concatenate
             v_po v_matnr v_maktx v_qty
             v_date1 v_name v_eknam v_lifnr
             into i_download
             SEPARATED BY con_tab.
        concatenate con_cret i_download INTO i_download .
        append i_download .
      endif.
    clear : v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
    endloop.
    ENDFORM.                    " fill_report_csv
    *&      Form  f_send_internet_mail
          text
    -->  p1        text
    <--  p2        text
    FORM f_send_internet_mail.
    Variables
    data:   it_packing_list like sopcklsti1 occurs 0 with header line,
            it_contents like solisti1 occurs 0 with header line,
            it_receivers like somlreci1 occurs 0 with header line,
            it_attachment like solisti1 occurs 0 with header line,
            gd_cnt type i,
            gd_sent_all(1) type c,
            gd_doc_data like sodocchgi1,
            gd_error type sy-subrc.
    data:   it_message type standard table of SOLISTI1 initial size 0
                    with header line.
    data : found_receiver type c,
           v_title(80) type c,
           l_text(180) type c.
    Fill the document data.
      gd_doc_data-doc_size = 1.
    Adds text to email text table
      append 'Pls see attached open purchase order report.' to it_message.
      append '' to it_message.
      concatenate 'Note: This is system generated report'
                  ', figures may subject to actual physical count.'
                  into l_text separated by space.
      append l_text to it_message.
    Populate the subject/generic message attributes
      CLEAR gd_doc_data.
      READ TABLE i_download INDEX w_cnt.
      gd_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( i_download ).
      gd_doc_data-obj_langu  = sy-langu.
      gd_doc_data-obj_name   = 'SAPRPT'.
    if p_asdate is initial .
         concatenate p_title ' '
                  sy-datum sy-uzeit into v_title separated by space.
    else .
        concatenate p_title ' '
                 p_bldat p_cputm into v_title separated by space.
    endif .
      gd_doc_data-obj_descr  = v_title .
      gd_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = i_download[].
    Describe the body of the message
      clear it_packing_list.
      refresh it_packing_list.
      it_packing_list-transf_bin = space.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 0.
      it_packing_list-body_start = 1.
      describe table it_message lines it_packing_list-body_num.
      it_packing_list-doc_type = 'RAW'.
      append it_packing_list.
    Create attachment notification
      it_packing_list-transf_bin = 'X'.
      it_packing_list-head_start = 1.
      it_packing_list-head_num   = 1.
      it_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES it_packing_list-body_num.
      it_packing_list-doc_type   =  'XLS'.
      it_packing_list-obj_descr  =  'OPEN PURCHASE ORDER' .
      it_packing_list-obj_name   =  'PO.XLS' .
      it_packing_list-doc_size   =  it_packing_list-body_num * 255.
      APPEND it_packing_list.
    assign SAP user smtp address from successful retrieval.
      loop at p_email.
    Add the recipients email address
         found_receiver = 'X' .
         it_receivers-receiver = p_email-low.
         it_receivers-rec_type = 'U'.
         it_receivers-com_type = 'INT'.
         it_receivers-notif_del = ''.
         it_receivers-notif_ndel = 'X'.
         append it_receivers .
      endloop .
    Add default recipient email when unable to locate purc group email
       if found_receiver is initial .
           it_receivers-receiver = p_email.
           it_receivers-rec_type = 'U'.
           it_receivers-com_type = 'INT'.
           it_receivers-notif_del = ''.
           it_receivers-notif_ndel = 'X'.
          append it_receivers.
       endif .
    Call the FM to post the message to SAPMAIL
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           exporting
                document_data              = gd_doc_data
                put_in_outbox              = 'X'
                commit_work                = 'X'
           importing
                sent_to_all                = gd_sent_all
           tables
                packing_list               = it_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                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.
    Store function module return code
      gd_error = sy-subrc.
    Get it_receivers return code
      loop at it_receivers.
      endloop.
    Instructs mail send program for SAPCONNECT to send email.
      wait up to 2 seconds.
      if gd_error eq 0.
          submit rsconn01 with mode = 'INT'
                        with output = ' '
                        and return.
      endif.
    ENDFORM.                    " f_send_internet_mail

    Hi,
    go through this link,
    http://www.sapdevelopment.co.uk/reporting/email/emailhome.htm
    you have some sample programs.
    Regards,
    Raghavendra

  • Report output via E-mail

    Hi all,
    i have a written a report where i need to send the report output to somebody via
    E-mail.i am sending this report output via E-mail successfully.The receiver receives, my output in excel format.but this excel is not <b>pivoted</b>.
    i want , the receiver should get my output in pivoted excel format.i.e my output data should be exactly fit in the excel sheet.
    now the columns in excel sheet are overlapping.once i double clicked, the columns are getting separated.i do not want to double click.i want all the columns should come properly i.e excel field  length should be adjusted as per the output field length.
    i am giving my coding below.plz suggest how i can do the above thing .it's urgent.
    any idea will be highly appreaciated.
    Regards
    if not p_email1 is initial.
         perform fill_report_csv.
         perform f_send_internet_mail.
      endif.
    FORM fill_report_csv.
       data :   l_text(232) type c,
               v_matnr1(21) type c,
               v_matnr(21) type c,
               v_matkl(14) type c,
               v_maktx(45) type c,
               v_ttlstk(14) type c,
               v_verpr(14) type c,
               v_werks(14) type c,
               v_lgort(14) type c,
               v_char(10) type c,
               v_stks type p ,
               v_po(40) type c,
               v_qty(13) type c,
                v_qty1 type sy-datum,
               v_date(15) type c,
               v_date1(15) TYPE C,
               v_name(35) type c,
               v_eknam(18) type c,
               v_lifnr(15) type c,
            l_po(40) type c,
            v_matnr(20) type c,
             l_rate(11) type  p decimals 5,
             l_flag type c.
      concatenate c_equal c_colon 'PO no.' c_colon
                    into v_po.
      concatenate c_equal c_colon 'Material no.' c_colon
                    into v_matnr.
      concatenate c_equal c_colon 'Description.' c_colon
                    into v_maktx.
      concatenate c_equal c_colon 'Due Qty.' c_colon
                    into v_qty.
      concatenate c_equal c_colon 'Del Date.' c_colon
                    into v_date.
      concatenate c_equal c_colon 'Vendor.' c_colon
                    into v_name.
      concatenate c_equal c_colon 'Buyer.' c_colon
                    into v_eknam.
      concatenate c_equal c_colon 'Vendor Code.' c_colon
                    into v_lifnr.
    concatenate
             v_po v_matnr v_maktx v_qty
             v_date v_name v_eknam v_lifnr
             into i_download
             SEPARATED BY con_tab.
      append i_download .
    clear : v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
    clear wa_output.
    loop at i_output into wa_output.
       on change of wa_output-ebeln.
         clear v_lines.
         loop at i_eket into wa_eket
                 where ebeln = wa_output-ebeln.
           v_lines = v_lines + 1.
           clear wa_eket.
         endloop.
    **-- Checking of page break
         v_lines = sy-linno + v_lines .
         if 55 < v_lines  .
           write:/0(161) sy-uline.
           new-page.
         endif.
      clear v_lines.
          loop at i_eket into wa_eket
                  where ebeln = wa_output-ebeln.
            v_lines = v_lines + 1.
            clear wa_eket.
          endloop.
    *-- Calculating the due qty.
        wa_output-dumng = wa_output-menge - wa_output-wemng.
    *-- Writing the Line items of the PO.
        read table i_ekpo into wa_ekpo
              with key ebeln = wa_output-ebeln
                       ebelp = wa_output-ebelp.
         l_rate = wa_ekpo-netpr / wa_ekpo-peinh.
    *-- Writing of PO detail
         if wa_output-dumng gt 0 .
         v_qty = wa_output-dumng.
        v_date1 = wa_output-eindt.
        v_maktx = wa_output-maktx.
         if wa_output-maktx+0(1) = '"' .
                concatenate  c_equal wa_output-maktx
                   into v_maktx  .
             else .
                concatenate  c_equal c_colon wa_output-maktx c_colon
                   into v_maktx  .
             endif .
       if wa_output-name1+0(1) = '"' .
                concatenate  c_equal wa_output-name1
                   into v_name  .
             else .
                concatenate  c_equal c_colon wa_output-name1 c_colon
                   into v_name  .
             endif .
        v_name = wa_output-name1.
        v_lifnr = wa_output-lifnr.
         write wa_output-eindt to v_date1 DD/MM/YYYY.
         concatenate '="' wa_output-ebeln '/'
                wa_output-ebelp '"' into v_po .
         concatenate '="' wa_output-matnr '"' into v_matnr .
             concatenate  c_equal c_colon wa_output-maktx c_colon
               into v_maktx  .
              concatenate  c_equal c_colon wa_output-dumng c_colon
               into v_qty1  .
               concatenate  c_equal c_colon wa_output-eindt c_colon
               into v_date1  .
              concatenate  c_equal c_colon wa_output-name1 c_colon
               into v_name  .
                concatenate  c_equal c_colon wa_output-eknam c_colon
                into v_eknam  .
              concatenate  c_equal c_colon wa_output-lifnr c_colon
               into v_lifnr  .
              concatenate  c_equal c_colon wa_mard-werks '/'
               wa_mard-lgort c_colon
               into v_lgort .
                 concatenate '="' wa_output-lifnr '"' into v_lifnr .
    condense:v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
         concatenate
             v_po v_matnr v_maktx v_qty
             v_date1 v_name v_eknam v_lifnr
             into i_download
             SEPARATED BY con_tab.
        concatenate con_cret i_download INTO i_download .
        append i_download .
      endif.
    clear : v_po,v_matnr, v_maktx, v_qty, v_date, v_name, v_eknam,v_lifnr .
    endloop.
    ENDFORM.                    " fill_report_csv
    *&      Form  f_send_internet_mail
          text
    -->  p1        text
    <--  p2        text
    FORM f_send_internet_mail.
    Variables
    data:   it_packing_list like sopcklsti1 occurs 0 with header line,
            it_contents like solisti1 occurs 0 with header line,
            it_receivers like somlreci1 occurs 0 with header line,
            it_attachment like solisti1 occurs 0 with header line,
            gd_cnt type i,
            gd_sent_all(1) type c,
            gd_doc_data like sodocchgi1,
            gd_error type sy-subrc.
    data:   it_message type standard table of SOLISTI1 initial size 0
                    with header line.
    data : found_receiver type c,
           v_title(80) type c,
           l_text(180) type c.
    Fill the document data.
      gd_doc_data-doc_size = 1.
    Adds text to email text table
      append 'Pls see attached open purchase order report.' to it_message.
      append '' to it_message.
      concatenate 'Note: This is system generated report'
                  ', figures may subject to actual physical count.'
                  into l_text separated by space.
      append l_text to it_message.
    Populate the subject/generic message attributes
      CLEAR gd_doc_data.
      READ TABLE i_download INDEX w_cnt.
      gd_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( i_download ).
      gd_doc_data-obj_langu  = sy-langu.
      gd_doc_data-obj_name   = 'SAPRPT'.
    if p_asdate is initial .
         concatenate p_title ' '
                  sy-datum sy-uzeit into v_title separated by space.
    else .
        concatenate p_title ' '
                 p_bldat p_cputm into v_title separated by space.
    endif .
      gd_doc_data-obj_descr  = v_title .
      gd_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = i_download[].
    Describe the body of the message
      clear it_packing_list.
      refresh it_packing_list.
      it_packing_list-transf_bin = space.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 0.
      it_packing_list-body_start = 1.
      describe table it_message lines it_packing_list-body_num.
      it_packing_list-doc_type = 'RAW'.
      append it_packing_list.
    Create attachment notification
      it_packing_list-transf_bin = 'X'.
      it_packing_list-head_start = 1.
      it_packing_list-head_num   = 1.
      it_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES it_packing_list-body_num.
      it_packing_list-doc_type   =  'XLS'.
      it_packing_list-obj_descr  =  'OPEN PURCHASE ORDER' .
      it_packing_list-obj_name   =  'PO.XLS' .
      it_packing_list-doc_size   =  it_packing_list-body_num * 255.
      APPEND it_packing_list.
    assign SAP user smtp address from successful retrieval.
      loop at p_email.
    Add the recipients email address
         found_receiver = 'X' .
         it_receivers-receiver = p_email-low.
         it_receivers-rec_type = 'U'.
         it_receivers-com_type = 'INT'.
         it_receivers-notif_del = ''.
         it_receivers-notif_ndel = 'X'.
         append it_receivers .
      endloop .
    Add default recipient email when unable to locate purc group email
       if found_receiver is initial .
           it_receivers-receiver = p_email.
           it_receivers-rec_type = 'U'.
           it_receivers-com_type = 'INT'.
           it_receivers-notif_del = ''.
           it_receivers-notif_ndel = 'X'.
          append it_receivers.
       endif .
    Call the FM to post the message to SAPMAIL
      call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           exporting
                document_data              = gd_doc_data
                put_in_outbox              = 'X'
                commit_work                = 'X'
           importing
                sent_to_all                = gd_sent_all
           tables
                packing_list               = it_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                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.
    Store function module return code
      gd_error = sy-subrc.
    Get it_receivers return code
      loop at it_receivers.
      endloop.
    Instructs mail send program for SAPCONNECT to send email.
      wait up to 2 seconds.
      if gd_error eq 0.
          submit rsconn01 with mode = 'INT'
                        with output = ' '
                        and return.
      endif.
    ENDFORM.                    " f_send_internet_mail

    ans

  • ALV output to be mailed in excel format

    Hi All,
    Currently we have a alv grid report, but my user requirement is he want this alv grid output to be mailed to his mail id in excel format.
    some times data may be huge of about 8000 - 10,000 lines.
    is it possiable.
    can any one help.

    hi check this code
    Here i'm posting u sample code try to execute it. It will convert all the data in the related tables to excel format and transfer it to respective mail id
    code&----
    *& Report ZTESTMAIL *
    REPORT ZTESTMAIL .
    tables: ekko.
    parameters: p_email type somlreci1-receiver .
    types: begin of t_ekpo,
    ebeln type ekpo-ebeln,
    ebelp type ekpo-ebelp,
    aedat type ekpo-aedat,
    matnr type ekpo-matnr,
    end of t_ekpo.
    data: it_ekpo type standard table of t_ekpo initial size 0,
    wa_ekpo type t_ekpo.
    types: begin of t_charekpo,
    ebeln(10) type c,
    ebelp(5) type c,
    aedat(8) type c,
    matnr(18) type c,
    end of t_charekpo.
    data: wa_charekpo type t_charekpo.
    data: it_message type standard table of solisti1 initial size 0
    with header line.
    data: it_attach type standard table of solisti1 initial size 0
    with header line.
    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,
    gd_error type sy-subrc,
    gd_reciever type sy-subrc.
    t_object_header = 'Text.xls'. append t_object_header.
    *START_OF_SELECTION
    start-of-selection.
    Retrieve sample data from table ekpo
    perform data_retrieval.
    Populate table with detaisl to be entered into .xls file
    perform build_xls_data_table.
    *END-OF-SELECTION
    end-of-selection.
    Populate message body text
    perform populate_email_message_body.
    Send file by email as .xls speadsheet
    perform send_file_as_email_attachment
    tables it_message
    it_attach
    using p_email
    'Example .xls documnet attachment'
    'XLS'
    'filename'
    changing gd_error
    gd_reciever.
    Instructs mail send program for SAPCONNECT to send email(rsconn01)
    perform initiate_mail_execute_program.
    *& Form DATA_RETRIEVAL
    Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp aedat matnr
    up to 10 rows
    from ekpo
    into table it_ekpo.
    endform. " DATA_RETRIEVAL
    *& Form BUILD_XLS_DATA_TABLE
    Build data table for .xls document
    form build_xls_data_table.
    *CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
    *con_tab TYPE x VALUE '09'. "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    constants:
    con_tab type c value cl_abap_char_utilities=>horizontal_tab,
    con_cret type c value cl_abap_char_utilities=>cr_lf.
    concatenate 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
    into it_attach separated by con_tab.
    concatenate con_cret it_attach into it_attach.
    append it_attach.
    loop at it_ekpo into wa_charekpo.
    concatenate wa_charekpo-ebeln wa_charekpo-ebelp
    wa_charekpo-aedat wa_charekpo-matnr
    into it_attach separated by con_tab.
    concatenate con_cret it_attach into it_attach.
    append it_attach.
    endloop.
    endform. " BUILD_XLS_DATA_TABLE
    *& Form SEND_FILE_AS_EMAIL_ATTACHMENT
    Send email
    form send_file_as_email_attachment tables pit_message
    pit_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.
    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] = pit_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
    object_header = t_object_header
    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.
    *& Form INITIATE_MAIL_EXECUTE_PROGRAM
    Instructs mail send program for SAPCONNECT to send email.
    form initiate_mail_execute_program.
    wait up to 2 seconds.
    submit rsconn01 with mode = 'INT'
    with output = 'X'
    and return.
    endform. " INITIATE_MAIL_EXECUTE_PROGRAM
    *& Form POPULATE_EMAIL_MESSAGE_BODY
    Populate message body text
    form populate_email_message_body.
    refresh it_message.
    it_message = 'Please find attached a list test ekpo records'.
    append it_message.
    endform. " POPULATE_EMAIL_MESSAGE_BODY
    *PARAMETERS: psubject(40) type c default 'Testing',
    *p_email(40) type c . "use ur email id
    *data: it_packing_list like sopcklsti1 occurs 0 with header line,
    *it_contents like solisti1 occurs 0 with header line,
    *it_receivers like somlreci1 occurs 0 with header line,
    *it_attachment like solisti1 occurs 0 with header line,
    *gd_cnt type i,
    *gd_sent_all(1) type c,
    *gd_doc_data like sodocchgi1,
    *gd_error type sy-subrc.
    *data: it_message type standard table of SOLISTI1 initial size 0
    *with header line.
    **START-OF-SELECTION.
    *START-OF-SELECTION.
    *Perform populate_message_table.
    **Send email message, although is not sent from SAP until mail send
    **program has been executed(rsconn01)
    *PERFORM send_email_message.
    **Instructs mail send program for SAPCONNECT to send email(rsconn01)
    *perform initiate_mail_execute_program.
    **& Form POPULATE_MESSAGE_TABLE
    Adds text to email text table
    *form populate_message_table.
    *Append 'Line1' to it_message.
    *Append 'Line2' to it_message.
    *Append 'Line3' to it_message.
    *Append 'Test- 1' to it_message.
    *endform. " POPULATE_MESSAGE_TABLE
    **& Form SEND_EMAIL_MESSAGE
    Send email message
    *form send_email_message.
    Fill the document data.
    *gd_doc_data-doc_size = 1.
    DATA: TAB_LINES LIKE sy-tabix.
    DESCRIBE TABLE it_message LINES TAB_LINES.
    READ TABLE it_message INDEX TAB_LINES.
    gd_doc_data-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( it_message )
    Populate the subject/generic message attributes
    *gd_doc_data-obj_langu = sy-langu.
    *gd_doc_data-obj_name = 'SAPRPT'.
    *gd_doc_data-obj_descr = psubject.
    *gd_doc_data-sensitivty = 'F'.
    Describe the body of the message
    Information about structure of data tables
    *clear it_packing_list.
    *refresh it_packing_list.
    *it_packing_list-transf_bin = space.
    *it_packing_list-head_start = 1.
    *it_packing_list-head_num = 0.
    *it_packing_list-body_start = 1.
    *describe table it_message lines it_packing_list-body_num.
    *it_packing_list-doc_type = 'RAW'.
    *append it_packing_list.
    Add the recipients email address
    *clear it_receivers.
    *refresh it_receivers.
    *it_receivers-receiver = p_email.
    *it_receivers-rec_type = 'U'.
    it_receivers-com_type = 'INT'.
    it_receivers-notif_del = 'X'.
    it_receivers-notif_ndel = 'X'.
    *append it_receivers.
    Call the FM to post the message to SAPMAIL
    *call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    *exporting
    *document_data = gd_doc_data
    *put_in_outbox = 'X'
    *importing
    *sent_to_all = gd_sent_all
    *tables
    *packing_list = it_packing_list
    *contents_txt = it_message
    *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.
    Store function module return code
    *gd_error = sy-subrc.
    Get it_receivers return code
    *loop at it_receivers.
    *endloop.
    *endform. " SEND_EMAIL_MESSAGE
    **& Form INITIATE_MAIL_EXECUTE_PROGRAM
    Instructs mail send program for SAPCONNECT to send email.
    *form initiate_mail_execute_program.
    *wait up to 2 seconds.
    *if gd_error eq 0.
    *submit rsconn01 with mode = 'INT'
    *with output = 'X'
    *and return.
    *endif.
    *endform. " INITIATE_MAIL_EXECUTE_PROGRAM
    [/code]

  • Need to choose fields from alv grid output and send mail

    Hi,
    I need to choose few orders from alv grid output and send mail as PDF for chosen orders.
    Suggest if possible and how.

    Moderator message - Please do not post your requirements and ask the forum to do your work for you - post locked
    Rob

  • Send the billing output by e-mail for the user

    Hi,
    Can you tell me if it's possible to send the billing output by e-mail (Medium = 5 - External send) for the user that create the billing document? the e-mail of the user is in SU01D.
    Thanks in advance
    Dora

    Hi Dora,
    What you can do is when you want to send a mail to customer after you receive the email for bill is do the following settings.
    1) Create a condition record VV31 with the required Key combination where you can give the name of the Employee or end user with the email id.
    2) Select the trasmission medium as 7 ( Simple Mail)
    3) Once the Billing is done E-Mail will be triggered.
    4) Downlaod it or forward it to your client with the additional text in the E-Mail.
    Hope this helps.
    Thanks and Regards
    Rohit Dujari

  • Quotation output through e-mail

    Hi All,
    I am working on quotation, i need to send quotation output through e-mail to distributors, i am not finding output type(Method)  e-mail in output types in IMG , please help in how to configure this.send me any document related to this to the email ID [email protected]
    Regards
    satya

    Hi Satya,
                Please make sure the following configurations are done.
    1. Goto transaction v/30 choose the output type(SAP provides default output type MAIL for sending emails). Go to the detail view of the output type and to the tab -> default value, Select the transamission medium Simple mail , In the partner functions select the partner function MP.
    2.Goto spro->output control settings, Make sure that this output type is added to the output determination procedure.
    3.Make sure that the output det procedure is assigned to the sales document header or at the item level.
    4.Maintain the condition records for the output type.
    If all these settings are apt in your system, You shudn't have any problems in getting the ouput generated.
    Let me know if your problem is solved..
    Regards,
    Girish

  • Output by E-mail

    Hi friends,
    Please help me out . How to configure the billing output by E-mail to customer
    Thanks
    Sai

    Hi Sai Krishna,
    If your SD output configuration is set up correctly, an e-mail from SAP using medium 5 should go through just fine via SAPconnect (transaction SCOT). When it works, the external recipient should receive an e-mail with a PDF attachment containing the form image, regardless of whether it has been created via SAPscript or Smart Forms. Depending on your output determination settings, this even can happen in the background, without any interaction with the SAP front end (e.g. for invoices created automatically by a batch job).
    Typically, a failed send will be flagged in the message control table (NAST), and this table should be monitored closely. However, there are many reasons why a document hasn't gone through, and this can be the case with both outgoing faxes and e-mails from SAP. The solution to both is the same: After identifying the failed document, re-send it manually by going inside it in change mode and repeating the appropriate output. If an obsolete customer e-mail address was the culprit, a customer master change would also be required, along with an audit of any docs recently created for this customer.
    If any underlying data has changed since initial issuance, a re-sent document may not appear identical to the (failed) original. Sometimes, as when address info has been corrected, this can be a good thing. After all, the new document is more accurate than the old one.
    In other cases, such as when pricing info has changed, it might be a cause for serious concern. There are several ways to deal with this concern:
    1) Limit the types of changes allowed on certain docs after creation
    2) Set up a doc image archive via ArchiveLink and re-issue output from there instead of from the current doc; or
    3) For highly sensitive docs, consider a more secure delivery method.
    REFER BELOW LINK
    Sending a Smart Form output via e-mail
    you need to maintain the email address of the customer in the customer master and then need to configure the output type in the NACE transction .and in the settings choose the medium as email.
    http://help.sap.com/saphelp_nw04/helpdata/en/dc/6b7c9f43d711d1893e0000e8323c4f/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/69/e5cb365f6511d2b458006094b9476a/content.htm
    check the above links
    Rewards if Helpful...
    Regards...
    Praveen Kumar.D

  • Function Module to send output list to mail.

    Hi,
    Could anyone let me know the function module to send output list to mail.
    Regards,
    Ramesh

    Hi,
    Please try with following sample code
    Sending mail with attachment
    This program will allowed you to send email with attachment.
    First, specify the attachment file from your local hardisk and execute.
    Next, specify the sender email address and click the send button.
    report YUP_MAIL.
    data method1 like sy-ucomm.
    data g_user like soudnamei1.
    data g_user_data like soudatai1.
    data g_owner like soud-usrnam.
    data g_receipients like soos1 occurs 0 with header line.
    data g_document like sood4 .
    data g_header like sood2.
    data g_folmam like sofm2.
    data g_objcnt like soli occurs 0 with header line.
    data g_objhead like soli occurs 0 with header line.
    data g_objpara  like selc occurs 0 with header line.
    data g_objparb  like soop1 occurs 0 with header line.
    data g_attachments like sood5 occurs 0 with header line.
    data g_references like soxrl occurs 0 with header line.
    data g_authority like sofa-usracc.
    data g_ref_document like sood4.
    data g_new_parent like soodk.
    data: begin of g_files occurs 10 ,
      text(4096) type c,
       end of g_files.
    data : fold_number(12) type c,
           fold_yr(2) type c,
           fold_type(3) type c.
    parameters ws_file(4096) type c default 'c:\debugger.txt'.
    Can me any file fromyour pc ....either xls or word or ppt etc ...
    g_user-sapname = sy-uname.
    call function 'SO_USER_READ_API1'
    exporting
       user                            = g_user
       PREPARE_FOR_FOLDER_ACCESS       = ' '
    importing
       user_data                       = g_user_data
    EXCEPTIONS
       USER_NOT_EXIST                  = 1
       PARAMETER_ERROR                 = 2
       X_ERROR                         = 3
       OTHERS                          = 4
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    fold_type = g_user_data-outboxfol+0(3).
    fold_yr = g_user_data-outboxfol+3(2).
    fold_number =  g_user_data-outboxfol+5(12).
    clear g_files.
    refresh : g_objcnt,
      g_objhead,
      g_objpara,
      g_objparb,
      g_receipients,
      g_attachments,
      g_references,
      g_files.
    method1 = 'SAVE'.
    g_document-foltp  = fold_type.
    g_document-folyr   = fold_yr.
    g_document-folno   = fold_number.
    g_document-objtp   = g_user_data-object_typ.
    *g_document-OBJYR   = '27'.
    *g_document-OBJNO   = '000000002365'.
    *g_document-OBJNAM = 'MESSAGE'.
    g_document-objdes   = 'sap-img.com testing by program'.
    g_document-folrg   = 'O'.
    *g_document-okcode   = 'CHNG'.
    g_document-objlen = '0'.
    g_document-file_ext = 'TXT'.
    g_header-objdes =  'sap-img.com testing by program'.
    g_header-file_ext = 'TXT'.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = sy-uname
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header
      FOLMEM_DATA        =
      RECEIVE_DATA       =
    File from the pc to send...
    method1 = 'ATTCREATEFROMPC'.
    g_files-text = ws_file.
    append g_files.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = g_owner
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header
    method1 = 'SEND'.
    g_receipients-recnam = 'MK085'.
    g_receipients-recesc = 'B'.
    g_receipients-sndex = 'X'.
    append  g_receipients.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = g_owner
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header.
    *-- End of Program
    Thanks,
    -Pramod

  • Report output send through mail

    Dear friends,
    Looking for sample report to send the report output through external mail on execution.
    Regards,
    Praveen Lobo

    *& Report  ZKB_EMAIL
    REPORT  zkb_email NO STANDARD PAGE HEADING LINE-SIZE 200.
    TABLES: ekko.
    PARAMETERS: p_email TYPE somlreci1-receiver
    DEFAULT '<b>WRITE EMAIL ID EG [email protected]'</b>.
    Output Table
    TYPES: BEGIN OF t_ekpo,
    ebeln TYPE ekpo-ebeln,
    ebelp TYPE ekpo-ebelp,
    aedat TYPE ekpo-aedat,
    matnr TYPE ekpo-matnr,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
    wa_ekpo TYPE t_ekpo.
    TYPES: BEGIN OF t_charekpo,
    ebeln(10) TYPE c,
    ebelp(5) TYPE c,
    aedat(8) TYPE c,
    matnr(18) TYPE c,
    END OF t_charekpo.
    DATA: wa_charekpo TYPE t_charekpo.
    Mail Parameters
    DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
    WITH HEADER LINE.
    DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
    WITH HEADER LINE.
    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,
    gd_error TYPE sy-subrc,
    gd_reciever TYPE sy-subrc.
    *START_OF_SELECTION
    START-OF-SELECTION.
    Retrieve sample data from table ekpo
      PERFORM data_retrieval.
    Populate table with detaisl to be entered into .xls file
      PERFORM build_xls_data_table.
    *END-OF-SELECTION
    END-OF-SELECTION.
    Populate message body text
      PERFORM populate_email_message_body.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment   TABLES it_message   it_attach
      USING p_email 'Example .xls documnet attachment'  'XLS'  'filename'
      CHANGING gd_error
      gd_reciever.
    Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM initiate_mail_execute_program.
    *& Form DATA_RETRIEVAL
    Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp aedat matnr
      UP TO 10 ROWS
      FROM ekpo
      INTO TABLE it_ekpo.
    ENDFORM. " DATA_RETRIEVAL
    *& Form BUILD_XLS_DATA_TABLE
    Build data table for .xls document
    FORM build_xls_data_table.
      CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
                 con_tab TYPE x VALUE '09'. "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    *constants:
    con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
    con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'  INTO it_attach SEPARATED BY space.
      CONCATENATE space it_attach INTO it_attach.
      APPEND it_attach.
      LOOP AT it_ekpo INTO wa_charekpo.
        CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
        wa_charekpo-aedat wa_charekpo-matnr
        INTO it_attach SEPARATED BY space .
        CONCATENATE space it_attach INTO it_attach.
        APPEND it_attach.
      ENDLOOP.
    ENDFORM. " BUILD_XLS_DATA_TABLE
    *& Form SEND_FILE_AS_EMAIL_ATTACHMENT
    Send email
    FORM send_file_as_email_attachment TABLES pit_message
    pit_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.
      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'.
      w_doc_data-skip_scren = 'X'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = pit_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'.
      APPEND t_receivers.
      CLEAR t_receivers.
      t_receivers-receiver = sy-uname. " replace with <login name>
      t_receivers-rec_type = 'B'.
      t_receivers-express = 'X'.
      APPEND t_receivers.
      CLEAR 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.                    "SEND_FILE_AS_EMAIL_ATTACHMENT
    *& Form INITIATE_MAIL_EXECUTE_PROGRAM
    Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
    WITH output = 'X'
      AND RETURN.
    ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
    *& Form POPULATE_EMAIL_MESSAGE_BODY
    Populate message body text
    FORM populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test ekpo records'.
      APPEND it_message.
    ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY
    Rewards if useful.............
    Minal

  • User exit to change vendor e-mail address used for PO output via e-mail...

    We have two vendor e-mail addresses for a particular vendor. Ignoring output determination, it looks like I will need to control which of the two e-mail vendor addresses is used when the PO is output via e-mail.
    The default is the first one e-mail address, but for PO's I would like to force the second vendor e-mail address.
    There are tonnes of exits available for PO output by the looks of it so I am trying to discover which is relevant for what I am trying to achieve.
    Jas
    Edited by: Jason Stratham on Apr 30, 2009 5:53 PM

    Thanks Martin,
    I guess that's the same path that I took earlier when using SPRO and looking at the Purchasing->Messages. In my case it's ZMEDRUCK, but that does not help me in regards to controlling the vendors e-mail address being used. When sending the PO as an e-mail it uses (by default) the first e-mail address of the Vendor, whereas the vendor could have multiple ones. In my test case my vendor has two addresses but it always defaults to using the first. I know that I need to modify this behaviour somehow, but how I have no idea as I can find no Exit routine.
    Jas

  • Task Outputs Send e-mail message

    Hi all,
    When I run a task from scom operations console, a new window opens and I can see the result and task output as usual.
    Is it possible to send that task output via e-mail message to corresponding department'e e-mail address.
    Regards.

    Hi,
    In addition, for more information and usage about the commands Get-Task and Get-TaskResult, please also refer to:
    Get-Task
    http://technet.microsoft.com/en-us/library/gg132265.aspx
    Get-TaskResult
    http://technet.microsoft.com/en-us/library/gg132216.aspx
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • IPhone 5S: random reboot triggers vanished apps (Settings, Mail, Phone and more...)

    For the last day or so, a high percentage of apps that I'd tried launching crashed instantly on my iPhone 5S with iOS 7.0.6. Reboot didn't help that problem. Facebook app, for example, still opens briefly and a second later crashes. Every. Time.
    Cut to this morning when my phone rebooted itself randomly and upon returning, many apps had vanished including system apps including Phone, Settings and Mail as well as Tweetbot, Google Voice,Kindle and much more). None of these apps show up in Spotlight search at all. App Store has, for the apps that are missing (at least the few I spot checked)  an OPEN button instead of download. But when I hit the OPEN button nothing at all happens.
    I can't make calls. I can't check or send emails. I can't use many of the apps actually on my phone still. I can't reset even without my Settings app.
    What happened and what do I do? Does this require a trip to my local Apple Genius?  Never seen this before and I've had an iPhone sine day one.
    Anybody? Thank you in advance for any ideas, advise and suggestions...

    Thanks, Jim. Sadly this doesn't appear to be possible at this point. I can't restore my phone from iTunes as it asks me to turn off Find My Phone in my phone's settings app which is no longer an app accessible on my phone. Sigh.

  • How to Convert internal table data into text output and send mail in ABAP

    Hi All,
    Good Morning.
    Taking a glance at a code that converts internal table data to an Excel file in ABAP. also checked how to send this excel to mailing list as attachment.
    But thought of doing it without excel.
    I mean, I have an internal table which contains fields of all types (character,integer,date,time). Since it is only around 4 to 5 rows in it (output),why to convert it to excel. not required!!.  Instead I  want to send this output to User's mails as Normal mail body with No attachments.
    Could anybody please suggest me a way as to how to send internal table data as a mail ( not as an excel or PDF etc).
    as of now my findings are, it is quite complex to convert internal table data to email (Text) format. but i believe if there is some way of doing it.
    Best Regards
    Dileep VT

    here's something I have used in the past where we send out information about failed precalculation settings (which are stored in internal table gt_fail)
    notice we use gt_text as "mail body"
    TRY.
    *     -------- create persistent send request ------------------------
           gv_send_request = cl_bcs=>create_persistent( ).
    *     -------- create and set document -------------------------------
    *     create text to be sent
           wa_line = text-001.
           APPEND wa_line TO gt_text.
           CLEAR wa_line.
           APPEND wa_line TO gt_text.
           LOOP AT gt_fail ASSIGNING <fs_fail>.
             MOVE <fs_fail>-retry_count TO gv_count.
             CONCATENATE text-002
                         <fs_fail>-setting_id
                         text-003
                         gv_count
                         INTO wa_line SEPARATED BY space.
             APPEND wa_line TO gt_text.
             CLEAR wa_line.
           ENDLOOP.
           APPEND wa_line TO gt_text.
           wa_line = text-007.
           APPEND wa_line TO gt_text.
    *     create actual document
           gv_document = cl_document_bcs=>create_document(
                           i_type    = 'RAW'
                           i_text    = gt_text
                           i_length  = '12'
                           i_subject = 'Failed Precalculation Settings!' ).
    *     add document to send request
           CALL METHOD gv_send_request->set_document( gv_document ).
    *     --------- set sender -------------------------------------------
           gv_sender = cl_sapuser_bcs=>create( sy-uname ).
           CALL METHOD gv_send_request->set_sender
             EXPORTING
               i_sender = gv_sender.
    *     --------- add recipient (e-mail address) -----------------------
           LOOP AT s_email INTO wa_email.
             MOVE wa_email-low TO gv_email.
             gv_recipient = cl_cam_address_bcs=>create_internet_address(
                                               gv_email ).
             CALL METHOD gv_send_request->add_recipient
               EXPORTING
                 i_recipient = gv_recipient
                 i_express   = 'X'.
           ENDLOOP.
    *     ---------- set to send immediately -----------------------------
           CALL METHOD gv_send_request->set_send_immediately( 'X' ).
    *     ---------- send document ---------------------------------------
           CALL METHOD gv_send_request->send(
             EXPORTING
               i_with_error_screen = 'X'
             RECEIVING
               result              = gv_sent_to_all ).
           IF gv_sent_to_all = 'X'.
             WRITE text-004.
           ENDIF.
           COMMIT WORK.
    *   exception handling
         CATCH cx_bcs INTO gv_bcs_exception.
           WRITE: text-005.
           WRITE: text-006, gv_bcs_exception->error_type.
           EXIT.
       ENDTRY.
    with the following declarations
    * TABLES                                                               *
    TABLES:
       adr6,
       rsr_prec_sett.
    * INTERNAL TABLES & WORK AREAS                                         *
    DATA:
       gt_fail          TYPE SORTED TABLE OF rsr_prec_sett
                             WITH UNIQUE KEY setting_id run_date,
       gt_text          TYPE bcsy_text,
       wa_fail          LIKE LINE OF gt_fail,
       wa_line(90)      TYPE c.
    FIELD-SYMBOLS:
       <fs_fail>        LIKE LINE OF gt_fail.
    * VARIABLES                                                            *
    DATA:
       gv_count(4)      TYPE n,
       gv_send_request  TYPE REF TO cl_bcs,
       gv_document      TYPE REF TO cl_document_bcs,
       gv_sender        TYPE REF TO cl_sapuser_bcs,
       gv_recipient     TYPE REF TO if_recipient_bcs,
       gv_email         TYPE adr6-smtp_addr,
       gv_bcs_exception TYPE REF TO cx_bcs,
       gv_sent_to_all   TYPE os_boolean.
    * SELECTION-SCREEN                                                     *
    SELECT-OPTIONS:
       s_email          FOR adr6-smtp_addr NO INTERVALS MODIF ID sel.
    DATA:
       wa_email         LIKE LINE OF s_email.

  • Sending ALV output in a mail in PDF format

    Hi folks,
                I have a requiremtnt. If i execute my ALV report in background, the output should be sent to the reciepient's mail in pdf format. i have used the function moudles CONVERT_ABAPSPOOLJOB_2_PDF and SO_DOCUMENT_SEND_API1. Now i am able to see my report output in spool in some pdf formt. how can i send this to the reciever mail as an attachement...pls send me any sample report which suits my reqirement...thanks in advance,
               Ram.

    REPORT ZSAP_EMAIL MESSAGE-ID Z001.
    *TABLES: rlgrap, btcxpm." zlookup.
    DATA:
    V_ZCODE(3) TYPE C,
    *svrname LIKE zlookup-zdesc,
    WA_ERROR(80) TYPE C,
    GLOBAL_FILEMASK_ALL(80).
    DATA: T_SOUD LIKE SOUD.
    DATA: P_INFOLDER LIKE SOFDK.
    DATA: P_OUTFOLDER LIKE SOFDK.
    DATA: OBJECT_HD_DISPLAY LIKE SOOD2.
    DATA: OBJECT_ID LIKE SOODK.
    DATA: DOCUMENT LIKE SOOD4.
    DATA: HEADER_DATA LIKE SOOD2.
    DATA: LINK_FOLDER_ID LIKE SOODK.
    DATA: FOLDER_SELECTIONS LIKE SOFDS.
    DATA: FOLDER_LIST LIKE SOXLI OCCURS 0 WITH HEADER LINE.
    DATA: RECEIVERS LIKE SOOS1 OCCURS 0 WITH HEADER LINE.
    DATA: OBJCONT LIKE SOLI OCCURS 0 WITH HEADER LINE.
    DATA: OBJHEAD LIKE SOLI OCCURS 0 WITH HEADER LINE.
    DATA: OBJECT_CONTENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
    DATA: OBJECT_HD_CHANGE LIKE SOOD1.
    DATA: BEGIN OF FILES OCCURS 0,
    LINE(200) TYPE C,
    END OF FILES.
    DATA: LISTOBJECT LIKE ABAPLIST OCCURS 1 WITH HEADER LINE.
    *Email to addresses
    SELECTION-SCREEN: BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-BL1.
    PARAMETERS: P_MAILTO(240) TYPE C.
    *PARAMETERS:P_MAILTO TYPE SOLI-LINE.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN COMMENT 10(2) TEXT-001.
    *Use zlookup-ztype as group to define multiple email to addresses
    *SELECT-OPTIONS: s_mailto FOR zlookup-ztype.
    SELECTION-SCREEN: END OF BLOCK BL1.
    *Subject
    SELECTION-SCREEN: BEGIN OF BLOCK BL2 WITH FRAME TITLE TEXT-BL2.
    PARAMETERS: P_SUBJ LIKE DOCUMENT-OBJDES.
    SELECTION-SCREEN: END OF BLOCK BL2.
    *Body
    SELECTION-SCREEN: BEGIN OF BLOCK BL3 WITH FRAME TITLE TEXT-BL3.
    PARAMETERS: P_BODY1 LIKE SOLISTI1-LINE LOWER CASE.
    PARAMETERS: P_BODY2 LIKE SOLISTI1-LINE LOWER CASE.
    PARAMETERS: P_BODY3 LIKE SOLISTI1-LINE LOWER CASE.
    PARAMETERS: P_BODY4 LIKE SOLISTI1-LINE LOWER CASE.
    PARAMETERS: P_BODY5 LIKE SOLISTI1-LINE LOWER CASE.
    PARAMETERS: P_BODY6 LIKE SOLISTI1-LINE LOWER CASE.
    SELECTION-SCREEN: END OF BLOCK BL3.
    *Attachments
    SELECTION-SCREEN: BEGIN OF BLOCK BL4 WITH FRAME TITLE TEXT-BL4.
    PARAMETERS: P_FNAME1 LIKE FILES-LINE.
    PARAMETERS: P_FNAME2 LIKE FILES-LINE.
    PARAMETERS: P_FNAME3 LIKE FILES-LINE.
    PARAMETERS: P_FNAME4 LIKE FILES-LINE.
    PARAMETERS: P_FNAME5 LIKE FILES-LINE.
    PARAMETERS: P_FNAME6 LIKE FILES-LINE.
    SELECTION-SCREEN: END OF BLOCK BL4.
    AT SELECTION-SCREEN.
      PERFORM CHK_SELECTION.
      IF NOT WA_ERROR IS INITIAL.
        MESSAGE E001 WITH WA_ERROR.
      ENDIF.
    START-OF-SELECTION.
    END-OF-SELECTION.
      PERFORM SEND_EMAIL.
    FORM chk_selection
    FORM CHK_SELECTION.
      CLEAR WA_ERROR.
    *Loop only once ???
    *If more checkings to be done.
    *Think about it and if not clear.
    *Let it sink in for a couple of minutes.
    *Still doesn't make sence? Go home and sleep on it.
      DO 1 TIMES.
    *Check Email to
        IF P_MAILTO IS INITIAL .
    *AND s_mailto IS INITIAL.
          WA_ERROR = 'Invalid or no EMAIL TO selection'.
          EXIT.
        ENDIF.
      ENDDO.
    ENDFORM.                    "chk_selection
    *& Form send_email
    *text
    *--> p1 text
    *<-- p2 text
    FORM SEND_EMAIL.
      PERFORM GET_FOLDER_INFO.
      PERFORM FILL_BODY.
      PERFORM INS_NEW_OBJECT.
      PERFORM CRT_ATTACHMENTS.
      PERFORM FILL_RECEIVERS_INFO.
      PERFORM SND_EMAIL.
    ENDFORM. " send_email
    *--+--
    *FORM Get_folder_info
    FORM GET_FOLDER_INFO.
      CLEAR T_SOUD.
    *Small so should be quick.
      SELECT * FROM SOUD
      INTO T_SOUD
      WHERE SAPNAM = SY-UNAME.
        P_INFOLDER-FOLTP = 'FOL'.
        P_INFOLDER-FOLYR = T_SOUD-INBYR. "inbox
        P_INFOLDER-FOLNO = T_SOUD-INBNO.
        P_OUTFOLDER-FOLTP = 'FOL'.
        P_OUTFOLDER-FOLYR = T_SOUD-OUTYR. "outbox
        P_OUTFOLDER-FOLNO = T_SOUD-OUTNO.
      ENDSELECT.
    ENDFORM.                    "get_folder_info
    *FORM fill_body *
    FORM FILL_BODY.
      OBJECT_CONTENT-LINE = P_BODY1.
      APPEND OBJECT_CONTENT.
      OBJECT_CONTENT-LINE = P_BODY2.
      APPEND OBJECT_CONTENT.
      OBJECT_CONTENT-LINE = P_BODY3.
      APPEND OBJECT_CONTENT.
      OBJECT_CONTENT-LINE = P_BODY4.
      APPEND OBJECT_CONTENT.
      OBJECT_CONTENT-LINE = P_BODY5.
      APPEND OBJECT_CONTENT.
      OBJECT_CONTENT-LINE = P_BODY6.
      APPEND OBJECT_CONTENT.
    ENDFORM.                    "fill_body
    *FORM ins_new_object *
    FORM INS_NEW_OBJECT.
      OBJECT_HD_CHANGE-OBJNAM = 'Notes'.
      OBJECT_HD_CHANGE-OBJDES = P_SUBJ.
      CALL FUNCTION 'SO_OBJECT_INSERT'
        EXPORTING
          FOLDER_ID                  = P_OUTFOLDER
          OBJECT_HD_CHANGE           = OBJECT_HD_CHANGE
          OBJECT_TYPE                = 'RAW'
          OWNER                      = SY-UNAME
        IMPORTING
          OBJECT_HD_DISPLAY          = OBJECT_HD_DISPLAY
          OBJECT_ID                  = OBJECT_ID
        TABLES
          OBJCONT                    = OBJECT_CONTENT
          OBJHEAD                    = OBJHEAD
        EXCEPTIONS
          ACTIVE_USER_NOT_EXIST      = 1
          COMMUNICATION_FAILURE      = 2
          COMPONENT_NOT_AVAILABLE    = 3
          DL_NAME_EXIST              = 4
          FOLDER_NOT_EXIST           = 5
          FOLDER_NO_AUTHORIZATION    = 6
          OBJECT_TYPE_NOT_EXIST      = 7
          OPERATION_NO_AUTHORIZATION = 8
          OWNER_NOT_EXIST            = 9
          PARAMETER_ERROR            = 10
          SUBSTITUTE_NOT_ACTIVE      = 11
          SUBSTITUTE_NOT_DEFINED     = 12
          SYSTEM_FAILURE             = 13
          X_ERROR                    = 14
          OTHERS                     = 15.
      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.                    "ins_new_object
    *FORM crt_attachments *
    *--> P_SUBJ *
    FORM CRT_ATTACHMENTS.
      DOCUMENT-FOLTP = P_OUTFOLDER-FOLTP.
      DOCUMENT-FOLYR = P_OUTFOLDER-FOLYR.
      DOCUMENT-FOLNO = P_OUTFOLDER-FOLNO.
      DOCUMENT-OBJTP = OBJECT_ID-OBJTP.
      DOCUMENT-OBJYR = OBJECT_ID-OBJYR.
      DOCUMENT-OBJNO = OBJECT_ID-OBJNO.
      DOCUMENT-OBJNAM = 'Notes'.
      DOCUMENT-OBJDES = P_SUBJ.
      DOCUMENT-OKCODE = 'CHNG'.
      DOCUMENT-FILE_EXT = 'TXT'.
      LINK_FOLDER_ID = OBJECT_ID.
      HEADER_DATA-OBJLA = 'EN'.
      HEADER_DATA-OBJNAM = DOCUMENT-OBJNAM.
      HEADER_DATA-OBJDES = DOCUMENT-OBJDES.
      HEADER_DATA-OBJPRI = '5'.
      HEADER_DATA-OBJSNS = 'O'.
      HEADER_DATA-FILE_EXT = 'TXT'.
      REFRESH FILES.
      CLEAR FILES.
      IF NOT P_FNAME1 IS INITIAL.
        FILES-LINE = P_FNAME1.
        APPEND FILES.
      ENDIF.
      IF NOT P_FNAME2 IS INITIAL.
        FILES-LINE = P_FNAME2.
        APPEND FILES.
      ENDIF.
      IF NOT P_FNAME3 IS INITIAL.
        FILES-LINE = P_FNAME3.
        APPEND FILES.
      ENDIF.
      IF NOT P_FNAME4 IS INITIAL.
        FILES-LINE = P_FNAME4.
        APPEND FILES.
      ENDIF.
      IF NOT P_FNAME5 IS INITIAL.
        FILES-LINE = P_FNAME5.
        APPEND FILES.
      ENDIF.
      IF NOT P_FNAME6 IS INITIAL.
        FILES-LINE = P_FNAME6.
        APPEND FILES.
      ENDIF.
      IF NOT FILES[] IS INITIAL.
        CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
          EXPORTING
            METHOD      = 'ATTCREATEFROMPC'
          TABLES
            FILES       = FILES
          CHANGING
            DOCUMENT    = DOCUMENT
            HEADER_DATA = HEADER_DATA.
        IF SY-SUBRC = 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.
    ENDFORM.                    "crt_attachments
    *FORM fill_receivers_info *
    FORM FILL_RECEIVERS_INFO.
      DATA: BEGIN OF RECLIST OCCURS 0,
      REC LIKE RECEIVERS-RECEXTNAM,
      END OF RECLIST.
    *Build reclist
      REFRESH RECLIST.
      IF NOT P_MAILTO IS INITIAL.
        RECLIST-REC = P_MAILTO.
        APPEND RECLIST.
      ENDIF.
    *IF NOT s_mailto IS INITIAL.
    *SELECT zdesc
    *INTO reclist-rec
    *FROM zlookup
    *WHERE ztype IN s_mailto.
    *APPEND reclist.
    *ENDSELECT.
    *ENDIF.
      REFRESH RECEIVERS.
      LOOP AT RECLIST.
        FOLDER_SELECTIONS-FOLNAM = 'INBOX'.
        CALL FUNCTION 'SO_FOLDER_LIST_READ'
          EXPORTING
            FOLDER_SELECTIONS          = FOLDER_SELECTIONS
            OWNER                      = SY-UNAME
            REGION                     = 'P'
          TABLES
            FOLDER_LIST                = FOLDER_LIST
          EXCEPTIONS
            COMPONENT_NOT_AVAILABLE    = 1
            OPERATION_NO_AUTHORIZATION = 2
            OWNER_NOT_EXIST            = 3
            PARAMETER_ERROR            = 4
            X_ERROR                    = 5
            OTHERS                     = 6.
        IF SY-SUBRC = 0.
          CLEAR RECEIVERS.
          MOVE: SY-DATUM TO RECEIVERS-RCDAT,
      SY-UZEIT TO RECEIVERS-RCTIM,
      ' ' TO RECEIVERS-RECESC,
      P_MAILTO TO RECEIVERS-RECNAM,
      'X' TO RECEIVERS-SNDEX.
          APPEND RECEIVERS.
         RECEIVERS-RCDAT = SY-DATUM.
         RECEIVERS-RCTIM = SY-UZEIT.
         RECEIVERS-RECNAM = RECLIST-REC.
         RECEIVERS-RECNO = FOLDER_LIST-PARNO.
         RECEIVERS-RECTP = FOLDER_LIST-PARTP.
         RECEIVERS-RECYR = FOLDER_LIST-PARYR.
         RECEIVERS-SNDTP = FOLDER_LIST-PARTP.
         RECEIVERS-SNDYR = FOLDER_LIST-PARYR.
         RECEIVERS-SNDNO = FOLDER_LIST-PARNO.
         RECEIVERS-SNDNAM = SY-UNAME.
         RECEIVERS-SNDPRI = '1'.
         RECEIVERS-MSGID = 'SO'.
         RECEIVERS-MSGNO = '619'.
         RECEIVERS-DELIVER = 'X'.
         RECEIVERS-NOT_DELI = 'X'.
         RECEIVERS-READ = 'X'.
         RECEIVERS-MAILSTATUS = 'E'.
    **receivers-ADR_NAME
         RECEIVERS-RESEND = ' '.
         RECEIVERS-SORTFIELD = ' '. "'USER WF_BATCH INDIGO BATCH'.
         RECEIVERS-SORTCLASS = '5'.
         APPEND RECEIVERS.
        ELSE.
          CLEAR RECEIVERS.
          RECEIVERS-SEL = 'X'.
          RECEIVERS-RECESC = 'U'.
          RECEIVERS-RECNAM = 'U-'.
          RECEIVERS-RECEXTNAM = RECLIST-REC.
          RECEIVERS-DELIVER = 'X'.
          RECEIVERS-NOT_DELI = 'X'.
          RECEIVERS-READ = 'X'.
          RECEIVERS-MAILSTATUS = 'E'.
          RECEIVERS-ADR_NAME = RECLIST-REC.
          RECEIVERS-SORTFIELD = RECLIST-REC.
          RECEIVERS-SORTCLASS = '5'.
          APPEND RECEIVERS.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "fill_receivers_info
    *FORM snd_email *
    FORM SND_EMAIL.
      CALL FUNCTION 'SO_OBJECT_SEND'
        EXPORTING
          FOLDER_ID                  = P_OUTFOLDER
          OBJECT_ID                  = OBJECT_ID
          OUTBOX_FLAG                = 'X'
          OWNER                      = SY-UNAME
          CHECK_SEND_AUTHORITY       = 'X'
          ORIGINATOR_TYPE            = 'J'
          LINK_FOLDER_ID             = LINK_FOLDER_ID
        TABLES
          OBJCONT                    = OBJECT_CONTENT
          RECEIVERS                  = RECEIVERS
        EXCEPTIONS
          ACTIVE_USER_NOT_EXIST      = 1
          COMMUNICATION_FAILURE      = 2
          COMPONENT_NOT_AVAILABLE    = 3
          FOLDER_NOT_EXIST           = 4
          FOLDER_NO_AUTHORIZATION    = 5
          FORWARDER_NOT_EXIST        = 6
          NOTE_NOT_EXIST             = 7
          OBJECT_NOT_EXIST           = 8
          OBJECT_NOT_SENT            = 9
          OBJECT_NO_AUTHORIZATION    = 10
          OBJECT_TYPE_NOT_EXIST      = 11
          OPERATION_NO_AUTHORIZATION = 12
          OWNER_NOT_EXIST            = 13
          PARAMETER_ERROR            = 14
          SUBSTITUTE_NOT_ACTIVE      = 15
          SUBSTITUTE_NOT_DEFINED     = 16
          SYSTEM_FAILURE             = 17
          TOO_MUCH_RECEIVERS         = 18
          USER_NOT_EXIST             = 19
          ORIGINATOR_NOT_EXIST       = 20
          X_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.
    ENDFORM.                    "snd_email
    go through this.
    Thanks

Maybe you are looking for

  • Will I get full screen view using my Samsung LED TV (UE46D5500

    will I get full screen view using my Samsung LED TV (UE46D5500)

  • IWeb sites on PCs

    Is there a checklist anywhere of the main things I need to do in order to make my website viewable on PC/IE? I've gleaned a lot of info from searching this forum, but I'm wondering if anybody has put together such a list? Telling visitors to change b

  • Oracle 10g install - upgrade

    When i install Oracle 10g software the wizard identifies the database instance and asks me if I want to upgrade.But after installation of 10g.When the DB Upgrade Assitant opens it does not show the database instance in the DBUA screen.Does the instal

  • Reinstall Windows 7 Home Premium x64 on Satellite R850

    I made recovery discs ( 5 DVD`s ). My question : must I reinstall operating system from recovery discs or I can install trial Windows 7 Home Premium and activated with my serial number?

  • JDO with container (J2EE) managed DataSource

    Hello, I would like to use application server managed DataSource with JDO and would love to find a piece of documentation/link that would take me through it. In absence of such a document, any advice/idea will be appreciated. Based on the bits and pi