FORM SEND_MAIL.
* PARAMETERS FOR SO_NEW_DOCUMENT_SEND_API1
DATA: W_OBJECT_ID LIKE SOODK,
W_SONV_FLAG LIKE SONV-FLAG.
DATA: T_RECEIVERS LIKE SOMLRECI1 OCCURS 1 WITH HEADER LINE,
W_OBJECT_CONTENT LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,
W_DOC_DATA LIKE SODOCCHGI1 OCCURS 0 WITH HEADER LINE.
*
DATA: W_DATE(10).
CLEAR T_RECEIVERS.
T_RECEIVERS-RECEIVER = SY-UNAME.
T_RECEIVERS-REC_TYPE = ‘B’.
T_RECEIVERS-EXPRESS = ‘ ‘.
APPEND T_RECEIVERS.
W_DOC_DATA-OBJ_DESCR = ‘Change Expiry date’.
* Delivery NO
CONCATENATE ‘Delivery No’ M_VMVMA-VBELN INTO W_OBJECT_CONTENT
SEPARATED BY ‘ ‘.
APPEND W_OBJECT_CONTENT.
* material Batch
CONCATENATE ‘Material’ ZGREC-MATNR ‘Batch’ ZGREC-CHARG
INTO W_OBJECT_CONTENT SEPARATED BY ‘ ‘.
APPEND W_OBJECT_CONTENT.
* Expiry date
WRITE B_VFDAT TO W_DATE DD/MM/YYYY.
CONCATENATE ‘Change expiry date to’ W_DATE
INTO W_OBJECT_CONTENT SEPARATED BY ‘ ‘.
APPEND W_OBJECT_CONTENT.
*
CALL FUNCTION ‘SO_NEW_DOCUMENT_SEND_API1’
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = ‘ ‘
TABLES
OBJECT_CONTENT = W_OBJECT_CONTENT
RECEIVERS = T_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.
ENDFORM. ” SEND_MAIL

Serkan AKKAVAK
Computer Engineer
ABAP Developer & SAP MM SD Consultant
Contact : serkurumsal@yandex.com