Skip to Content
1
Nov 10, 2011 at 11:39 AM

SO_NEW_DOCUMENT_ATT_SEND_API1 cannot send out mail

771 Views

Hi all,

I am getting the error code '2' (Document not send). Anyone knows whichever part that I did wrongly below??

Whichever part is the most suspicious for document not send? Is it the gd_doc_data? Or the it_packing_list? Or objhead/objbin?

  • *&Get the Email id and User id Whom you want to Send ******

  • sort the lt_p0105 according to uname

SORT lt_p0105 by uname ASCENDING.

  • &-- Assign the Email id and User id to Whom you want to Send -------------&

LOOP AT lt_p0105 INTO ls_p0105.

wa_it_receivers-receiver = ls_p0105-usrid_long. "&---- Assign Email id

wa_it_receivers-rec_type = 'U'. "&---- Send to External Email id

wa_it_receivers-com_type = 'INT'.

wa_it_receivers-notif_del = 'X'.

wa_it_receivers-notif_ndel = 'X'.

lv_uname = ls_p0105-uname.

APPEND wa_it_receivers TO it_receivers .

CLEAR wa_it_receivers.

CLEAR ls_p0105.

ENDLOOP.

& - END of Assign the Email id and User id to Whom you want to Send --&

"&--- Read the Number of lines in the Internal Table

DESCRIBE TABLE it_receivers LINES num_lines.

"&--- Check the Sender Email id or SAP User id is got or not.

IF num_lines IS NOT INITIAL.

*&----


  • Add thetext to mail text table

*&----


*********& Send EMAIL MESSAGE &********************************

DESCRIBE TABLE it_message LINES tab_lines.

  • READ TABLE it_message INDEX tab_lines.

gd_doc_data-doc_size = 1.

  • 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

CLEAR wa_it_packing_list.

REFRESH it_packing_list.

wa_it_packing_list-transf_bin = space.

wa_it_packing_list-head_start = 1.

wa_it_packing_list-head_num = 0.

wa_it_packing_list-body_start = 1.

DESCRIBE TABLE it_message LINES wa_it_packing_list-body_num.

wa_it_packing_list-doc_type = 'RAW'.

APPEND wa_it_packing_list TO it_packing_list.

  • Creation of the document attachment

LOOP AT int_storage.

CONCATENATE int_storage-P0000-PERNR

int_storage-P0002-VORNA

int_storage-P0002-NACHN

int_storage-P0019-MNDAT

int_storage-P0019-BVMRK

int_storage-TEXT_P0019_BVMRK

int_storage-P0019-TERMN

int_storage-P0019-TMART

int_storage-TEXT_P0019_TMART

int_storage-SYHR_A_P0019_AF_TEXT1

int_storage-SYHR_A_P0019_AF_TEXT2

int_storage-SYHR_A_P0019_AF_TEXT3

INTO OBJBIN.

APPEND OBJBIN.

ENDLOOP.

DESCRIBE TABLE OBJBIN LINES TAB_LINES.

OBJHEAD = 'Monitoring Task Email'.

APPEND OBJHEAD.

  • Creation of the entry for the compressed attachment

wa_it_packing_list-TRANSF_BIN = 'X'.

wa_it_packing_list-HEAD_START = 1.

wa_it_packing_list-HEAD_NUM = 1.

wa_it_packing_list-BODY_START = 1.

wa_it_packing_list-BODY_NUM = TAB_LINES.

wa_it_packing_list-DOC_TYPE = 'TXT'.

wa_it_packing_list-OBJ_NAME = 'Monitoring Task Email List'.

wa_it_packing_list-OBJ_DESCR = 'EMAIL_LIST.TXT'.

wa_it_packing_list-DOC_SIZE = TAB_LINES * 255.

APPEND wa_it_packing_list to it_packing_list.

.

*&------ Call the Function Module to send the message to External and SAP Inbox

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = gd_doc_data

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = it_packing_list

object_header = objhead

contents_bin = objbin

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.

  • 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. "&---- END of Check the Sender Email id or SAP User id is got or not.

Edited by: Siong Chao on Nov 10, 2011 12:39 PM

Edited by: Siong Chao on Nov 10, 2011 12:41 PM