2008 Aug 19 6:00 PM
I am facing the problem in sending mail while using FMs SO_OBJECT _SEND
Or
SO_NEW_DOCUMENT_SEND_API1.
Am I missing some thing while passing. Codes were attached here with this mail.
Could you please suggest me Which parameters I missed while supplying to FM.
None of the codes are working.
Could you please suggest me which one is preferable.
======================================
REPORT ZCONSOLIDATED_02.
DATA : GS_MAIL_HEADER LIKE SOOD1.
DATA: GT_MAIL_CONTENT TYPE STANDARD TABLE OF SOLI WITH HEADER LINE.
DATA: GT_RECEIVER_LIST TYPE STANDARD TABLE OF SOOS1 WITH HEADER
LINE.
*-- Fill Mail Header
PERFORM FILL_MAIL_HEADER.
Populate the document_data
PERFORM FILL_DOCUMENT_DATA.
Populate the reciever table
PERFORM POPULATE_RECIEVER.
Call the function module to send the emails
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
OBJECT_HD_CHANGE = GS_MAIL_HEADER
OBJECT_TYPE = 'RAW'
OUTBOX_FLAG = 'X'
OWNER = SY-UNAME
ORIGINATOR_TYPE = 'U'
TABLES
OBJCONT = GT_MAIL_CONTENT
RECEIVERS = GT_RECEIVER_LIST
EXCEPTIONS
ACTIVE_USER_NOT_EXIST = 1
COMMUNICATION_FAILURE = 2
COMPONENT_NOT_AVAILABLE = 3
FOLDER_NOT_EXIST = 4
FOLDER_NO_AUTHORIZATION = 5
FORWARDER_NOT_EXIST = 6
NOTE_NOT_EXIST = 7
OBJECT_NOT_EXIST = 8
OBJECT_NOT_SENT = 9
OBJECT_NO_AUTHORIZATION = 10
OBJECT_TYPE_NOT_EXIST = 11
OPERATION_NO_AUTHORIZATION = 12
OWNER_NOT_EXIST = 13
PARAMETER_ERROR = 14
SUBSTITUTE_NOT_ACTIVE = 15
SUBSTITUTE_NOT_DEFINED = 16
SYSTEM_FAILURE = 17
TOO_MUCH_RECEIVERS = 18
USER_NOT_EXIST = 19
X_ERROR = 20
OTHERS = 21.
&----
*& Form FILL_MAIL_HEADER
&----
text
----
form FILL_MAIL_HEADER .
CLEAR GS_MAIL_HEADER.
GS_MAIL_HEADER-OBJLA = 'E'.
GS_MAIL_HEADER-OBJNAM = 'Dedicated SO change'(041).
GS_MAIL_HEADER-OBJSNS = 'P'.
GS_MAIL_HEADER-OBJPRI = '2'.
CONCATENATE 'Dedicated SO'
'GT_VBAP-VBELN'
'LV_PO_NUMBER'
' - Change'
INTO GS_MAIL_HEADER-OBJDES
SEPARATED BY SPACE.
endform. " FILL_MAIL_HEADER
&----
*& Form FILL_DOCUMENT_DATA
&----
text
----
form FILL_DOCUMENT_DATA .
GT_MAIL_CONTENT-LINE = 'Size PO QTY Recieved QTY' .
APPEND GT_MAIL_CONTENT.
GT_MAIL_CONTENT-LINE = 'Size PO QTY Recieved QTY' .
APPEND GT_MAIL_CONTENT.
endform. " FILL_DOCUMENT_DATA
&----
*& Form POPULATE_RECIEVER
&----
text
----
form POPULATE_RECIEVER .
CLEAR : GT_RECEIVER_LIST[],
GT_RECEIVER_LIST.
GT_RECEIVER_LIST-RCDAT = SY-DATUM.
GT_RECEIVER_LIST-RCTIM = SY-UZEIT.
GT_RECEIVER_LIST-SNDPRI = '1'.
GT_RECEIVER_LIST-SNDEX = 'X'.
GT_RECEIVER_LIST-RECNAM = 'U-'.
GT_RECEIVER_LIST-RECESC = 'U'.
GT_RECEIVER_LIST-SNDART = 'INT'.
GT_RECEIVER_LIST-SORTCLASS = '5'.
GT_RECEIVER_LIST-RECEXTNAM = 'LV_SMTP_ADDR'.
APPEND GT_RECEIVER_LIST.
endform. " POPULATE_RECIEVER
ORRRRRRR
Report SEND_MAIL .
&----
*& Form SEND_MAIL *
&----
This routine is to send mail to concerned DL. *
----
form SEND_MAIL .
data: maildata type sodocchgi1.
data: mailtxt type table of solisti1 with header line.
data: mailrec type table of somlrec90 with header line.
clear: maildata, mailtxt, mailrec.
refresh: mailtxt, mailrec.
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test mail'.
maildata-obj_langu = sy-langu.
Loop at your ITAB here and append the row of ITAB
to mailtxt.
mailtxt-line = 'This is a test for send mail'.
append mailtxt.
mailrec-receiver = 'name at the ratecompany.com'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'RAW'
put_in_outbox = 'X'
tables
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
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 SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " SEND_MAIL
2008 Aug 19 8:19 PM
First check in SCOT , it is configured properly or not. if it is not configured then it is not possible to send any mail to external id.
Second do this..
if sy-subrc eq 0.
commit work.
*-- DEQUEUE THE LOCK CREATED BY SO_OBJECT_SEND -----------------------
call function 'SO_DEQUEUE_UPDATE_LOCKS'.
endif.
2008 Aug 19 6:02 PM
Better use-->SO_NEW_DOCUMENT_SEND_API1 with COMMIT WORK..
try with this..
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
SELECT-OPTIONS: S_EMAIL FOR SOMLRECI1-RECEIVER NO INTERVALS OBLIGATORY.
FORM SEND_MAIL_SUPPORT TABLES P_EM_BODY
USING P_TITLE.
*_ Start of the code to send an email notification
DATA : ATTACH_REC TYPE I.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE,
OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,
OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
DOC_CHNG LIKE SODOCCHGI1,
TAB_LINES LIKE SY-TABIX.
Creation of the document to be sent
DOC_CHNG-OBJ_NAME = 'Mat Attach'(010).
DOC_CHNG-OBJ_DESCR = P_TITLE.
APPEND LINES OF P_EM_BODY TO OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
*Creation of the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
DESCRIBE TABLE IT_ERROR LINES ATTACH_REC.
IF ATTACH_REC GE '1'.
*Start of email attachement of internal table conversition
APPEND LINES OF IT_ERROR TO OBJBIN.
WRITE: '----
' TO OBJBIN.
APPEND OBJBIN.
CLEAR OBJBIN.
CONCATENATE 'CCode.' 'A/CDocNum.' ' FYear.' 'DType.' 'PDate.' ' RefField.' INTO
V_TEXT SEPARATED BY ' '.
APPEND V_TEXT TO OBJBIN.
CLEAR V_TEXT.
WRITE: '----
' TO OBJBIN.
APPEND OBJBIN.
CLEAR OBJBIN.
LOOP AT IT_ERROR.
CONCATENATE IT_ERROR-BUKRS IT_ERROR-BELNR IT_ERROR-GJAHR IT_ERROR-BLART
IT_ERROR-BUDAT IT_ERROR-STATUS INTO V_TEXT SEPARATED BY ' '.
APPEND V_TEXT TO OBJBIN.
CLEAR V_TEXT.
ENDLOOP.
WRITE: '----
' TO OBJBIN.
APPEND OBJBIN.
CLEAR OBJBIN.
DESCRIBE TABLE OBJBIN LINES OBJPACK-BODY_NUM.
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-DOC_SIZE = OBJPACK-BODY_NUM * 255.
OBJPACK-DOC_TYPE = 'RAW'.
OBJPACK-OBJ_DESCR = 'List of Error Documents'(012). " Description
APPEND OBJPACK. CLEAR OBJPACK.
ENDIF.
*reclist-receiver = 'xxxxx@xxxxx.com'.
RECLIST-RECEIVER = S_EMAIL-LOW.
RECLIST-REC_TYPE = 'U'.
RECLIST-COPY = 'X'.
APPEND RECLIST.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
*CHECK SY-SUBRC = 0.
SUBMIT RSCONN01 WITH MODE = C_INT AND RETURN.
ENDFORM. " SEND_MAIL_SUPPORT.
go through this
leave ur mail id i will send u the code just go through once
2008 Aug 19 6:06 PM
Use FM SO_NEW_DOCUMENT_SEND_API1.
Check this example:
http://sapr3.tripod.com/abap011.htm
Regards,
Naimesh Patel
2008 Aug 19 6:52 PM
Hi,
Check this code.
DATA: p_title(50),
em_body LIKE solisti1 OCCURS 10 WITH HEADER LINE,
v_sysdate(12),
v_systime(10).
DATA : attach_rec TYPE i.
DATA: "objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
"objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
"doc_chng LIKE sodocchgi1,
"tab_lines LIKE sy-tabix.
*_ Start of E-mail content.
-
-
-
-
-
APPEND em_body.
CLEAR v_sysdate.
em_body = 'Thanks,'.
-
-
-
-
-
'Note: This is System generated message. Please do not reply'.
APPEND em_body.
IF sy-sysid <> 'P01'.
CONCATENATE 'Exp Compliance Notification' sy-sysid ':' vbak-vbeln
INTO p_title SEPARATED BY space.
ELSE.
CONCATENATE 'Export Compliance Notification order' vbak-vbeln
INTO p_title SEPARATED BY space.
ENDIF.
PERFORM SEND_MAIL_SUPPORT TABLES EM_BODY USING P_TITLE.
Creation of the document to be sent
doc_chng-obj_name = 'Materials'.
*DOC_CHNG-OBJ_DESCR = 'Please check the error message'(002).
doc_chng-obj_descr = p_title.
APPEND LINES OF em_body TO objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
*Creation of the entry for the compressed document
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
DESCRIBE TABLE imail107 LINES attach_rec.
IF attach_rec GE '1'.
*Start of email attachement of internal table conversition
objbin-line =
'Item Material Number Ans1 Ans2 Ans3 Signed by'.
APPEND objbin.
CLEAR objbin.
LOOP AT imail107 INTO wa_mail107.
exp-record+0(06) = wa_mail107-posnr.
exp-record+8(26) = wa_mail107-matnr.
exp-record+30(2) = wa_mail107-zans01ind.
exp-record+39(2) = wa_mail107-zans02ind.
exp-record+47(2) = wa_mail107-zans03ind.
exp-record+54(35) = wa_mail107-name1.
objbin-line = exp-record.
APPEND objbin.
CLEAR: objbin, exp-record.
ENDLOOP.
APPEND LINES OF imail107 TO objbin.
objbin-line =
'Answers: 1 = Disagreed 2 = Agreed'.
APPEND objbin.
CLEAR objbin.
*end of email attachement of internal table conversition
DESCRIBE TABLE objbin LINES objpack-body_num.
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-doc_size = objpack-body_num * 255.
objpack-doc_type = 'DOC'.
objpack-obj_descr = 'Materials'. " Description
APPEND objpack. CLEAR objpack.
ENDIF.
*_ Receiver
reclist-receiver = zsd100-zdata.
reclist-rec_type = 'U'.
reclist-copy = 'X'.
APPEND reclist.
CLEAR reclist.
ENDSELECT.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.
REFRESH: objpack,
objhead,
objbin,
objtxt,
reclist.
clear: doc_chng.
2008 Aug 19 7:32 PM
Hai ,
Thanks for your assistance.
I NEED TO SEND MAIL TO EXTERNAL ADDRESS.
2008 Aug 19 7:59 PM
I am working on ECC 6.0 env.
None of the codes are working to send my internal table to external address .
Can any body send me the code which will send mail in ECC 6.0.
thanks a tonne in adv.
2008 Aug 19 8:19 PM
First check in SCOT , it is configured properly or not. if it is not configured then it is not possible to send any mail to external id.
Second do this..
if sy-subrc eq 0.
commit work.
*-- DEQUEUE THE LOCK CREATED BY SO_OBJECT_SEND -----------------------
call function 'SO_DEQUEUE_UPDATE_LOCKS'.
endif.
2008 Aug 19 8:28 PM
Hi Kumar,
You need use the statement commit work . This should help.
2008 Aug 19 9:06 PM
Vijay babu,
how can I give you extra points.
I really don't know how to give extra points.
YOU ARE GREAT.
THANKS.
2008 Aug 20 1:57 AM
One more doubt please.
I have three output internal tables. Out of which two are error internal tables and the other one is resulted output internal table.
I need to send each error internal tables to mulitiple recipents and resulted output internal table to multiple recipents.
Do I need to use function module SO_NEW_DOCUMENT_SEND_API1 three times ?
Can I pass multiple email ids at a time to the function module SO_NEW_DOCUMENT_SEND_API1 ?
Thansk in advance
Do I need to use
2008 Aug 20 3:45 AM
>i need to send each error internal tables to mulitiple recipents and resulted output internal table to >multiple recipents.
>Do I need to use function module SO_NEW_DOCUMENT_SEND_API1 three times ?
yes, Since the mail content is different
>Can I pass multiple email ids at a time to the function module SO_NEW_DOCUMENT_SEND_API1 ?
Yes , you append the ids to the RECEIVERS, so that you can send to many id at a time.
2008 Aug 20 4:59 AM
Thanks Vijay.
I have to give points for this .
But there is no option .
how can I give .just guide me.
It helps me in future.
HIGHLY APPRECIATED UR HELP SIR.