2012 Jun 29 7:32 AM
Hi all,
I am using function module to send mail.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = w_doc_data
* DOCUMENT_TYPE = 'RAW'
PUT_IN_OUTBOX = 'X'
* COMMIT_WORK = ' '
* IP_ENCRYPT =
* IP_SIGN =
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
* OBJECT_HEADER =
OBJECT_CONTENT = it_object_content
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
RECEIVERS = it_receivers
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.
But it is throwing a x_error.
What can be the probable cause for the same?
ENDIF.
2012 Jun 29 8:31 AM
Hi
check this
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_type = 'RAW'
document_data = w_doc_data
put_in_outbox = 'X'
commit_work = 'X "Uncoment this
tables
object_content = it_object_content
receivers = it_receivers
exceptions
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
others = 99.
Check this sample program,
It is used to send mail to sap inbox.
report ztemp.
data: objcont like solisti1 occurs 5 with header line.
data: reclist like somlreci1 occurs 5 with header line.
data: doc_chng like sodocchgi1.
data: entries like sy-tabix.
data: name(15).
data: receivers type table of usr21 with header line.
select * from usr21 into table receivers where bname = 'PHANI'.
* fill the document
doc_chng-obj_name = 'TITLE'.
*subject of mail
doc_chng-obj_descr = 'Read at once !'.
*p-confidential or o-open
doc_chng-sensitivty = 'P'.
*appending lines of the document m.ail
objcont = 'Hello experts!!!'.
append objcont.
*One more line in the content of document
objcont = 'Sample program'.
append objcont.
describe table objcont lines entries.
read table objcont index entries.
doc_chng-doc_size = ( entries - 1 ) * 255 + strlen( objcont ).
*the table reclist contains the receivers of the m.ail (fill it according to your logic)
loop at receivers.
*fill the receiver list
clear reclist.
reclist-receiver = receivers-bname.
reclist-rec_type = 'B'.
reclist-express = 'X'.
append reclist.
endloop.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_type = 'RAW'
document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
tables
object_content = objcont
receivers = reclist
exceptions
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
others = 99.
case sy-subrc.
when 0.
loop at reclist.
if reclist-receiver = space.
name = reclist-rec_id.
else.
name = reclist-receiver.
endif.
if reclist-retrn_code = 0.
write: / name, ': succesfully sent'.
else.
write: / name, ': error occured'.
endif.
endloop.
when 1.
write: / 'Too many receivers specified !'.
when 2.
write: / 'No receiver got the document !'.
when 4.
write: / 'Missing send authority !'.
when others.
write: / 'Unexpected error occurred !'.
endcase.
Hi all,
I am using function module to send mail.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = w_doc_data
* DOCUMENT_TYPE = 'RAW'
PUT_IN_OUTBOX = 'X'
* COMMIT_WORK = ' '
* IP_ENCRYPT =
* IP_SIGN =
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
* OBJECT_HEADER =
OBJECT_CONTENT = it_object_content
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
RECEIVERS = it_receivers
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.
But it is throwing a x_error.
What can be the probable cause for the same?
ENDIF.
2012 Jun 29 7:42 AM
Hi Sanghamitra,
check these links. they might help resolve your error.
http://wiki.sdn.sap.com/wiki/display/ABAP/Send+Message+to+External+email+id+and+SAP+User+id+via+ABAP
http://www.sapdev.co.uk/reporting/email/email_mbody.htm
http://wiki.sdn.sap.com/wiki/display/Snippets/Send+mail+via+SAP+ABAP+Code
compare the code and debug to see where you are going wrong.
2012 Jun 29 7:52 AM
Hi Sanghamitra,
Please pass below essentiel parameters to FM:
call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = gd_doc_data
put_in_outbox = 'X'
sender_address = '[email protected]'
sender_address_type = 'INT'
commit_work = 'X'
importing
sent_to_all = gd_sent_all
tables
packing_list = it_packing_list
contents_txt = it_message
receivers = it_receivers
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.
also ,you may refer below link:
http://wiki.sdn.sap.com/wiki/display/Snippets/Send+mail+via+SAP+ABAP+Code
2012 Jun 29 8:31 AM
Hi
check this
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_type = 'RAW'
document_data = w_doc_data
put_in_outbox = 'X'
commit_work = 'X "Uncoment this
tables
object_content = it_object_content
receivers = it_receivers
exceptions
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
others = 99.
Check this sample program,
It is used to send mail to sap inbox.
report ztemp.
data: objcont like solisti1 occurs 5 with header line.
data: reclist like somlreci1 occurs 5 with header line.
data: doc_chng like sodocchgi1.
data: entries like sy-tabix.
data: name(15).
data: receivers type table of usr21 with header line.
select * from usr21 into table receivers where bname = 'PHANI'.
* fill the document
doc_chng-obj_name = 'TITLE'.
*subject of mail
doc_chng-obj_descr = 'Read at once !'.
*p-confidential or o-open
doc_chng-sensitivty = 'P'.
*appending lines of the document m.ail
objcont = 'Hello experts!!!'.
append objcont.
*One more line in the content of document
objcont = 'Sample program'.
append objcont.
describe table objcont lines entries.
read table objcont index entries.
doc_chng-doc_size = ( entries - 1 ) * 255 + strlen( objcont ).
*the table reclist contains the receivers of the m.ail (fill it according to your logic)
loop at receivers.
*fill the receiver list
clear reclist.
reclist-receiver = receivers-bname.
reclist-rec_type = 'B'.
reclist-express = 'X'.
append reclist.
endloop.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_type = 'RAW'
document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
tables
object_content = objcont
receivers = reclist
exceptions
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
others = 99.
case sy-subrc.
when 0.
loop at reclist.
if reclist-receiver = space.
name = reclist-rec_id.
else.
name = reclist-receiver.
endif.
if reclist-retrn_code = 0.
write: / name, ': succesfully sent'.
else.
write: / name, ': error occured'.
endif.
endloop.
when 1.
write: / 'Too many receivers specified !'.
when 2.
write: / 'No receiver got the document !'.
when 4.
write: / 'Missing send authority !'.
when others.
write: / 'Unexpected error occurred !'.
endcase.
2012 Jun 29 10:38 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |