郵件相關三:一個發郵件的FM和一個…
阿新 • • 發佈:2019-01-09
FUNCTION ZLM_TEST_MAIL_01.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(MAIL_TITLE) TYPE SO_OBJ_DES OPTIONAL
*" REFERENCE(MAIL_TEXT) TYPE STRING
*" EXPORTING
*" VALUE(ERROR_TEXT) TYPE STRING
*" TABLES
*" SEND_LIST STRUCTURE SOLISTI1 OPTIONAL
*"----------------------------------------------------------------------
DATA: BEGIN OF GT_SEND OCCURS 0. "E-mail address
INCLUDE STRUCTURE SOMLRECI1.
DATA: END OF GT_SEND.
DATA: GS_DATA LIKE SODOCCHGI1, "E-mail setting
TAB_LINES TYPE I,
DOC_SIZE TYPE I.
DATA: L_TEXT(50).
DATA: BEGIN OF GT_ITAB OCCURS 0, "E-mail text
TEXT(255),
END OF GT_ITAB.
DATA: IT_SITAB TYPE TABLE OF STRING.
SPLIT MAIL_TEXT AT '/n/t' INTO TABLE GT_ITAB.
* Email的接收人員
LOOP AT SEND_LIST.
GT_SEND-RECEIVER = SEND_LIST-LINE.
GT_SEND- REC_TYPE = 'U'.
GT_SEND-EXPRESS = 'X'.
APPEND GT_SEND.
ENDLOOP.
CLEAR: GS_DATA.
GS_DATA-OBJ_NAME = 'URGENT'.
GS_DATA-OBJ_DESCR = MAIL_TITLE. "郵件標題
GS_DATA-OBJ_LANGU = '1'. "中文
*GS_DATA-SENSITIVTY = 'P'.
GS_DATA-OBJ_PRIO = '1'.
GS_DATA-NO_CHANGE = 'X'.
GS_DATA-PRIORITY = '1'.
* Write Packing List (Main)
DESCRIBE TABLE GT_ITAB LINES TAB_LINES.
READ TABLE GT_ITAB INDEX TAB_LINES.
GS_DATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( GT_ITAB ).
* SEND THE EMAIL
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = GS_DATA
DOCUMENT_TYPE = 'RAW'
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(MAIL_TITLE) TYPE SO_OBJ_DES OPTIONAL
*" REFERENCE(MAIL_TEXT) TYPE STRING
*" EXPORTING
*" VALUE(ERROR_TEXT) TYPE STRING
*" TABLES
*" SEND_LIST STRUCTURE SOLISTI1 OPTIONAL
*"----------------------------------------------------------------------
DATA: BEGIN OF GT_SEND OCCURS 0. "E-mail address
INCLUDE STRUCTURE SOMLRECI1.
DATA: END OF GT_SEND.
DATA: GS_DATA LIKE SODOCCHGI1, "E-mail setting
TAB_LINES TYPE I,
DOC_SIZE TYPE
DATA: L_TEXT(50).
DATA: BEGIN OF GT_ITAB OCCURS 0, "E-mail text
TEXT(255),
END OF GT_ITAB.
DATA: IT_SITAB TYPE TABLE OF STRING.
SPLIT MAIL_TEXT AT '/n/t' INTO TABLE GT_ITAB.
* Email的接收人員
LOOP AT SEND_LIST.
GT_SEND-RECEIVER = SEND_LIST-LINE.
GT_SEND-
GT_SEND-EXPRESS = 'X'.
APPEND GT_SEND.
ENDLOOP.
CLEAR: GS_DATA.
GS_DATA-OBJ_NAME = 'URGENT'.
GS_DATA-OBJ_DESCR = MAIL_TITLE. "郵件標題
GS_DATA-OBJ_LANGU = '1'. "中文
*GS_DATA-SENSITIVTY = 'P'.
GS_DATA-OBJ_PRIO = '1'.
GS_DATA-NO_CHANGE = 'X'.
GS_DATA-PRIORITY = '1'.
* Write Packing List (Main)
DESCRIBE TABLE GT_ITAB LINES TAB_LINES.
READ TABLE GT_ITAB INDEX TAB_LINES.
GS_DATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( GT_ITAB ).
* SEND THE EMAIL
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = GS_DATA
DOCUMENT_TYPE = 'RAW'
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES