T4S4  19.1 C8540 A23673
Teamcenter Gateway for SAP S/4HANA API Reference
TPSAP::MAIL Namespace Reference

Functions

 SendMail args
 Sends a SAP mail to the specified recipient. More...
 
 SendMailWithBOAtt args
 Sends a SAP mail to the specified recipient with a SAP BusinessObject as attachment. More...
 

Function Documentation

◆ SendMail()

TPSAP::MAIL::SendMail   args  

Sends a SAP mail to the specified recipient.

Parameters
argsnone
Returns
List of Status OK and Status message if available

Sample code sequence

1 set ::SAPDat(SAPMAIL:OBJHEADERCHANGE:OBJLA) "EN"; # Language in Which Document Is Created
2 set ::SAPDat(SAPMAIL:OBJHEADERCHANGE:OBJDES) "My Email Subject"; # Short description of contents
3 #
4 # Body of the mail
5 #
6 set MailBody "This is my Text"
7 set ::SAPDat(SAPMAIL:OBJCONTENT:LINE:1) [string range $MailBody 0 254] ; # each Line takes 255 chars...
8 set ::SAPDat(SAPMAIL:OBJCONTENT:LINE:2) [string range $MailBody 255 499] ; # each Line takes 255 chars...
9 # if the Body has more than these 500 chars add here more of the previous lines!
10 
11 set ::SAPDat(SAPMAIL:RECEIVERS:RECNAM:1) Receipient ; # Recipient Name (SAP user)
12 set ::SAPDat(SAPMAIL:RECEIVERS:SNDEX:1) "X" ; # Send express (X or " ")
13 
14 #
15 # Now we can send the mail
16 #
17 set Status [::TPSAP::MAIL::SendMail]
18 if {[lindex $Status 0] eq "OK"} {
19  # email was sent to SAP user
20 } else {
21  # email was not sent
22  puts [tpco_formatHEX16 [lindex $Status 1]]
23 }

◆ SendMailWithBOAtt()

TPSAP::MAIL::SendMailWithBOAtt   args  

Sends a SAP mail to the specified recipient with a SAP BusinessObject as attachment.

Parameters
argsnone
Returns
List of Status OK and Status message if available

Sample code sequence

1 #
2 # Send a SAP mail to the given receipient
3 #
4 set ::SAPDat(SAPMAIL:RECEIVERS:RECEIVER:1) Recipient ; # Recipient Name (SAP user)
5 set ::SAPDat(SAPMAIL:RECEIVERS:EXPRESS:1) "X" ; # Send express (X or " ")
6 
7 #
8 # Subject of the mail
9 #
10 set ::SAPDat(SAPMAIL:DOCUMENTDATA:OBJ_DESCR) "My Subject"
11 
12 #
13 # Objects of the mail
14 #
15 # In this case we have to objects:
16 # 1) The mail itself (Type RAW)
17 # 2) The BO as an attachment (Typ ObjType)
18 #
19 # (if we remove object Nr 1) then the BO itself would be in the inbox directly without mail and not as an attachment)
20 #
21 set ::SAPDat(SAPMAIL:PACKING_LIST:HEAD_START:1) "0"
22 set ::SAPDat(SAPMAIL:PACKING_LIST:HEAD_NUM:1) "0"
23 set ::SAPDat(SAPMAIL:PACKING_LIST:BODY_START:1) "1"
24 set ::SAPDat(SAPMAIL:PACKING_LIST:BODY_NUM:1) "3"
25 set ::SAPDat(SAPMAIL:PACKING_LIST:DOC_TYPE:1) "RAW"
26 
27 # Object Type (Example: DRAW for Documents
28 # 1234567890123456789012345
29 # Object Key (Example: DRW000000000000000000000123400001 for Document 1234/DRW/001/00 (Nr,Type,Ver,Part)
30 
31 set ObjType DRAW
32 set ObjKey DRW000000000000000000000123400001
33 
34 set ::SAPDat(SAPMAIL:PACKING_LIST:HEAD_START:2) "1"
35 set ::SAPDat(SAPMAIL:PACKING_LIST:HEAD_NUM:2) "1"
36 set ::SAPDat(SAPMAIL:PACKING_LIST:BODY_START:2) "0"
37 set ::SAPDat(SAPMAIL:PACKING_LIST:BODY_NUM:2) "0"
38 set ::SAPDat(SAPMAIL:PACKING_LIST:DOC_TYPE:2) "OBJ"
39 set ::SAPDat(SAPMAIL:PACKING_LIST:OBJ_NAME:2) $ObjType
40 set ::SAPDat(SAPMAIL:PACKING_LIST:OBJ_DESCR:2) "$ObjType-$ObjKey"
41 
42 #
43 # OBJECT_HEADER of the BO (10 chars LogicalSystem (can be empty), 10 chars ObjectType, 70 chars (max) the ObjectKey)
44 #
45 set OBJECT_HEADER [format "%-10s%-10s%-25s" "" $ObjType $ObjKey]
46 set ::SAPDat(SAPMAIL:OBJECT_HEADER:LINE:1) $OBJECT_HEADER
47 #
48 # Body of the mail
49 #
50 set MailBody "This is my Text"
51 set ::SAPDat(SAPMAIL:CONTENTS_TXT:LINE:1) [string range $MailBody 0 254] ; # each Line takes 255 chars...
52 set ::SAPDat(SAPMAIL:CONTENTS_TXT:LINE:2) [string range $MailBody 255 499] ; # each Line takes 255 chars...
53 # if the Body has more than these 500 chars add here more of the previous lines!
54 
55 #
56 # Now we can send the mail
57 #
59 if {[lindex $Status 0] eq "OK"} {
60  # email was sent to SAP user
61 } else {
62  # email was not sent
63  puts [tpco_formatHEX16 [lindex $Status 1]]
64 }