on 2006 Mar 30 1:41 PM
Hi @ all,
I like to send a SAP Mail with an Link to a Case inside. Could I use FM SO_NEW_DOCUMENT_SEND_API1 on that and how could I at a link to an case into my mail.
Thanks for any help.
Regards
Matt
Hi,
check you use this method.
FUNCTION ZSEND_MAIL_INPROCESS.
*"----
""Local interface:
*" IMPORTING
*" REFERENCE(GUID) LIKE CRMD_ORDERADM_H-GUID
*" REFERENCE(PRIOR) LIKE CRMT_ACTIVITY_H_WRK-PRIORITY
*"----
CONFIDENTIAL PROPERTY OF
Ranbaxy Laboratories Limited
*----
Name : ZSEND_MAIL_INPROCESS
Created by : Sivagami.R, Enteg Infotech.
*
Purpose : To get the Escalation time of a Support Message.
*----
Modification Log
*----
********************************************************************
data:
mail like adr6-SMTP_ADDR,
description like crmd_orderadm_h-description,
object_id like crmd_orderadm_h-object_id,
sta like crm_jest-stat,
inact like crm_jest-inact,
D1 LIKE sy-datum value 'ddmmyyyy',
STEXT LIKE TJ30T-TXT30,
NAM1 LIKE BUT000-NAME_FIRST,
NAM2 LIKE BUT000-NAME_LAST,
TXT LIKE TJ30T-TXT30,
TXT1 LIKE TJ30T-TXT30,
STATUS_FLAG LIKE CRMD_ORDERADM_H-ARCHIVING_FLAG,
sp(1) type c value '"',
M_NAME1 LIKE BUT000-NAME_first,
M_NAME2 LIKE BUT000-NAME_LAST,
text like SDBLINE512-LINE,
tab_lines type i,
docdata like sodocchgi1,
header like thead,
d3 like stxl-tdname.
data : begin of text_name occurs 0,
d1 like stxl-tdname,
end of text_name.
data: G1 LIKE THEAD-TDNAME,
G2 LIKE THEAD-TDNAME.
data:
itab_part like crmd_order_index occurs 0 with header line.
data:
p_guid like but000-partner_guid,
link_guid like crmd_link-guid_set,
p_func like crmd_partner-partner_fct,
PER_NO LIKE ADR6-PERSNUMBER,
creator like but000-partner.
data: reclist like somlreci1 occurs 1 with header line,
objtxt like solisti1 occurs 10 with header line,
objpack like sopcklsti1 occurs 1 with header line,
objbin like solisti1 occurs 10 with header line,
listobject like abaplist occurs 1 with header line,
LINES like TLINE occurs 0 with header line,
objhead like solisti1 occurs 1 with header line,
OBJCONT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
**--
DATA : ST LIKE TJ30-ESTAT,
d(2) type n,
m(2) type n,
y(4) type n,
DAT(10) type c,
S1 TYPE C.
DATA : ITAB LIKE CRM_JEST OCCURS 0 WITH HEADER LINE.
G1 = guid.
Select the partner numbers of the support Message
select * from crmd_order_index into table itab_part
where header = guid and
object_type = 'BUS2000116'.
if sy-subrc = 0.
Select the Link GUID of the Message
select single guid_set into link_guid from crmd_link
where guid_hi = guid AND
objtype_set = '07'.
loop at itab_part.
Select the Partner GUID for each partner of the Message
select single partner_guid into p_guid from but000
where partner = itab_part-partner_no.
if sy-subrc = 0.
Select the partner function for the Partner Number
select single partner_fct into p_func from crmd_partner
where partner_no = p_guid and guid = link_guid.
if p_func = 'SDSM0002'.
creator = itab_part-partner_no.
endif.
endif.
endloop.
endif.
-----Fetching Name and email address of Key User---
SELECT SINGLE PERSNUMBER NAME_FIRST NAME_LAST INTO
(PER_NO, NAM1, NAM2) FROM BUT000
WHERE PARTNER = creator.
SELECT SINGLE SMTP_ADDR INTO MAIL FROM ADR6
WHERE PERSNUMBER = PER_NO.
clear reclist.
refresh reclist.
--
*reclist-receiver = 'sivagami.r@enteg.com'.
reclist-receiver = 'sapgur@ranbaxy.com'."mail-change address
reclist-rec_type = 'U'.
append reclist.
--
SELECT SINGLE POSTING_DATE description object_id INTO
(D1, description, object_id) FROM CRMD_ORDERADM_H
WHERE GUID = guid.
d = d1+6(2).
m = d1+4(2).
y = d1+0(4).
concatenate d m y into dat separated by '/'.
--
SELECT * FROM CRM_JEST INTO TABLE ITAB WHERE OBJNR = GUID.
IF SY-SUBRC = 0.
LOOP AT ITAB.
S1 = ITAB-STAT+0(1).
IF S1 = 'E' AND ITAB-INACT <> 'X'.
ST = ITAB-STAT.
ENDIF.
ENDLOOP.
ENDIF.
----
SELECT SINGLE TXT30 INTO STEXT FROM TJ30T
WHERE STSMA = 'RBX00001' AND
ESTAT = ST AND SPRAS = 'EN'.
*--
data: mtext like tacopca-c254,
sub_text like tacopca-c254,
urlstring like tacopca-c254,
urlstring1 like tacopca-c254.
concatenate 'Dear' nam1 nam2 ':' into mtext separated by space.
Start Designing fo the mail.
OBJCONT-LINE = '<HTML>'.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = '<HEAD><META HTTP-EQUIV="content-type" >'.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = '<CONTENT="text/html; charset=ISO-8859-1"></HEAD>'.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = '<BODY>'.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = mtext.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = '<BR>   '.
APPEND OBJCONT.
CLEAR OBJCONT.
End Designing fo the mail.
TXT = ' is in progress'.
STATUS_FLAG = '2'.
sub_text = 'Support Message'.
concatenate sub_text object_id 'is in process' into sub_text
separated
by space.
DATA :
tno LIKE crmd_orderadm_h-object_id,
action LIKE crmd_orderadm_h-archiving_flag,
itab_ppf LIKE ppfttrigg OCCURS 0 WITH HEADER LINE.
SELECT SINGLE object_id INTO tno FROM crmd_orderadm_h
WHERE guid = guid.
IF sy-subrc = 0.
SELECT * FROM ppfttrigg INTO TABLE itab_ppf
WHERE applkey = tno .
IF sy-subrc = 0.
LOOP AT itab_ppf.
IF itab_ppf-ttype = 'SMSD_SERVICE_ORDER_DNO_FIND_P2'.
action = 1.
EXIT.
ELSE.
action = 0.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
Mail content for InProcess
if action = 0.
mtext = '1st level Support Team has started working on your message'.
elseif action = 1.
mtext = '2nd level Support Team has started working on your message'.
endif.
concatenate mtext 'This is for your information' into
mtext separated by space.
Start Designing fo the mail.
OBJCONT-LINE = mtext.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = '<BR>'.
APPEND OBJCONT.
CLEAR OBJCONT.
End Designing fo the mail.
--
IF PRIOR = '1'.
TXT1 = 'Very High'.
ELSEIF PRIOR = '2'.
TXT1 = 'High'.
ELSEIF PRIOR = '3'.
TXT1 = 'Medium'.
ELSEIF PRIOR = '4'.
TXT1 = 'Low'.
ENDIF.
*----
urlstring1 = guid.
*urlstring = 'http://ransolmandev.ransap.com:8000/sap(bD1lbiZjPTIwMA==)'.
*concatenate urlstring '/bc/bsp/sap/dswp_bsp/dsmop.html?' into urlstring.
*concatenate urlstring 'ISBSP=X&CMD=NOMI&NCMD=CRMVW&ID=' into urlstring.
urlstring = 'http://ransolmandev.ransap.com:8000/sap(bD1lbiZjPTIwMA==)/bc/bsp/sap/dswp_bsp/dsmop.html?ISBSP=X&CMD=NOMI&NCMD=CRMVW&ID='.
concatenate urlstring urlstring1 into urlstring.
*----
OBJPACK-HEAD_START = 1.
OBJBIN = ' | '. APPEND OBJBIN.
OBJPACK-HEAD_START = 1.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
docdata-obj_name = sub_text.
docdata-obj_descr = sub_text.
----
----
mtext = ' '.
CONCATENATE 'Support Message Id    : ' space space object_id INTO mtext.
Start Designing fo the mail.
OBJCONT-LINE = '<BR>   '.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = mtext.
APPEND OBJCONT.
CLEAR OBJCONT.
End Designing fo the mail.
CONCATENATE 'Priority              : ' txt1 INTO mtext SEPARATED BY space.
Start Designing fo the mail.
OBJCONT-LINE = '<BR>   '.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = mtext.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = '<BR>   '.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = 'Details               : '.
APPEND OBJCONT.
CLEAR OBJCONT.
End Designing fo the mail.
--
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'SU99'
LANGUAGE = 'E'
NAME = G1
OBJECT = 'CRM_ORDERH'
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER = HEADER
TABLES
LINES = LINES
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
.
IF SY-SUBRC = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
if lines[] is not initial.
LOOP AT LINES.
Start Designing fo the mail.
OBJCONT-LINE = lines-tdline.
APPEND OBJCONT.
CLEAR OBJCONT.
End Designing fo the mail.
ENDLOOP.
endif.
ENDIF.
CONCATENATE G1 '%' INTO G2.
select tdname into table text_name
from stxl where
TDID = 'SU01' AND
TDNAME LIKE G2.
if sy-subrc = 0.
Start Designing fo the mail.
OBJCONT-LINE = '<BR>   '.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = 'Reply                 : '.
APPEND OBJCONT.
CLEAR OBJCONT.
End Designing fo the mail.
loop at text_name.
*--
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'SU01'
LANGUAGE = 'E'
NAME = text_name-d1
OBJECT = 'CRM_ORDERH'
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER = HEADER
TABLES
LINES = LINES
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
.
IF SY-SUBRC = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
if lines[] is not initial.
LOOP AT LINES.
Start Designing fo the mail.
OBJCONT-LINE = lines-tdline.
APPEND OBJCONT.
CLEAR OBJCONT.
End Designing fo the mail.
ENDLOOP.
endif.
ENDIF.
endloop.
endif.
Start Designing fo the mail.
OBJCONT-LINE = text-001.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = '<BR><BR><BR>    Solution Manager Link : '.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = urlstring.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = '<BR><BR><BR>Thanks<BR>Ranbaxy Support Desk<BR>Email : support@ranbaxy.com'.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = text-002.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = SPACE.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = '<BR>'.
APPEND OBJCONT.
CLEAR OBJCONT.
OBJCONT-LINE = '</BODY></HTML>'.
APPEND OBJCONT.
CLEAR OBJCONT.
End Designing fo the mail.
DESCRIBE TABLE OBJCONT LINES tab_lines.
READ TABLE OBJCONT INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 500 + STRLEN( OBJCONT ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'HTM'.
APPEND objpack.
Send Message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X' "used from rel.6.10
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
tables
packing_list = objpack
OBJECT_HEADER = objhead
CONTENTS_BIN = objbin
CONTENTS_TXT = OBJCONT
CONTENTS_HEX = objhex
OBJECT_PARA =
OBJECT_PARB =
receivers = reclist
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 <> 0.
message ID 'SO' TYPE 'S' NUMBER '023' with docdata-obj_name.
ENDIF.
ENDFUNCTION.
cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.