<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Attach text file on email in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/attach-text-file-on-email/m-p/3552061#M854637</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Venkat,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;also if I use the character "#" like record's separator the file remain not aligned.&lt;/P&gt;&lt;P&gt;The body's file after the modify that you have suggested me is this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#2008#04#001#900000#00000048#AGK#00000000#10#100.00#00#01#Q#1                                              #2008#04#001##00000141#ACD#00000000#00#   0.0#00##Q#1                                                          #2008#04#001##00000169#A1Y#00000000#00#   0.0#00##I#1                                                          #2008#04#001##00000241##00000000#00#   0.0#00##I#1                                                             #2008#04#001##00000243#AGF#00000000#10#100.00#00#01#I#1                                                        #2008#04#001##00000467##00000000#00#   0.0#00##I#1                                                             #2008#04#001#210408#00000700#A1Y#00000000#10#   0.0#00#01#I#1     &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I must have the body's file like is below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;200804  001  900000  00000048AGK   0000000010       100.00   00     01  Q   1                          &lt;/P&gt;&lt;P&gt;200804  001               00000141ACD   0000000000          0.0     00           Q  1                          &lt;/P&gt;&lt;P&gt;200804  001               00000169A1Y    0000000000          0.0     00           I   1                          &lt;/P&gt;&lt;P&gt;200804  001               00000241          0000000000          0.0     00           I   1                          &lt;/P&gt;&lt;P&gt;200804  001               00000243AGF   0000000010       100.00   00     01   I   1           &lt;/P&gt;&lt;P&gt;200804  001               00000467          0000000000          0.0     00           I    1                          &lt;/P&gt;&lt;P&gt;200804  001  210408  00000700A1Y    0000000010          0.0     00     01   I    1          &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Davide&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 01 Apr 2008 16:56:13 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-01T16:56:13Z</dc:date>
    <item>
      <title>Attach text file on email</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attach-text-file-on-email/m-p/3552058#M854634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I must attach one table like file ".txt" at an email.&lt;/P&gt;&lt;P&gt;I use the call function "SO_NEW_DOCUMENT_ATT_SEND_API1" and I can send email with attachment the text file.&lt;/P&gt;&lt;P&gt;When I open this file, it is not properly aligned like I see it into table during program process.&lt;/P&gt;&lt;P&gt;If I change the file extension in ".doc", it's attached and is properly aligned.&lt;/P&gt;&lt;P&gt;Do you konw tell me if I must change some function parameter's settings?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, Davide.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Apr 2008 15:34:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attach-text-file-on-email/m-p/3552058#M854634</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-01T15:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Attach text file on email</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attach-text-file-on-email/m-p/3552059#M854635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN __default_attr="blue" __jive_macro_name="color"&gt;
Davide Leso,

Check the sample program used to send .txt file as attachment with tab delimited data. its working.

Please try to change receivers id in the program

  &lt;PRE&gt;&lt;CODE&gt;report  zvenkat_txt_attach.
*--------------------------------------------------------*
"  Data retrieval related declarations
*--------------------------------------------------------*
types:
     begin of t_emp_dat,
       pernr type pa0001-pernr,
       persg type pa0001-persg,
       persk type pa0001-persk,
       plans type pa0001-plans,
       stell type pa0001-stell,
     end of t_emp_dat.
data:
     w_emp_data type t_emp_dat.
data:
     i_emp_data type standard table of t_emp_dat.
*--------------------------------------------------------*
"  declarations
*--------------------------------------------------------*
"Variables
data :
     g_sent_to_all   type sonv-flag,
     g_tab_lines     type i.
"Types
types:
     t_document_data  type  sodocchgi1,
     t_packing_list   type  sopcklsti1,
     t_attachment     type  solisti1,
     t_body_msg       type  solisti1,
     t_receivers      type  somlreci1.
