Hi,
hier das Coding, mit dem Funktionsbaustein 'SO_NEW_DOCUMENT_ATT_SEND_API1' kanns Du Emails an beliebige Email-Adressen versenden. .
Gruß
Lupus
REPORT Y_ZZZDEMO.
DATA: REAL_RECIPIENTS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.
DATA: CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
DATA: PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE.
DATA: OBJECT_HEADER LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
DATA: DOCU_DATA LIKE SODOCCHGI1 OCCURS 0 WITH HEADER LINE.
DATA: CONTENTS_TXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
DATA: PACKING_LIST_TXT LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE.
DATA: OBJECT_HEADER_TXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
DATA: MAILTITEL(70).
DATA: MAILTEXT1(70).
START-OF-SELECTION.
* IF BEDINGUNG. "erfüllt dann Email
* Empfänger
REAL_RECIPIENTS-RECEIVER = 'vorname.name@xyz.de'.
REAL_RECIPIENTS-REC_TYPE = 'U'.
APPEND REAL_RECIPIENTS.
MAILTITEL = 'Betreff'.
MAILTEXT1 = 'Hallo'.
*Mail-Titel
DOCU_DATA-OBJ_DESCR = MAILTITEL.
APPEND DOCU_DATA.
*Mailaufbau
CLEAR PACKING_LIST_TXT.
PACKING_LIST_TXT-HEAD_START = 1.
PACKING_LIST_TXT-HEAD_NUM = 0.
PACKING_LIST_TXT-BODY_START = 1.
*Anzahl Mailzeilen
PACKING_LIST_TXT-BODY_NUM = 1.
PACKING_LIST_TXT-DOC_TYPE = 'RAW'.
APPEND PACKING_LIST_TXT.
*Mailinhalt
CONTENTS_TXT = MAILTEXT1.
APPEND CONTENTS_TXT.
APPEND LINES OF CONTENTS_TXT TO CONTENTS.
APPEND LINES OF OBJECT_HEADER_TXT TO OBJECT_HEADER.
APPEND LINES OF PACKING_LIST_TXT TO PACKING_LIST.
* Send the message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOCU_DATA
PUT_IN_OUTBOX = 'X'
TABLES
PACKING_LIST = PACKING_LIST
OBJECT_HEADER = OBJECT_HEADER
CONTENTS_TXT = CONTENTS
RECEIVERS = REAL_RECIPIENTS
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 NE 0.
RAISE SENDING_FAILED.
ENDIF.
Bearbeitet vom Benutzer
vor 16 Jahre
|
Grund: Nicht angegeben