Fm SO_NEW_DOCUMENT_SEND_API1
hi everybody
im using fm SO_NEW_DOCUMENT_SEND_API1 to send mail,
i have 2 receivers, the mail is being sent properly but the sender is getting the mails twice in his mailbox
there are 2 receivers and 1 sender
the sender should receive the mail once, isnt it?
heres my code
concatenate '9118' '@email.net' into mailrec-receiver.
mailrec-rec_type = 'U'.
append mailrec.
concatenate '9808' '@email.net' into mailrec-receiver.
mailrec-rec_type = 'U'.
append mailrec.
loop at 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.
is my code wrong?
Hi
The following code will work properly and sending the mail twice as u have used loop at mailrec.So Mail has been sent two times thats why sender has two mails in sent items.
Just remove loop and endloop from ur code and execute
that will work
Or try this
U can try like this
concatenate '9118''@email.net' into mailrec1-receiver1.
concatenate '9808''@email.net' into mailrec-receiver2.
concatenate mailrec1-receiver1 mailrec-receiver2 into mailrec-receiver separeted by ';'.
mailrec-rec_type = 'U'.
append mailrec.
then
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.
I think it should work
just correct syntax errors.
If helpful reward points
Regs
Manas Ranjan Panda
Message was edited by: MANAS PANDA
Similar Messages
-
Hi All,
In my BSp application user can enter long text ( can be more than 300 char ) in TextEdit.
problem is as below:
1) i am getting all the text in oninput processing ...
2) using the FM READ_TEXT to get mail template built in SO10.
3) Replacing all dynamic variables in mail template with user enterd text.
4) then passing the data to FM SO_NEW_DOCUMENT_SEND_API1. this FM has table parameter with 255 char ( please check once )
i am able to send the data in mail. But long text more than 256 char is not comming as single paragraph.
For expamle ...user enter the following text in text edit.
Responsible for the development, implementation, and maintenance of human resource information systems (HRIS) associated with the collection, retrieval, accessibility, and usage of employee information for Human Resource department planning and activities. Maintains internal database files and tables, and develops custom reports to meet the requirements of Human Resource management and staff.
in inbox i am getting as below:
Job Description for : Responsible for the development, implementation, and maintenance of human resource information systems (HRIS) associated with the collection, retrieval, accessibility, and usage of employee information for Human Resource depa
Maintains internal database files and tables, and develops custom reports to meet the requirements of Human Resource management and staff.
Job Description for is fixed text from SO10 templete. and remainning text is user text.
some data is missing in mail.
SO10 template is as below :
Job Description for : &INSTRUC1&
&INSTRUC2&
help to solve the above issue.
Regads,
Kishan
Edited by: kishanrao.sap on Oct 11, 2010 3:12 PMHi Krishna,
Please use the object_type parameter of tthe FM as 'HTM'.
Then divide the text by append them into the lines of the object_content. In the begining and end make sure you have
<p> -- in the begining
</p>-- in the end
if i want to type the text in one para " My name is Imran and i am an ABAP developer".
CLEAR: WA_OBJECT_CONTENT.
WA_OBJECT_CONTENT-line = '<html>'<body><p> My name is Imran.
APPEND WA_OBJECT_CONTENT TO T_OBJECT_CONTENT.
CLEAR WA_OBJECT_CONTENT.
WA_OBJECT_CONTENT-line = ' and i am an ABAP developer</p></body><html;>'.
APPEND WA_OBJECT_CONTENT TO T_OBJECT_CONTENT.
Hope this helps you.
Regards
Imran. -
Error in Sending email :SO_NEW_DOCUMENT_SEND_API1
Hiiiii Every1,
I m sending e-mail in Html format using the above mentioned FM.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
commit_work = 'X'
document_type = 'HTM'
document_data = doc_chng
put_in_outbox = 'X'
TABLES
object_header = objcont
object_content = objcont
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
and sending it automatically using
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
What the error is that when i send e-mail what i have to check is that weather the the E-mail is sent from SOST or Not..If the Status of that e-mail is Delivered then i have to set a flag for sucess.
Else..Error Message.
How i can check weather is mail is delivered to recipent or Not even if SMTP is creating problem or due to any reason mail is not sent. I have to check.
Plz do reply as soon as Possible.
Thanks & Regards
Sachin DhingraHallo,
I think I understand what you mean. You need the end status of the document after the send process has finshed.
Please try the following way:
After calling
SO_NEW_DOCUMENT_SEND_API1
check the Export parameter:
NEW_OBJECT_ID
It will cointain the new object ID wich is created.
After submiting the send process manually (usually this is not recommended...) the status of the document is updated in the DB Table:
'SOST'.
In this you can look for the object by:
OBJTP
OBJYR
OBJNO
(This can be found in the NEW_OBJECT_ID ).
The fileds:
MSGID
MSGTY
MSGNO
of the table
SOST
will contain the information you requiere.
I hope this helps you.
Regards. -
How to Populate Sender Id in FM SO_NEW_DOCUMENT_SEND_API1
Hi Friends,
I am using FM SO_NEW_DOCUMENT_SEND_API1 for sending an email to the users. Though everything is working fine but I want to set the sender id.
For example any user may run the report but in sender name it should come accountspayable at the rate abc dot com
How and where I can set the sender id.
I have tried populating it in receiver list but of no use.
code of the program
wa_recv_list-receiver = wa_data-email. (receiver mail id)
wa_recv_list-rec_type = 'U'.
wa_recv_list-express = 'X'.
APPEND wa_recv_list TO recv_list.
CLEAR wa_recv_list.
wa_recv_list-receiver = sender.
wa_recv_list-rec_type = 'U'.
APPEND wa_recv_list TO recv_list.
CLEAR wa_recv_list.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = doc_data
document_type = 'RAW'
commit_work = 'X'
TABLES
object_content = objtxt
receivers = recv_list
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.
Kindly help.
PradeepHi,
You can use 'SO_DOCUMENT_SEND_API1' FM
In this you can sene the Sender Id as well
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = lv_doc_data
put_in_outbox = 'X'
sender_address = lv_sender_address
sender_address_type = lv_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = lv_sent_all
new_object_id = new_object_id
SENDER_ID =
TABLES
packing_list = it_packing_list
OBJECT_HEADER =
CONTENTS_BIN =
contents_txt = it_message
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
Regards,
Syed -
I am having trouble sending an email so that it appears in HTML format, nice and pretty. I have been experimenting with FM SO_NEW_DOCUMENT_SEND_API1 and ATTSEND_API1. I have been able to successfully send an email to myself (using an email address outside of SAP), but all I see is the html source code. If I set the DOC_TYP to "HTM", I get the error "Message cannot be processed as it cannot be converted.". Below is my sample code. Has anyone been able to do this in 46C ?
Thanks, Mark
REPORT ZYR_EMAIL_TEST1 .
* SAP 46C
data: maildata type sodocchgi1,
mailhdr type table of solisti1 with header line,
mailtxt type table of solisti1 with header line,
mailbin type table of solisti1 with header line,
mailpack type table of sopcklsti1 with header line,
mailrec type table of somlreci1 with header line,
tab_lines type i.
define bld_txt.
clear mailtxt.
mailtxt = &1.
append mailtxt.
end-of-definition.
define bld_bin.
clear mailbin.
mailbin = &1.
append mailbin.
end-of-definition.
start-of-selection.
clear: maildata, mailhdr, mailtxt, mailbin, mailrec, tab_lines.
refresh: mailhdr, mailtxt, mailbin, mailrec.
perform build_header.
perform build_message.
perform build_pack_list.
perform build_receivers.
perform send_mail_nodialog..
* Use form initiate_mail_execute_program OR process
* with txn SCOT. Check status of mail with txn SOST.
* perform initiate_mail_execute_program.
write: / 'End of program.'.
* Form BUILD_HEADER
form build_header.
maildata-obj_name = 'Email_Name'.
maildata-obj_descr = 'Email_Description'.
* maildata-obj_langu =
* maildata-obj_sort =
mailhdr = 'MYTEST.HTM'.
append mailhdr.
endform.
* Form BUILD_MESSAGE
form build_message.
bld_txt '<html>'.
bld_txt '<head>'.
bld_txt '<title>Untitled Document</title>'.
bld_txt '<meta http-equiv="Content-Type" content="text/html;'.
bld_txt 'charset=iso-8859-1">'.
bld_txt '</head>'.
bld_txt '<body>'.
bld_txt '<div align="center"><em><font' .
bld_txt 'color="#0000FF" size="+7" face="Arial,'.
bld_txt 'Helvetica, sans-serif">THIS'.
bld_txt ' IS A TEST </font></em><br><font' .
bld_txt 'color="#0000FF" size="+7" face="Arial,'.
bld_txt 'Helvetica, sans-serif">Yahoo</font>'.
bld_txt '</div>'.
bld_txt '</body>'.
bld_txt '</html>'.
* Doc_Size is length of last line + ( nbr of other lines x 255 ).
describe table mailtxt lines tab_lines.
read table mailtxt index tab_lines.
maildata-doc_size = ( ( tab_lines - 1 ) * 255 ) + strlen( mailtxt ).
endform.
* Form BUILD_PACK_LIST
form build_pack_list.
clear mailpack.
refresh mailpack.
* mailpack-transf_bin = 'X'.
mailpack-head_start = 1.
mailpack-head_num = 0.
mailpack-body_start = 1.
describe table mailtxt lines tab_lines.
mailpack-body_num = tab_lines.
mailpack-doc_type = 'HTM'.
append mailpack.
endform.
* Form BUILD_RECEIVERS
form build_receivers.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
mailrec-com_type = 'INT'.
append mailrec.
endform.
* Form SEND_MAIL
form send_mail.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_type = 'HTM'
document_data = maildata
* put_in_outbox = ' '
tables
object_header = mailhdr
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.
write: / 'There was error. sy-subrc = ', sy-subrc.
endif.
endform.
* Form INITIATE_MAIL_EXECUTE_PROGRAM
* Instructs mail send program for SAPCONNECT to send email.
form initiate_mail_execute_program.
wait up to 2 seconds.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
endform.Yes, the OBJ_HTM function exists. I found these also, that exist on our system.
SX_OBJECT_CONVERT
SX_OBJECT_CONVERT_ALI_HTM
SX_OBJECT_CONVERT_ALI_PRT
SX_OBJECT_CONVERT_ALI_RAW
SX_OBJECT_CONVERT_ALI_TXT
SX_OBJECT_CONVERT_INT_RAW
SX_OBJECT_CONVERT_OBJ_HTM
SX_OBJECT_CONVERT_OBJ_R3O
SX_OBJECT_CONVERT_OTF_PDF
SX_OBJECT_CONVERT_OTF_PRT
SX_OBJECT_CONVERT_OTF_RAW
SX_OBJECT_CONVERT_RAW_SCR
SX_OBJECT_CONVERT_RAW_TXT
SX_OBJECT_CONVERT_SCR_OTF
SX_OBJECT_CONVERT_TO_AFX
SX_OBJECT_CONVERT_TXT_INT
And these are the entries I see in the SXCONVERT table:
SX_OBJECT_CONVERT_ALI_HTM
SX_OBJECT_CONVERT_ALI_PRT
SX_OBJECT_CONVERT_ALI_RAW
SX_OBJECT_CONVERT_ICS_RAW
SX_OBJECT_CONVERT_INT_RAW
SX_OBJECT_CONVERT_OBJ_HTM
SX_OBJECT_CONVERT_OTF_PDF
SX_OBJECT_CONVERT_OTF_PRT
SX_OBJECT_CONVERT_OTF_RAW
SX_OBJECT_CONVERT_RAW_SCR
SX_OBJECT_CONVERT_RAW_TXT
SX_OBJECT_CONVERT_SCR_OTF
SX_OBJECT_CONVERT_TXT_INT
SX_OBJECT_CONVERT_OBJL_HTM -
Hi ,
I am calling 'SO_NEW_DOCUMENT_SEND_API1' inside an user exit to send an email whenever the notification gets created..If the user exit is called in the same transaction IW21 then the mail is sending successfully.But if the transaction IW21 is called via another transaction say IW31 or IW32 to create a notification,then the mail is not going.instead the mail still in waitning stage in Outbox in SAP business work place.
Note:I should not use commit as 'X in 'SO_NEW_DOCUMENT_SEND_API1' because it is written inside the user exit.
Edited by: Vigneswaran S on Dec 24, 2009 10:17 AMHi,
One option is to call the FM using STARTING NEW TASK and then also use commit = 'X'.
Since we are using NEW TASK, it will occur in new task (and will not affect the user exit).
Also the commit will be done INSIDE the new task, and will not affect the current user exit. This will be independent and done paralelly.
Regards,
Amit Mittal. -
SO_OBJECT _SEND or SO_NEW_DOCUMENT_SEND_API1 to send mail
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_MAILHi,
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. -
Empty attachment with SO_NEW_DOCUMENT_SEND_API1
Hi everyone,
I use SO_NEW_DOCUMENT_SEND_API1 to send mails. Mails are sent without any problem, but there's nothing in the body of the mail. Instead of that, there's an attachement on the mail which is empty.
This is my code :
data: maildata type sodocchgi1.
data: mailtxt type table of solisti1 with header line.
data: mailrec type table of somlrec90 with header line.
start-of-selection.
clear: maildata, mailtxt, mailrec.
refresh: mailtxt, mailrec.
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test'.
maildata-obj_langu = sy-langu.
mailtxt-line = 'This is a test'.
append mailtxt.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'RAW'
commit_work = '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.
Is there anyone who knows why the system behaves like this ?Hi
Try with this
types: begin of t_mara,
matnr type mara-matnr,
matkl type mara-matkl,
mtart type mara-mtart,
meins type mara-meins,
end of t_mara.
data: gt_mara type table of t_mara,
wa_mara like line of gt_mara,
it_packing_list type table of SOPCKLSTI1,
wa_packing_list like line of it_packing_list,
it_receivers type table of SOMLRECI1,
wa_receivers like line of it_receivers,
it_mailbody type table of SOLISTI1,
wa_mailbody like line of it_mailbody,
it_attachment type table of SOLISTI1,
wa_attachment like line of it_attachment.
data: la_doc type SODOCCHGI1.
constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
* get material
select matnr matkl mtart meins
into table gt_mara
from mara
up to 25 rows.
* Populate the subject/generic message attributes
la_doc-obj_langu = sy-langu.
la_doc-obj_descr = 'Material Details' . "Mail Header
la_doc-sensitivty = 'F'.
la_doc-doc_size = 1.
* Add the recipients email address
CLEAR wa_receivers.
REFRESH it_receivers.
wa_receivers-receiver = 'PCSDEVL'.
wa_receivers-rec_type = 'U'.
wa_receivers-com_type = 'INT'.
wa_receivers-notif_del = 'X'.
wa_receivers-notif_ndel = 'X'.
APPEND wa_receivers to it_receivers.
* Mail Body
CLEAR wa_mailbody.
REFRESH it_mailbody.
wa_mailbody-line = 'Please find the attachment'.
APPEND wa_mailbody to it_mailbody.
* Mail attachmwnt
CLEAR wa_attachment.
REFRESH it_attachment.
CONCATENATE 'MATNR' 'MATKL' 'MTART' 'MEINS'
INTO wa_attachment SEPARATED BY con_tab.
CONCATENATE con_cret wa_attachment INTO wa_attachment.
APPEND wa_attachment to it_attachment.
LOOP AT gt_mara INTO wa_mara.
CONCATENATE wa_mara-matnr wa_mara-matkl
wa_mara-mtart wa_mara-meins
INTO wa_attachment SEPARATED BY con_tab.
CONCATENATE con_cret wa_attachment INTO wa_attachment.
APPEND wa_attachment to it_attachment.
ENDLOOP.
* Describe the body of the message
CLEAR wa_packing_list.
REFRESH it_packing_list.
wa_packing_list-transf_bin = space.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 0.
wa_packing_list-body_start = 1.
wa_packing_list-body_num = 1.
wa_packing_list-doc_type = 'RAW'.
APPEND wa_packing_list to it_packing_list.
* Create attachment notification
wa_packing_list-transf_bin = 'X'.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 1.
wa_packing_list-body_start = 1.
DESCRIBE TABLE it_attachment LINES wa_packing_list-body_num.
wa_packing_list-doc_type = 'XLS'. " To word attachment change this as 'DOC'
wa_packing_list-obj_descr = ' '.
concatenate wa_packing_list-doc_type 'file' into wa_packing_list-OBJ_DESCR
separated by space.
wa_packing_list-doc_size = wa_packing_list-body_num * 255.
APPEND wa_packing_list to it_packing_list.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = la_doc
PUT_IN_OUTBOX = 'X'
* SENDER_ADDRESS = SY-UNAME
* SENDER_ADDRESS_TYPE = 'B'
COMMIT_WORK = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
* SENDER_ID =
tables
packing_list = it_packing_list
* OBJECT_HEADER =
CONTENTS_BIN = it_attachment
CONTENTS_TXT = it_mailbody
* 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.
endif.
Reward all helpfull answers
Regards
Pavan -
Line by line text in SO_NEW_DOCUMENT_SEND_API1
Hi everyone
Can anyone plz tell me how can we get the text in the table OBJECT_CONTENT of the function module line by line?
Like, Suppose I have to send the data:
This is SDN.
Welcome
But in the normal case, it is coming as: This is SDN. Welcome
How can I avoid this and get the text in two different lines??
Warm Regards
]DebolinaHi
I am attaching a snippet of my code..
CONCATENATE ' This is a reminder'
': ' INTO WA_OBJECT_CONTENT
SEPARATED BY SPACE.
APPEND WA_OBJECT_CONTENT TO T_OBJECT_CONTENT.
WA_OBJECT_CONTENT-LINE = 'This has been sent from SAP'.
APPEND WA_OBJECT_CONTENT TO T_OBJECT_CONTENT.
This T_OBJECT_CONTENT has been passed to the FM.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOCUMENT_DATA
DOCUMENT_TYPE = 'HTM'
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
OBJECT_HEADER = T_OBJHEAD
OBJECT_CONTENT = T_OBJECT_CONTENT
RECEIVERS = T_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
Warm Regards
Debolina -
Hi everyone,
Is it possible to set a link to a text in the body of a mail sent by SO_NEW_DOCUMENT_SEND_API1, in order to navigate to a SAP transaction?
Example:
Body (in sbwp):
Distribution done. Click here for going to transfer program.
And the link is a transaction to a report program.
Regards everybody in advance. Points promised for every help answer.Hi
Re: link to FM
Regards
pavan -
hello friends,
The below code work perfectly in a report but it does not work with BADI .
The mail needs to be sent to an internet user ,this is the code i am using.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = lx_docu_data
document_type = 'RAW'
commit_work = lc_checked
TABLES
object_content = li_docu_content
receivers = li_receiver
Am able to send mail directly from SE37 to Transaction SCOT and here i need to start the send process and mail is sent sucessfully. But from the code its not working.
li_receiver -> lw_receiver-receiver = useratdomain.com
lw_receiver-rec_type = 'U'.Hi Sheel,
It wont work in a BADI since COMMIT WORK is not explicitly recognized.
Put the FM in a separate report program with COMMIT WORK and call the report using SUBMIT from the BADI. I hope this definitely works!
Let us know how it goes.
Vijay -
Hi Experts,
I am using one FM "SO_NEW_DOCUMENT_SEND_API1" to send mail form my program.
In the receipient inbox under from address the mail is showing
the USER ID in which that program has been executed .
*Is it possible to send a hard coded value as a sender instead of the sap user id in the sender address * .
Regards
sarmistha
Edited by: sarmistha das on May 6, 2008 11:18 AMHi,
Using FM SO_NEW_DOCUMENT_SEND_API1 you cannot have hard coded sender address.
You can create your Z fm that is copy of the above fm and implement an option to have sender address.
Or you can implement below logic to send an email in your program.
*TABLES : ypgtest.
DATA: send_request TYPE REF TO cl_bcs.
DATA: text TYPE bcsy_text.
DATA: xtext TYPE STANDARD TABLE OF solix .
DATA: document TYPE REF TO cl_document_bcs.
DATA: sender TYPE REF TO if_sender_bcs.
DATA: recipient TYPE REF TO if_recipient_bcs.
DATA: bcs_exception TYPE REF TO cx_bcs.
DATA: sent_to_all TYPE os_boolean.
DATA: conlength TYPE i ,
conlengths TYPE so_obj_len ,
result_content TYPE string .
subject TYPE so_obj_des .
DATA: e_r_page TYPE REF TO cl_rsr_www_page.
DATA: content_length TYPE w3param-cont_len ,
content_type TYPE w3param-cont_type,
return_code TYPE w3param-ret_code .
DATA: html TYPE STANDARD TABLE OF w3html .
DATA: server TYPE string ,
port TYPE string .
DATA: wa_rec TYPE ad_smtpadr .
DATA: bcs_message TYPE string .
DATA : reply TYPE REF TO if_recipient_bcs.
DATA: tmp_str TYPE string .
data: v_sender like SENDER_ID.
v_sender = SENDER_ID.
IF NOT recepients[] IS INITIAL .
CLEAR result_content.
CLEAR : server, port .
CALL FUNCTION 'TH_GET_VIRT_HOST_DATA'
EXPORTING
protocol = 1
virt_idx = 0
LOCAL = 1
IMPORTING
hostname = server
port = port
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3 .
CLEAR tmp_str .
CONCATENATE 'http://' server ':' port '/sap/public/' INTO tmp_str .
REPLACE ALL OCCURRENCES OF '/sap/public/' IN result_content WITH
tmp_str .
CLEAR tmp_str .
CLEAR: conlength,conlengths .
REFRESH text .
text[] = email_body[].
TRY.
CLEAR send_request .
send_request = cl_bcs=>create_persistent( ).
CLEAR document .
document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = text
i_length = conlengths
i_subject = subject ).
add document to send request
CALL METHOD send_request->set_document( document ).
CLEAR sender .
sender = cl_cam_address_bcs=>create_internet_address( SENDER_ID ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
CLEAR sender .
reply = cl_cam_address_bcs=>create_internet_address( reply_id ).
CALL METHOD send_request->set_reply_to
EXPORTING
i_reply_to = reply.
CLEAR wa_rec .
LOOP AT recepients INTO wa_rec .
CLEAR recipient .
recipient = cl_cam_address_bcs=>create_internet_address(
wa_rec ).
add recipient with its respective attributes to send request
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
ENDLOOP .
CALL METHOD send_request->set_status_attributes
EXPORTING
i_requested_status = 'E'
i_status_mail = 'E'.
CALL METHOD send_request->set_send_immediately( 'X' ).
---------- send document ---------------------------------------
CALL METHOD send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = sent_to_all ).
IF sent_to_all = 'X'.
APPEND 'Mail sent successfully ' TO return .
ENDIF.
COMMIT WORK.
* exception handling
* replace this very rudimentary exception handling
* with your own one !!!
CATCH cx_bcs INTO bcs_exception.
bcs_message = bcs_exception->get_text( ).
APPEND bcs_message TO return .
EXIT.
ENDTRY.
ELSE .
APPEND 'Specify email address for sending' TO return .
ENDIF .
Regards,
Shravan G. -
Changing senders mail address in 'SO_NEW_DOCUMENT_SEND_API1'
Dear All,
I am using the function module 'SO_NEW_DOCUMENT_SEND_API1' for sending mail to the vendors.
The problem is when the mail is sent from this function module it takes the name of the user logged in in the senders address.
I want to send the mail by some other mail id, so is it possible to change the senders address in this function module.
If not , then is there any other way by which we can send mail and can change the senders addess .
Thanks and Regards
Manik L DhakateHi,
*--Method 1--*
CALL FUNCTION 'SUSR_USER_ADDRESS_READ'
EXPORTING
user_name = wf_user
IMPORTING
user_address = it_address
EXCEPTIONS
user_address_not_found = 1
OTHERS = 2.
IF sy-subrc = 0.
wf_addr_no = it_address-addrnumber.
wf_pers_no = it_address-persnumber.
SELECT SINGLE smtp_addr FROM adr6 INTO wf_addr
WHERE persnumber EQ wf_pers_no AND
addrnumber EQ wf_addr_no.
IF sy-subrc = 0.
p_add = wf_addr.
ENDIF.
*----Another metheod -*
PARAMETERS: p_add(50) TYPE c.
Data: it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
IF p_add IS NOT INITIAL.
CLEAR it_receivers.
IF p_user = c_x.
it_receivers-rec_type = 'B'. "SAP-Username
ELSEIF p_dl = 'X'.
it_receivers-rec_type = 'C'. "Distribution list
ELSEIF p_int = 'X'.
it_receivers-rec_type = 'U'. "Internet Address
ENDIF.
it_receivers-receiver = p_add.
it_receivers-express = 'X'.
APPEND it_receivers.
ENDIF. -
Hi there,
Am using SO_NEW_DOCUMENT_SEND_API1 in batch to issue emails containing multiple blind copied recipients. I load recipient email addresses into RECLIST (see below line)
"DATA: RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.
I have two problems. My first problem is if any one email address in a batch of 10 recipients is formated incorrectly, none of 10 recipients receive emails. My second problem is "incorrect" email addresses. While these do not prevent the remaining 9 emails being delivered I would also like to capture these. How might I capture these 2 conditions at or immediately after function module execution for batch reporting ?
Thank you for your time and help, HaroldHi All,
I have not used that parameter ( Contents_bin ).Its in disable mode only.see my code below and please tell me how to avoid it.
DESCRIBE TABLE i_body LINES g_att_lines.
READ TABLE i_body INTO lw_body INDEX g_att_lines.
gd_doc_data-doc_size = ( g_att_lines - 1 ) * 255 + STRLEN( lw_body ).
lw_packing_list-transf_bin = space.
lw_packing_list-head_start = 1.
lw_packing_list-head_num = 0.
lw_packing_list-body_start = 1.
lw_packing_list-body_num = g_att_lines.
lw_packing_list-doc_type = 'RAW'.
lw_packing_list-doc_size = 255 * g_att_lines.
APPEND lw_packing_list TO i_packing_list .
CLEAR lw_packing_list.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = gd_doc_data
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = i_packing_list
object_header = i_context
contents_txt = i_body
receivers = i_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 .
Regards,
Rakesh. -
Sending mail through FM : SO_NEW_DOCUMENT_SEND_API1
Dear Friends,
I am using the Function Module : SO_NEW_DOCUMENT_SEND_API1 to send mails to MS Outlook. My program is working perfectly fine, when I execute in the foreground. However, when I schedule a job for the same program, it is throwing up an exception. Not sure if it something to do with the user authorization? In fact, user has full authorization. Could someone help on this?
Regards,
ChandruHere we go...
get the 'To' email address. " Receiver mail id.
clear buyer_receivers.
buyer_receivers-receiver = wa_zmala-smtp_addr.
buyer_receivers-rec_type = 'U'.
buyer_receivers-copy = ' '.
append buyer_receivers.
get the 'CC' email address. " Reply back mail id.
clear buyer_receivers.
buyer_receivers-receiver = wa_zmala-rbmail.
buyer_receivers-rec_type = 'U'.
buyer_receivers-copy = 'X'. " Indicates a carbon copy
append buyer_receivers.
get the subject of the mail.
concatenate sy-sysid wa_zmala-bukrs 'SINA' 'DocID'
wa_zmala-documentid wa_zmala-vname into subject_data-obj_descr
separated by '-'.
subject_data-obj_langu = sy-langu.
subject_data-sensitivty = 'F'. " indicates functional
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_type = 'RAW'
document_data = subject_data
put_in_outbox = 'X'
tables
object_content = object_content
receivers = buyer_receivers
exceptions
too_many_receivers = 2
document_not_sent = 3
document_type_not_exist
operation_no_authorization
parameter_error
x_error
enqueue_error
document_not_sent = 2
others = 99.
case sy-subrc.
when 0.
update zmalainbox set
mail_date = sy-datum
mail_time = sy-uzeit
where documentid = wa_zmala-documentid.
condense temp_mailid1. condense temp_mailid2.
write: / temp_docid, text-002, temp_mailid1, ',', temp_mailid2.
uline.
when others.
write: / temp_docid, text-003.
uline.
endcase.
endform
form initiate_mail_send_program.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
endform. -
Issue with SO_NEW_DOCUMENT_SEND_APi1
Hi Experts,
Im able to send mail to external mail ID using FM SO_NEW_DOCUMENT_SEND_API1
but it is coming as a junk mail to the recipient.Along with that junk mail , one more mail is coming to inbox from MAIL DELIVERY SYSTEM.
Is there any parameter to be set inorder for sending the mail to inbox instead as a junk.
Need you help in this..
Thanks in advance.Hi,
Can you point out what changes have been done after unicode check errors ?
That should help in indetifying the problem.
Thanks.
Maybe you are looking for
-
Multiple invoices for single qty in PO
Hi We have created the purchase order for 1 qty and cost is : 500000 Rs . The Account Assignment category is F ( Order ) of the purchase order. Becuase we are settling the total cost from order to AUC. Unfortunally we have received the multiple invoi
-
Exporting report to Word, Word editable or RTF adds page breaks
Our workforce management software (Aspect Workforce Management) uses Crystal 2008 for customer reports. Previewing, printing, and exporting to HTML, PDF, and Excel all work fine but exporting the report to Word, Word Editable, and RTF results in a d
-
Is there a way to automatically create a 1/4 scale duplicate of something that changes with the master. So you have one thing that you draw on and another off to the side, hopefully on another art board, that mirrors it at 1/4 scale. I feel like this
-
Hi, I just downloaded WebLogic 10.0 and installed in my system. But I am not able to start the server, due to the following exception <Jun 22, 2009 5:17:15 PM GMT> <Error> <Security> <BEA-090870> <The realm "myrealm" failed to be loaded: weblogic.sec
-
Hi. I would like to ensure that menus stay open while the visitor is browsing sub menu items Please visit my site to see what I mean: jeffcooperdesign.co.uk/devonsailingtemp Click on Adventure Sailing, the menu opens, then click on Around Britain. Yo