SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Не отправляется письмо с аттачем



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
Максим
Специалист
Специалист



Joined: 27 Sep 2007
Posts: 61

PostPosted: Fri Nov 07, 2008 3:58 pm    Post subject: Не отправляется письмо с аттачем Reply with quote

Коллеги, можете посмотреть, почему не отправляется письмо, если добавлен attachment? Ошибок не выдает.
Если закомментировать прикрепление файла, письмо приходит.

Code:
DEFINE __repl.
  if objtxt cs &1.
    len = strlen( &2 ).
    if len > 0.
      replace &1 with &2(len) into objtxt.
    else.
      replace &1 with space into objtxt.
    endif.
  endif.
END-OF-DEFINITION."__REPL

DATA:  lt_lines  LIKE tline OCCURS 0,
       ls_lines  LIKE tline.

DATA: docdata LIKE sodocchgi1,
      objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
      objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
      objtxt  LIKE solisti1 OCCURS 10 WITH HEADER LINE,
      objbin  LIKE solisti1 OCCURS 10 WITH HEADER LINE,
      reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.

DATA:
  listobject  LIKE abaplist OCCURS 1 WITH HEADER LINE.

DATA:
  tab_lines   TYPE i,
  doc_size    TYPE i,
  len         TYPE i,
  l_fax_found TYPE i.

DATA: s_file    TYPE string,
      l_file    TYPE rlgrap-filename,
      l_filename TYPE rlgrap-filename.
DATA: l_objid     TYPE wwwdata-objid.


REFRESH lt_lines.
CALL FUNCTION 'READ_TEXT'
     EXPORTING
          id       = 'ST'
          language = 'EN'
          name     = 'ZERU_TEXTS'
          object   = 'TEXT'
     TABLES
          lines    = lt_lines
     EXCEPTIONS
          OTHERS   = 1.

CHECK sy-subrc IS INITIAL.

* Title and Description
docdata-obj_name = 'EMAIL'.
docdata-obj_descr = 'Reconciliation Statement'.

* Create Message Body
LOOP AT lt_lines INTO ls_lines WHERE tdformat = '*'
                                  OR tdformat = ''.
  objtxt = ls_lines-tdline.
  __repl '=ContactPersonEng' g_contact_per_e.
  __repl '=ContactPersonRus' g_contact_per_r.
  __repl '=ContactEmail'     g_contact_email.

  IF objtxt CS '=ContactFax'.
    CASE l_fax_found.
      WHEN 0.
        __repl '=ContactFax' g_contact_fax1.
      WHEN 1.
        __repl '=ContactFax' g_contact_fax2.
    ENDCASE.
    l_fax_found = l_fax_found + 1.
  ENDIF.

  APPEND objtxt.
ENDLOOP.

*  Write Packing List (Main)
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.

docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
objpack-transf_bin = space.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.

*   Create Message Attachment
*   Write Packing List (Attachment)
CALL FUNCTION 'GUI_UPLOAD'
     EXPORTING
          filename                = s_file
          filetype                = 'BIN'
     IMPORTING
          filelength              = doc_size
     TABLES
          data_tab                = objbin
     EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          OTHERS                  = 22.

CHECK sy-subrc IS INITIAL.

** Include Attachment
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = doc_size.
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'BIN'.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = 'Attached Document'.
APPEND objpack.

reclist-rec_type = 'U'. "Internet address
reclist-com_type = 'INT'.
reclist-notif_del = 'X'.
reclist-notif_ndel = 'X'.

reclist-receiver = i_result-email.
reclist-receiver = '[email protected]'.
APPEND reclist.

* Send Message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
     EXPORTING
          document_data = docdata
          put_in_outbox = ''
     TABLES
          packing_list  = objpack
          object_header = objhead
          contents_bin  = objbin
          contents_txt  = objtxt
          receivers     = reclist
     EXCEPTIONS
          OTHERS        = 8.

IF sy-subrc <> 0.
  MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
  WITH docdata-obj_name.
ENDIF.

CONCATENATE 'File' l_filename 'sent.'
  INTO l_filename SEPARATED BY space.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
     EXPORTING
          text = l_filename.
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 175
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Fri Nov 07, 2008 6:06 pm    Post subject: Reply with quote

Попробуйте сменить дип документа с 'BIN' на 'XLS' и применить этот код.

Code:
  DESCRIBE TABLE objbin LINES tab_lines.
  READ TABLE objbin INDEX tab_lines.
  CLEAR objpack.
  objpack-doc_size = doc_size.
  objpack-transf_bin = 'X'.
  objpack-head_start = 1.
  objpack-head_num = 1.
  objpack-body_start = 1.
  objpack-body_num = tab_lines.
  objpack-doc_type = 'XLS'.
  objpack-obj_name = l_filename.
  objpack-obj_descr = l_filename.
  APPEND objpack.

  reclist-rec_type = 'U'. "Internet address
  reclist-com_type = 'INT'.

  reclist-receiver = i_result-email.
  reclist-receiver = '[email protected]'.
  APPEND reclist.

* Send Message
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       EXPORTING
            document_data = docdata
*            put_in_outbox = 'X'
            commit_work   = 'X'
       TABLES
            packing_list  = objpack
            object_header = objhead
            contents_bin  = objbin
            contents_txt  = objtxt
            receivers     = reclist
       EXCEPTIONS
            OTHERS        = 8.
Back to top
View user's profile Send private message Blog Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.