程序要点:1、显示smartform时,获取对应的OTF数据,然后转换为PDF对象
2、使用function module
SO_NEW_DOCUMENT_ATT_SEND_API1 发送邮件,设置
PUT_IN_OUTBOX = 'X'
可以在工作台outbox查看邮件的发送状态及内容
3、调用程序 RSCONN01
立即发送;上述function module 执行之后,并不能立即发送出去,需要执行
RSCONN01
才能立即发送。此程序一般在basis配置SAP邮件时设置成后台作业,参考事务码SCOT
以下是程序源码及SAP outbox截图:
*&---------------------------------------------------------------------*
*& Report YZ_TEST13
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT YZ_TEST13.
DATA I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE.
DATA WA_BUFFER TYPE STRING. "To convert from 132 to 255
DATA: I_RECORD TYPE TABLE OF SOLISTI1 WITH HEADER LINE,
WA_DOC TYPE SODOCCHGI1,
I_RECLIST TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
* Objects to send mail.
I_OBJPACK TYPE TABLE OF SOPCKLSTI1 WITH HEADER LINE,
I_OBJTXT TYPE TABLE OF SOLISTI1 WITH HEADER LINE,
I_OBJBIN TYPE TABLE OF SOLISTI1 WITH HEADER LINE,
* Work Area declarations
WA_OBJHEAD TYPE SOLI_TAB,
* Variables declarations
V_LEN_IN TYPE SOOD-OBJLEN,
V_LINES_TXT TYPE I,
V_LINES_BIN TYPE I.
DATA OUTPUT_OPTIONS TYPE SSFCOMPOP .
DATA CONTROL_PARAMETERS TYPE SSFCTRLOP.
DATA JOB_OUTPUT_INFO TYPE SSFCRESCL.
DATA LV_FNAME(30).
PARAMETERS P_MAILTO(30) DEFAULT 'zyz_erp@163.com'.
*Smartforms
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = '/SAPDII/FINC_LIST'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
FM_NAME = LV_FNAME
* EXCEPTIONS
* NO_FORM = 1
* NO_FUNCTION_MODULE = 2
* OTHERS = 3
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CONTROL_PARAMETERS-GETOTF = 'X'.
CALL FUNCTION LV_FNAME
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = CONTROL_PARAMETERS
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
OUTPUT_OPTIONS = OUTPUT_OPTIONS
* USER_SETTINGS = 'X'
* LINEITEMS =
IMPORTING
* DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = JOB_OUTPUT_INFO
* JOB_OUTPUT_OPTIONS =
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED