欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SAP ABAP 内部发邮件

程序员文章站 2022-03-18 21:44:46
...
REPORT zhelllo.
TABLES: usr02.
DATA: lt_pack_list TYPE swftpcklst WITH HEADER LINE,
      lt_contents  TYPE swftlisti1 WITH HEADER LINE,
      st_contents  TYPE swftlisti1 WITH HEADER LINE,
      lt_receivers TYPE somlreci1_t WITH HEADER LINE,
      it_contents TYPE swftlisti1 WITH HEADER LINE,
      value TYPE i VALUE 5,
      doc_data     LIKE sodocchgi1 .

SELECT-OPTIONS:
                s_uname FOR usr02-bname NO INTERVALS OBLIGATORY.

DO value TIMES.
  CONCATENATE
    `<TR> <td>` '2'
    `</td><td>` '3'
    `</td><td>` '3'
    `</td><td>` '4'
    `</td><td>` '5'
    `</td><td>` '6'
    `</td><td>` '6'
    `</td></tr>`
    INTO st_contents .
  APPEND st_contents.
ENDDO.

APPEND `<HTML> <font face="courier new"> <BODY> 错误明细` TO lt_contents.
APPEND `<meta http-equiv=Content-Type content` TO lt_contents.
APPEND `="text/html; charset=utf-8">` TO lt_contents.

APPEND `<TABLE border=1 cellpadding=2 ` TO lt_contents.
APPEND `style='border-collapse:collapse;font-size:10.5pt'>` TO
lt_contents.
APPEND `<TR style= 'background:#5dcbfd'> ` TO lt_contents.
APPEND `<TD>物料凭证</TD>` TO lt_contents.
APPEND `<TD>年度</TD>`  TO lt_contents.
APPEND `<TD>采购订单</TD>`  TO lt_contents.
APPEND `<TD>项目</TD>` TO lt_contents.
APPEND `<TD>采购申请</TD>`  TO lt_contents.
APPEND `<TD>项目</TD>` TO lt_contents.
APPEND `<TD>错误信息</TD>` TO lt_contents.
APPEND `</TR>` TO lt_contents.

APPEND LINES OF st_contents TO lt_contents.

APPEND '</TABLE> <P> ' TO lt_contents.
APPEND '</BODY> </HTML>' TO lt_contents.

doc_data-obj_langu = sy-langu.
doc_data-obj_descr = '寄售物料自动移库程序关闭PR失败'.

lt_pack_list-transf_bin = space.
lt_pack_list-head_start = 1.
lt_pack_list-head_num = 0.
lt_pack_list-body_start = 1.
DESCRIBE TABLE lt_contents LINES lt_pack_list-body_num.
lt_pack_list-doc_type = 'HTML'.
APPEND lt_pack_list.

LOOP AT s_uname.
  lt_receivers-receiver = s_uname-low.
  lt_receivers-rec_type = 'B'.
  lt_receivers-com_type = 'INT'.
  lt_receivers-notif_del = 'X'.
  lt_receivers-notif_ndel = 'X'.
  lt_receivers-express  = 'X'.
  APPEND lt_receivers.
ENDLOOP.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
  EXPORTING
    document_data              = doc_data
    put_in_outbox              = 'X'
    commit_work                = 'X'
  TABLES
    packing_list               = lt_pack_list
    contents_txt               = lt_contents
    receivers                  = lt_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.