10-11-2011 4:55 AM
Hello,
I am using FM "SO_NEW_DOCUMENT_ATT_SEND_API1" for sending mails. I have to write a COMMIT WORK after the FM execution, since the mails are not going unless COMIT WORK is written. I am writing this code in one enhancement, and I feel its risky to write a COMMIT WORK. Is there any other solution to send mail so the COMMIT WORK is avoided.
I tried with class CL_BCS for which also COMMIT WORK is required.
Thanks and regards,
Madhuri S
Edited by: madhuri sonawane on Oct 11, 2011 9:25 AM
10-11-2011 5:06 AM
Hello Madhuri,
Since SO_NEW_DOCUMENT_ATT_SEND_API1 is an RFM you can call it in a parallel session using the STARTING NEW TASK addition and pass 'X' to the COMMIT_WORK param.
@Dhina: If we pass 'X' to the COMMIT_WORK, an explicit commit is triggered inside the FM. This will terminate the current LUW.
BR,
Suhas
PS: The basic idea is to trigger the COMMIT WORK in a separate session.
Edited by: Suhas Saha on Oct 11, 2011 9:37 AM
10-11-2011 5:06 AM
10-11-2011 5:06 AM
Hello Madhuri,
Since SO_NEW_DOCUMENT_ATT_SEND_API1 is an RFM you can call it in a parallel session using the STARTING NEW TASK addition and pass 'X' to the COMMIT_WORK param.
@Dhina: If we pass 'X' to the COMMIT_WORK, an explicit commit is triggered inside the FM. This will terminate the current LUW.
BR,
Suhas
PS: The basic idea is to trigger the COMMIT WORK in a separate session.
Edited by: Suhas Saha on Oct 11, 2011 9:37 AM
10-11-2011 5:42 AM
hello
As said above....please put 'X ' in the commit work parameter of that FM.
or use the below FM ..I have used this in so many reports it worked...no need of explicit COMMIT WORK.
After you execute your transaction/user exit....goto SOST.transaction .and check whether you have the email in it...if it is there then select it and click on send process.(execute button)..then SAP will send mails from SAP to external email ids.
Because sometimes the SOST background jobs runs slowly depends on the job settings...so we need to explicitly run our email from SOST to send out from SAP.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = lw_sender_address
sender_address_type = lw_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
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.
Hope this helps you.....
10-11-2011 6:21 AM
Thank you very much Suhas, The problem is solved .
Is there any way also for CL_BCS send method?
regards,
Madhuri s
Edited by: madhuri sonawane on Oct 11, 2011 10:56 AM
10-11-2011 6:47 AM
Suhas,
Do we really need to call this function module in NEW TASK with commit option ? If there is an implicit commit happening after the enhancement, I think calling the function module / CL_BCS (without calling explicity COMMIT) will trigger the mail after successful completion of transaction.
Unfortunately I am not able to simulate the scenario in current system. Generated mail is appearing in SOST without commit, but waiting for transmission as my Mail server is not configured. (or is it due to absence of explicity commit? )
Regards, Vinod