"Workareas
data :
     w_document_data  type  t_document_data,
     w_packing_list   type  t_packing_list,
     w_attachment     type  t_attachment,
     w_body_msg       type  t_body_msg,
     w_receivers      type  t_receivers.
"Internal Tables
data :
     i_document_data  type standard table of t_document_data,
     i_packing_list   type standard table of t_packing_list,
     i_attachment     type standard table of t_attachment,
     i_body_msg       type standard table of t_body_msg,
     i_receivers      type standard table of t_receivers.

*--------------------------------------------------------*
"Start-of-selection.
*--------------------------------------------------------*
start-of-selection.
  perform get_data.
  perform build_xls_data_table.

*--------------------------------------------------------*
  "End-of-selection.
*--------------------------------------------------------*
end-of-selection.
  perform send_txt.

*&amp;amp;--------------------------------------------------------*
  "Form  get_data from PA0001
*&amp;amp;--------------------------------------------------------*
form get_data.

  select pernr
         persg
         persk
         plans
         stell
   from pa0001
   into corresponding fields of table i_emp_data
   up to 4 rows.

endform.                    " get_data
*&amp;amp;---------------------------------------------------------*
"Form  build_xls_data_table
*&amp;amp;---------------------------------------------------------*
form build_xls_data_table.
  "If you have Unicode check active in program attributes then
  "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=&amp;gt;horizontal_tab,
      con_cret type c value cl_abap_char_utilities=&amp;gt;cr_lf.

  concatenate 'PERNR' 'PERSG' 'PERSK' 'PLANS' 'STELL'
         into  w_attachment
 separated by  con_tab.

  concatenate con_cret
              w_attachment
         into w_attachment.

  append w_attachment to i_attachment.
  clear  w_attachment.

  loop at i_emp_data into w_emp_data.

    concatenate w_emp_data-pernr
                w_emp_data-persg
                w_emp_data-persk
                w_emp_data-plans
                w_emp_data-stell
           into w_attachment
   separated by con_tab.

    concatenate con_cret w_attachment
           into w_attachment.

    append w_attachment to i_attachment.
    clear  w_attachment.
  endloop.

endform.                    "build_xls_data_table
*&amp;amp;----------------------------------------------------------*
"Form  
"---------------
"PACKING LIST
"This table requires information about how the data in the
"tables OBJECT_HEADER, CONTENTS_BIN and CONTENTS_TXT are to
"be distributed to the documents and its attachments.The first
"row is for the document, the following rows are each for one
"attachment.
*&amp;amp;-----------------------------------------------------------*
form send_txt .

  "Subject of the 
  w_document_data-obj_name  = 'MAI_TO_HEAD'.
  w_document_data-obj_descr = 'Regarding TXT attachment by SAP ABAP'.

  "Body 
  perform build_body_of_mai
    using:space,
          'Hi,',
          'I am fine. How are you? How are you doing ? ',
          'This program has been created to send simple mai',
          'with Subject,Body with Address of the sender. ',
          'Regards,',
          'Venkat.O,',
          'SAP HR Technical Consultant.'.

  "Write Packing List for Body
  describe table i_body_msg lines g_tab_lines.
  w_packing_list-head_start = 1.
  w_packing_list-head_num   = 0.
  w_packing_list-body_start = 1.
  w_packing_list-body_num   = g_tab_lines.
  w_packing_list-doc_type   = 'RAW'.
  append w_packing_list to i_packing_list.
  clear  w_packing_list.

  "Write Packing List for Attachment
  w_packing_list-transf_bin = 'X'.
  w_packing_list-head_start = 1.
  w_packing_list-head_num   = 1.
  w_packing_list-body_start = 1.
  describe table i_attachment lines w_packing_list-body_num.
  w_packing_list-doc_type   = 'TXT'.
  w_packing_list-obj_descr  = 'Text Attachment'.
  w_packing_list-obj_name   = 'TXT_ATTACHMENT'.
  w_packing_list-doc_size   = w_packing_list-body_num * 255.
  append w_packing_list to i_packing_list.
  clear  w_packing_list.

  "Fill the document data and get size of attachment
  w_document_data-obj_langu  = sy-langu.
  read table i_attachment into w_attachment index g_tab_lines.
  w_document_data-doc_size = ( g_tab_lines - 1 ) * 255 + strlen( w_attachment ).

  "Receivers List.
  w_receivers-rec_type   = 'U'.  "Internet address
  w_receivers-receiver   = ' '." Please mention receiver here
  w_receivers-com_type   = 'INT'.
  w_receivers-notif_del  = 'X'.
  w_receivers-notif_ndel = 'X'.
  append w_receivers to i_receivers .
  clear:w_receivers.

  "Function module to send mai to Recipients
  call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    exporting
      document_data              = w_document_data
      put_in_outbox              = 'X'
      commit_work                = 'X'
    importing
      sent_to_all                = g_sent_to_all
    tables
      packing_list               = i_packing_list
      contents_bin               = i_attachment
      contents_txt               = i_body_msg
      receivers                  = i_receivers
    exceptions
      too_many_receivers         = 1
      document_not_sent          = 2
      document_type_not_exist    = 3
      operation_no_authorization = 4
      parameter_error            = 5
      x_error                    = 6
      enqueue_error              = 7
      others                     = 8.

  if sy-subrc = 0 .
    message i303(me) with 'Mai has been Successfully Sent.'.
  else.
    wait up to 2 seconds.
    "This program starts the SAPconnect send process.
    submit rsconn01 with mode = 'INT'
                    with output = 'X'
                    and return.
  endif.

