Send Mail Function Module
send mail Function Module
DATA: LT_MAILSUBJECT TYPE SODOCCHGI1.
DATA: LT_MAILRECIPIENTS TYPE STANDARD TABLE OF SOMLREC90 WITH HEADER LINE.
DATA: LT_MAILTXT TYPE STANDARD TABLE OF SOLI WITH HEADER LINE.
* Recipients
LT_MAILRECIPIENTS-REC_TYPE = 'U'.
LT_MAILRECIPIENTS-RECEIVER = 'rkm4888@gmail.com'.
*APPEND LT_MAILRECIPIENTS .
* LT_MAILRECIPIENTS-REC_TYPE = 'U'.
* LT_MAILRECIPIENTS-COPY = 1.
* LT_MAILRECIPIENTS-RECEIVER = 'rkm4888@gmail.com'.
APPEND LT_MAILRECIPIENTS .
CLEAR LT_MAILRECIPIENTS .
* Subject.
LT_MAILSUBJECT-OBJ_NAME = 'SALES ORDER CONF'.
LT_MAILSUBJECT-OBJ_LANGU = SY-LANGU.
CONCATENATE vbak-vbeln ' # Export Sale Order Created for ' vbak-vkorg INTO LT_MAILSUBJECT-OBJ_DESCR SEPARATED BY space.
*LT_MAILSUBJECT-OBJ_DESCR = 'Sales Order No '. "+ xvbak-vbeln.
* Mail Contents
LT_MAILTXT = 'Dear Team,'.
APPEND LT_MAILTXT.
LT_MAILTXT = 'Sales Order for Export is created. The details of which are as under. '.
APPEND LT_MAILTXT.
LT_MAILTXT = ' '.
APPEND LT_MAILTXT.
CONCATENATE 'Sold To Party : ' KUAGV-KUNNR '-' KUAGV-TXTPA INTO lt_mailtxt SEPARATED BY space.
APPEND LT_MAILTXT.
LT_MAILTXT = ' '.
APPEND LT_MAILTXT.
CONCATENATE 'Ship To Party : ' KUWEV-KUNNR ' - 'KUWEV-TXTPA INTO lt_mailtxt SEPARATED BY space.
APPEND LT_MAILTXT.
LT_MAILTXT = ' '.
APPEND LT_MAILTXT.
LT_MAILTXT = 'With Best Regards'.
APPEND LT_MAILTXT.
CLEAR LT_MAILTXT.
* Send Mail
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = LT_MAILSUBJECT
TABLES
OBJECT_CONTENT = LT_MAILTXT
RECEIVERS = LT_MAILRECIPIENTS
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 EQ 0.
COMMIT WORK.
* Push mail out from SAP outbox
SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN.
ENDIF.
DATA: LT_MAILSUBJECT TYPE SODOCCHGI1.
DATA: LT_MAILRECIPIENTS TYPE STANDARD TABLE OF SOMLREC90 WITH HEADER LINE.
DATA: LT_MAILTXT TYPE STANDARD TABLE OF SOLI WITH HEADER LINE.
* Recipients
LT_MAILRECIPIENTS-REC_TYPE = 'U'.
LT_MAILRECIPIENTS-RECEIVER = 'rkm4888@gmail.com'.
*APPEND LT_MAILRECIPIENTS .
* LT_MAILRECIPIENTS-REC_TYPE = 'U'.
* LT_MAILRECIPIENTS-COPY = 1.
* LT_MAILRECIPIENTS-RECEIVER = 'rkm4888@gmail.com'.
APPEND LT_MAILRECIPIENTS .
CLEAR LT_MAILRECIPIENTS .
* Subject.
LT_MAILSUBJECT-OBJ_NAME = 'SALES ORDER CONF'.
LT_MAILSUBJECT-OBJ_LANGU = SY-LANGU.
CONCATENATE vbak-vbeln ' # Export Sale Order Created for ' vbak-vkorg INTO LT_MAILSUBJECT-OBJ_DESCR SEPARATED BY space.
*LT_MAILSUBJECT-OBJ_DESCR = 'Sales Order No '. "+ xvbak-vbeln.
* Mail Contents
LT_MAILTXT = 'Dear Team,'.
APPEND LT_MAILTXT.
LT_MAILTXT = 'Sales Order for Export is created. The details of which are as under. '.
APPEND LT_MAILTXT.
LT_MAILTXT = ' '.
APPEND LT_MAILTXT.
CONCATENATE 'Sold To Party : ' KUAGV-KUNNR '-' KUAGV-TXTPA INTO lt_mailtxt SEPARATED BY space.
APPEND LT_MAILTXT.
LT_MAILTXT = ' '.
APPEND LT_MAILTXT.
CONCATENATE 'Ship To Party : ' KUWEV-KUNNR ' - 'KUWEV-TXTPA INTO lt_mailtxt SEPARATED BY space.
APPEND LT_MAILTXT.
LT_MAILTXT = ' '.
APPEND LT_MAILTXT.
LT_MAILTXT = 'With Best Regards'.
APPEND LT_MAILTXT.
CLEAR LT_MAILTXT.
* Send Mail
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = LT_MAILSUBJECT
TABLES
OBJECT_CONTENT = LT_MAILTXT
RECEIVERS = LT_MAILRECIPIENTS
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 EQ 0.
COMMIT WORK.
* Push mail out from SAP outbox
SUBMIT RSCONN01 WITH MODE = 'INT' AND RETURN.
ENDIF.
Comments
Post a Comment