You are on page 1of 1

DATA: objcont LIKE solisti1 OCCURS 0 WITH HEADER LINE.

DATA: reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE.


DATA: doc_chng LIKE sodocchgi1.
* Email subject line
doc_chng-obj_descr = 'Email subject'.
* Email body
objcont = 'This is a line to be sent in the email body'.
APPEND objcont.
* Receiver list
reclist-receiver = 'your email address here'.
reclist-rec_type = 'U'.
APPEND reclist.
* Send the document
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = doc_chng
commit_work = 'X'
TABLES
object_content = objcont
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc <> 0.
MESSAGE 'Email could not be sent' TYPE 'I'.
ELSE.
MESSAGE 'Email was sent successfully' TYPE 'I'.
ENDIF.

You might also like