endform.                    " send_mai
*&amp;amp;-----------------------------------------------------------*
"      Form  build_body_of_mai
*&amp;amp;-----------------------------------------------------------*
form build_body_of_mai  using l_message.

  w_body_msg = l_message.
  append w_body_msg to i_body_msg.
  clear  w_body_msg.

endform.                    " build_body_of_&lt;/CODE&gt;&lt;/PRE&gt; 

I hope that it helps u. 

Regards,
Venkat.O
&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Apr 2008 15:55:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attach-text-file-on-email/m-p/3552059#M854635</guid>
      <dc:creator>venkat_o</dc:creator>
      <dc:date>2008-04-01T15:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: Attach text file on email</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attach-text-file-on-email/m-p/3552060#M854636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;as part of the community rule we can not use mail word. so i tried to delete .please check there may be small syntax errors ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Venkat.O&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Apr 2008 15:57:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attach-text-file-on-email/m-p/3552060#M854636</guid>
      <dc:creator>venkat_o</dc:creator>
      <dc:date>2008-04-01T15:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Attach text file on email</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attach-text-file-on-email/m-p/3552061#M854637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Venkat,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;also if I use the character "#" like record's separator the file remain not aligned.&lt;/P&gt;&lt;P&gt;The body's file after the modify that you have suggested me is this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#2008#04#001#900000#00000048#AGK#00000000#10#100.00#00#01#Q#1                                              #2008#04#001##00000141#ACD#00000000#00#   0.0#00##Q#1                                                          #2008#04#001##00000169#A1Y#00000000#00#   0.0#00##I#1                                                          #2008#04#001##00000241##00000000#00#   0.0#00##I#1                                                             #2008#04#001##00000243#AGF#00000000#10#100.00#00#01#I#1                                                        #2008#04#001##00000467##00000000#00#   0.0#00##I#1                                                             #2008#04#001#210408#00000700#A1Y#00000000#10#   0.0#00#01#I#1     &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I must have the body's file like is below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;200804  001  900000  00000048AGK   0000000010       100.00   00     01  Q   1                          &lt;/P&gt;&lt;P&gt;200804  001               00000141ACD   0000000000          0.0     00           Q  1                          &lt;/P&gt;&lt;P&gt;200804  001               00000169A1Y    0000000000          0.0     00           I   1                          &lt;/P&gt;&lt;P&gt;200804  001               00000241          0000000000          0.0     00           I   1                          &lt;/P&gt;&lt;P&gt;200804  001               00000243AGF   0000000010       100.00   00     01   I   1           &lt;/P&gt;&lt;P&gt;200804  001               00000467          0000000000          0.0     00           I    1                          &lt;/P&gt;&lt;P&gt;200804  001  210408  00000700A1Y    0000000010          0.0     00     01   I    1          &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Davide&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Apr 2008 16:56:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attach-text-file-on-email/m-p/3552061#M854637</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-01T16:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Attach text file on email</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attach-text-file-on-email/m-p/3552062#M854638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi try this ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES: ekko.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS: p_email   TYPE somlreci1-receiver .&lt;/P&gt;&lt;P&gt;                                  &lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF t_ekpo,&lt;/P&gt;&lt;P&gt;  ebeln TYPE ekpo-ebeln,&lt;/P&gt;&lt;P&gt;  ebelp TYPE ekpo-ebelp,&lt;/P&gt;&lt;P&gt;  aedat TYPE ekpo-aedat,&lt;/P&gt;&lt;P&gt;  matnr TYPE ekpo-matnr,&lt;/P&gt;&lt;P&gt; END OF t_ekpo.&lt;/P&gt;&lt;P&gt;DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,&lt;/P&gt;&lt;P&gt;      wa_ekpo TYPE t_ekpo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF t_charekpo,&lt;/P&gt;&lt;P&gt;  ebeln(10) TYPE c,&lt;/P&gt;&lt;P&gt;  ebelp(5)  TYPE c,&lt;/P&gt;&lt;P&gt;  aedat(8)  TYPE c,&lt;/P&gt;&lt;P&gt;  matnr(18) TYPE c,&lt;/P&gt;&lt;P&gt; END OF t_charekpo.&lt;/P&gt;&lt;P&gt;DATA: wa_charekpo TYPE t_charekpo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0&lt;/P&gt;&lt;P&gt;                WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0&lt;/P&gt;&lt;P&gt;                WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:   t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;        t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;        t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;        t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;        t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;        w_cnt TYPE i,&lt;/P&gt;&lt;P&gt;        w_sent_all(1) TYPE c,&lt;/P&gt;&lt;P&gt;        w_doc_data LIKE sodocchgi1,&lt;/P&gt;&lt;P&gt;        gd_error    TYPE sy-subrc,&lt;/P&gt;&lt;P&gt;        gd_reciever TYPE sy-subrc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*START_OF_SELECTION&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Retrieve sample data from table ekpo&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  PERFORM data_retrieval.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Populate table with detaisl to be entered into .xls file&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  PERFORM build_xls_data_table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;*END-OF-SELECTION&lt;/P&gt;&lt;P&gt;END-OF-SELECTION.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Populate message body text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  perform populate_email_message_body.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Send file by email as .xls speadsheet&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  PERFORM send_file_as_email_attachment&lt;/P&gt;&lt;P&gt;                               tables it_message&lt;/P&gt;&lt;P&gt;                                      it_attach&lt;/P&gt;&lt;P&gt;                                using p_email&lt;/P&gt;&lt;P&gt;                                      'Example .txt documnet attachment'&lt;/P&gt;&lt;P&gt;                                      'txt'&lt;/P&gt;&lt;P&gt;                                      'filename'&lt;/P&gt;&lt;P&gt;                                      ' '&lt;/P&gt;&lt;P&gt;                                      ' '&lt;/P&gt;&lt;P&gt;                                      ' '&lt;/P&gt;&lt;P&gt;                             changing gd_error&lt;/P&gt;&lt;P&gt;                                      gd_reciever.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  Instructs mail send program for SAPCONNECT to send email(rsconn01)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  PERFORM initiate_mail_execute_program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  DATA_RETRIEVAL&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      Retrieve data form EKPO table and populate itab it_ekko&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM data_retrieval.&lt;/P&gt;&lt;P&gt;  SELECT ebeln ebelp aedat matnr&lt;/P&gt;&lt;P&gt;   UP TO 10 ROWS&lt;/P&gt;&lt;P&gt;    FROM ekpo&lt;/P&gt;&lt;P&gt;    INTO TABLE it_ekpo.&lt;/P&gt;&lt;P&gt;ENDFORM.                    " DATA_RETRIEVAL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  BUILD_XLS_DATA_TABLE&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      Build data table for .xls document&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM build_xls_data_table.&lt;/P&gt;&lt;P&gt;  data: ld_store(50) type c.  "Leading zeros&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CONSTANTS: con_cret(5) TYPE c VALUE '0D',  "OK for non Unicode&lt;/P&gt;&lt;P&gt;             con_tab(5) TYPE c VALUE '09'.   "OK for non Unicode&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*If you have Unicode check active in program attributes thnen you will&lt;/P&gt;&lt;P&gt;*need to declare constants as follows&lt;/P&gt;&lt;P&gt;*class cl_abap_char_utilities definition load.&lt;/P&gt;&lt;P&gt;*constants:&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   con_tab  type c value cl_abap_char_utilities=&amp;gt;HORIZONTAL_TAB,&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   con_cret type c value cl_abap_char_utilities=&amp;gt;CR_LF.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR' INTO it_attach SEPARATED BY con_tab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CONCATENATE con_cret it_attach  INTO it_attach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  APPEND  it_attach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT it_ekpo INTO wa_charekpo.&lt;/P&gt;&lt;P&gt;*Modification to retain leading zeros&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  inserts code for excell REPLACE command into ld_store&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  =REPLACE("00100",1,5,"00100")&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    concatenate '=REPLACE("' wa_charekpo-ebelp '",1,5,"'&lt;/P&gt;&lt;P&gt;                             wa_charekpo-ebelp '")' into ld_store .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;  concatenate ld_store into .xls file instead of actual value(ebelp)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    CONCATENATE wa_charekpo-ebeln ld_store  wa_charekpo-aedat wa_charekpo-matnr  INTO it_attach SEPARATED BY con_tab.&lt;/P&gt;&lt;P&gt;    CONCATENATE con_cret it_attach  INTO it_attach.&lt;/P&gt;&lt;P&gt;    APPEND  it_attach.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDFORM.                    " BUILD_XLS_DATA_TABLE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  SEND_FILE_AS_EMAIL_ATTACHMENT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      Send email&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM send_file_as_email_attachment tables pit_message&lt;/P&gt;&lt;P&gt;                                          pit_attach&lt;/P&gt;&lt;P&gt;                                    using p_email&lt;/P&gt;&lt;P&gt;                                          p_mtitle&lt;/P&gt;&lt;P&gt;                                          p_format&lt;/P&gt;&lt;P&gt;                                          p_filename&lt;/P&gt;&lt;P&gt;                                          p_attdescription&lt;/P&gt;&lt;P&gt;                                          p_sender_address&lt;/P&gt;&lt;P&gt;                                          p_sender_addres_type&lt;/P&gt;&lt;P&gt;                                 changing p_error&lt;/P&gt;&lt;P&gt;                                          p_reciever.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA: ld_error    TYPE sy-subrc,&lt;/P&gt;&lt;P&gt;        ld_reciever TYPE sy-subrc,&lt;/P&gt;&lt;P&gt;        ld_mtitle LIKE sodocchgi1-obj_descr,&lt;/P&gt;&lt;P&gt;        ld_email LIKE  somlreci1-receiver,&lt;/P&gt;&lt;P&gt;        ld_format TYPE  so_obj_tp ,&lt;/P&gt;&lt;P&gt;        ld_attdescription TYPE  so_obj_nam ,&lt;/P&gt;&lt;P&gt;        ld_attfilename TYPE  so_obj_des ,&lt;/P&gt;&lt;P&gt;        ld_sender_address LIKE  soextreci1-receiver,&lt;/P&gt;&lt;P&gt;        ld_sender_address_type LIKE  soextreci1-adr_typ,&lt;/P&gt;&lt;P&gt;        ld_receiver LIKE  sy-subrc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ld_email   = p_email.&lt;/P&gt;&lt;P&gt;  ld_mtitle = p_mtitle.&lt;/P&gt;&lt;P&gt;  ld_format              = p_format.&lt;/P&gt;&lt;P&gt;  ld_attdescription      = p_attdescription.&lt;/P&gt;&lt;P&gt;  ld_attfilename         = p_filename.&lt;/P&gt;&lt;P&gt;  ld_sender_address      = p_sender_address.&lt;/P&gt;&lt;P&gt;  ld_sender_address_type = p_sender_addres_type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Fill the document data.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  w_doc_data-doc_size = 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Populate the subject/generic message attributes&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  w_doc_data-obj_langu = sy-langu.&lt;/P&gt;&lt;P&gt;  w_doc_data-obj_name  = 'SAPRPT'.&lt;/P&gt;&lt;P&gt;  w_doc_data-obj_descr = ld_mtitle .&lt;/P&gt;&lt;P&gt;  w_doc_data-sensitivty = 'F'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Fill the document data and get size of attachment&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CLEAR w_doc_data.&lt;/P&gt;&lt;P&gt;  READ TABLE it_attach INDEX w_cnt.&lt;/P&gt;&lt;P&gt;  w_doc_data-doc_size =&lt;/P&gt;&lt;P&gt;     ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).&lt;/P&gt;&lt;P&gt;  w_doc_data-obj_langu  = sy-langu.&lt;/P&gt;&lt;P&gt;  w_doc_data-obj_name   = 'SAPRPT'.&lt;/P&gt;&lt;P&gt;  w_doc_data-obj_descr  = ld_mtitle.&lt;/P&gt;&lt;P&gt;  w_doc_data-sensitivty = 'F'.&lt;/P&gt;&lt;P&gt;  CLEAR t_attachment.&lt;/P&gt;&lt;P&gt;  REFRESH t_attachment.&lt;/P&gt;&lt;P&gt;  t_attachment[] = pit_attach[].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Describe the body of the message&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CLEAR t_packing_list.&lt;/P&gt;&lt;P&gt;  REFRESH t_packing_list.&lt;/P&gt;&lt;P&gt;  t_packing_list-transf_bin = space.&lt;/P&gt;&lt;P&gt;  t_packing_list-head_start = 1.&lt;/P&gt;&lt;P&gt;  t_packing_list-head_num = 0.&lt;/P&gt;&lt;P&gt;  t_packing_list-body_start = 1.&lt;/P&gt;&lt;P&gt;  DESCRIBE TABLE it_message LINES t_packing_list-body_num.&lt;/P&gt;&lt;P&gt;  t_packing_list-doc_type = 'RAW'.&lt;/P&gt;&lt;P&gt;  APPEND t_packing_list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Create attachment notification&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  t_packing_list-transf_bin = 'X'.&lt;/P&gt;&lt;P&gt;  t_packing_list-head_start = 1.&lt;/P&gt;&lt;P&gt;  t_packing_list-head_num   = 1.&lt;/P&gt;&lt;P&gt;  t_packing_list-body_start = 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.&lt;/P&gt;&lt;P&gt;  t_packing_list-doc_type   =  ld_format.&lt;/P&gt;&lt;P&gt;  t_packing_list-obj_descr  =  ld_attdescription.&lt;/P&gt;&lt;P&gt;  t_packing_list-obj_name   =  ld_attfilename.&lt;/P&gt;&lt;P&gt;  t_packing_list-doc_size   =  t_packing_list-body_num * 255.&lt;/P&gt;&lt;P&gt;  APPEND t_packing_list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Add the recipients email address&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CLEAR t_receivers.&lt;/P&gt;&lt;P&gt;  REFRESH t_receivers.&lt;/P&gt;&lt;P&gt;  t_receivers-receiver = ld_email.&lt;/P&gt;&lt;P&gt;  t_receivers-rec_type = 'U'.&lt;/P&gt;&lt;P&gt;  t_receivers-com_type = 'INT'.&lt;/P&gt;&lt;P&gt;  t_receivers-notif_del = 'X'.&lt;/P&gt;&lt;P&gt;  t_receivers-notif_ndel = 'X'.&lt;/P&gt;&lt;P&gt;  APPEND t_receivers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'SO_DOCUMENT_SEND_API1'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            document_data              = w_doc_data&lt;/P&gt;&lt;P&gt;            put_in_outbox              = 'X'&lt;/P&gt;&lt;P&gt;            sender_address             = ld_sender_address&lt;/P&gt;&lt;P&gt;            sender_address_type        = ld_sender_address_type&lt;/P&gt;&lt;P&gt;            commit_work                = 'X'&lt;/P&gt;&lt;P&gt;       IMPORTING&lt;/P&gt;&lt;P&gt;            sent_to_all                = w_sent_all&lt;/P&gt;&lt;P&gt;       TABLES&lt;/P&gt;&lt;P&gt;            packing_list               = t_packing_list&lt;/P&gt;&lt;P&gt;            contents_bin               = t_attachment&lt;/P&gt;&lt;P&gt;            contents_txt               = it_message&lt;/P&gt;&lt;P&gt;            receivers                  = t_receivers&lt;/P&gt;&lt;P&gt;       EXCEPTIONS&lt;/P&gt;&lt;P&gt;            too_many_receivers         = 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            document_not_sent          = 2&lt;/P&gt;&lt;P&gt;            document_type_not_exist    = 3&lt;/P&gt;&lt;P&gt;            operation_no_authorization = 4&lt;/P&gt;&lt;P&gt;            parameter_error            = 5&lt;/P&gt;&lt;P&gt;            x_error                    = 6&lt;/P&gt;&lt;P&gt;            enqueue_error              = 7&lt;/P&gt;&lt;P&gt;            OTHERS                     = 8.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Populate zerror return code&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  ld_error = sy-subrc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Populate zreceiver return code&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  LOOP AT t_receivers.&lt;/P&gt;&lt;P&gt;    ld_receiver = t_receivers-retrn_code.&lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  INITIATE_MAIL_EXECUTE_PROGRAM&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      Instructs mail send program for SAPCONNECT to send email.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM initiate_mail_execute_program.&lt;/P&gt;&lt;P&gt;  WAIT UP TO 2 SECONDS.&lt;/P&gt;&lt;P&gt;  SUBMIT rsconn01 WITH mode = 'INT'&lt;/P&gt;&lt;P&gt;                WITH output = 'X'&lt;/P&gt;&lt;P&gt;                AND RETURN.&lt;/P&gt;&lt;P&gt;ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  POPULATE_EMAIL_MESSAGE_BODY&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;       Populate message body text&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form populate_email_message_body.&lt;/P&gt;&lt;P&gt;  REFRESH it_message.&lt;/P&gt;&lt;P&gt;  it_message = 'Please find attached a list test ekpo records'.&lt;/P&gt;&lt;P&gt;  APPEND it_message.&lt;/P&gt;&lt;P&gt;endform.                    " POPULATE_EMAIL_MESSAGE_BODY&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;venkat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Apr 2008 17:38:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attach-text-file-on-email/m-p/3552062#M854638</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-01T17:38:38Z</dc:date>
    </item>
  </channel>
</rss>

