FM之SO_DOCUMENT_SEND_API1

通过 Function Module 发送邮件,可发送附件。
所属 Function Group : SOI1
所属 Package : SO

*@邮件相关变量
DATA:rec_l_docdata   TYPE sodocchgi1,
     l_sender_adr    TYPE soextreci1-receiver,
     tab_l_packlist  TYPE STANDARD TABLE OF sopcklsti1,
     tab_l_contents  TYPE STANDARD TABLE OF solisti1,
     tab_l_receivers TYPE STANDARD TABLE OF somlreci1.

DATA:l_mail_title    TYPE sodocchgi1-obj_descr,
       rec_l_packlist  TYPE sopcklsti1,
       rec_l_contents  TYPE solisti1,
       rec_l_receivers TYPE somlreci1.

* Populate the subject/generic message attributes
rec_l_docdata-obj_langu = sy-langu.
rec_l_docdata-obj_name  = ‘SAPRPT’.
rec_l_docdata-obj_descr = l_mail_title .
rec_l_docdata-sensitivty = ‘F’.
rec_l_docdata-skip_scren = ’1′.

* Describe the body of the message
rec_l_packlist-transf_bin = space.
rec_l_packlist-head_start = 1.
rec_l_packlist-head_num = 0.
rec_l_packlist-body_start = 1.
DESCRIBE TABLE tab_l_contents LINES rec_l_packlist-body_num.
rec_l_packlist-doc_type = ‘RAW’.
APPEND rec_l_packlist TO tab_l_packlist.

*邮件内容
APPEND rec_l_contents TO tab_l_contents.

*如何修改发送人邮箱?
rec_l_receivers-receiver = ‘your@domain’.
rec_l_receivers-rec_type = ‘U’.
rec_l_receivers-com_type = ‘INT’.
rec_l_receivers-notif_del = ‘X’.
rec_l_receivers-notif_ndel = ‘X’.
APPEND rec_l_receivers TO tab_l_receivers.

CALL FUNCTION ‘SO_DOCUMENT_SEND_API1′
  EXPORTING
    document_data                    = rec_l_docdata
*   PUT_IN_OUTBOX                    = ‘ ‘
   sender_address                   = sy-uname
   sender_address_type              = ‘ ‘
   commit_work                      = ‘X’
* IMPORTING
*   SENT_TO_ALL                      =
*   NEW_OBJECT_ID                    =
*   SENDER_ID                        =
  TABLES
    packing_list                     = tab_l_packlist
*   OBJECT_HEADER                    =
*   CONTENTS_BIN                     =
   contents_txt                     = tab_l_contents
*   CONTENTS_HEX                     =
*   OBJECT_PARA                      =
*   OBJECT_PARB                      =
    receivers                        = tab_l_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.

————
注意:
1、发件人必须在SU3里配置好邮箱。
2、收件人邮箱域名必须由basis在系统中配置。具体方法不清楚。

 


你可能感兴趣的:(FM之SO_DOCUMENT_SEND_API1)