2013 May 23 10:30 AM
I am not particularly bright as will soon become apparent... so any help is greatly appreciated. Also I am not familiar with error handling.
I have an inbound IDOC which runs every evening around 22h00 in background. I have created an enhancement to send an email to various parties if the IDOC does not process successfully.
Most of the time it works and if the IDOC is unsuccessful then an email is sent. There are however times when the email is not sent and I need some ideas of how to handle this?
My code (utilising Class CL_BCS) is currently:
send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = sent_to_all ).
COMMIT WORK.
WAIT UP TO 1 SECONDS.
I am thinking of changing the code to this:
try.
send_request->send(
exporting
i_with_error_screen = 'X'
receiving
result = sent_to_all ).
commit work.
catch cx_send_req_bcs.
endtry.
If I use this code to catch the error what happens? I would like to know if an email was sent or not, I don't want to have to keep physically checking the IDOC logs every day. If I catch the error at this point and perhaps save it to an internal table then what should I do next?
2013 May 23 10:56 AM
Glen,
1 - How about creating a ZTABLE and update the same in times of exception?
2 - As IDOCs ae processed in a job, how about using a "WRITE" statement in times of exception?
This will ensure, in the job log you have the IDoc # for whom the mail is not sent.
TRY
send_request->send(
exporting
i_with_error_screen = 'X'
receiving
result = sent_to_all ).
commit work.
catch cx_send_req_bcs INTO lv_text.
Write: Idoc no, lv_text->errortext.
ENDTRY
Cheers!
Abhinab
I am not particularly bright as will soon become apparent... so any help is greatly appreciated. Also I am not familiar with error handling.
I have an inbound IDOC which runs every evening around 22h00 in background. I have created an enhancement to send an email to various parties if the IDOC does not process successfully.
Most of the time it works and if the IDOC is unsuccessful then an email is sent. There are however times when the email is not sent and I need some ideas of how to handle this?
My code (utilising Class CL_BCS) is currently:
send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = sent_to_all ).
COMMIT WORK.
WAIT UP TO 1 SECONDS.
I am thinking of changing the code to this:
try.
send_request->send(
exporting
i_with_error_screen = 'X'
receiving
result = sent_to_all ).
commit work.
catch cx_send_req_bcs.
endtry.
If I use this code to catch the error what happens? I would like to know if an email was sent or not, I don't want to have to keep physically checking the IDOC logs every day. If I catch the error at this point and perhaps save it to an internal table then what should I do next?
2013 May 23 10:56 AM
Glen,
1 - How about creating a ZTABLE and update the same in times of exception?
2 - As IDOCs ae processed in a job, how about using a "WRITE" statement in times of exception?
This will ensure, in the job log you have the IDoc # for whom the mail is not sent.
TRY
send_request->send(
exporting
i_with_error_screen = 'X'
receiving
result = sent_to_all ).
commit work.
catch cx_send_req_bcs INTO lv_text.
Write: Idoc no, lv_text->errortext.
ENDTRY
Cheers!
Abhinab
2013 May 23 11:05 AM
Hi,
I suppose you can process the exception considering that the exception was raised inside the method. Looking at the coding done in the method, exception is not raised immediately in the method, but other methods called inside it do raise the exception depending on some conditions.
So, you must be able to handle the exception using the CATCH statement written as above. Take the error text, write it to an error file so that you can
get the list of IDOCs where email sending was failed.
Hope this helps,
~Athreya
2013 May 23 11:06 AM
I am not particularly bright as will soon become apparent... That's the funniest thing i've heard today, you made my day mate!
Back to your question, did you trouble shoot why the email sending is failing? Imo the best way to write error logs is to use Application log (SLG* t-codes)
BR,
Suhas
2013 May 23 11:54 AM
Hello Glen,
It is a good option to write the Idoc details for which mail is not sent in spool (Job log) as specified Abhinab.
You can also store the data sent in email in AL11 or write it to spool as a backup if you want.
Thanks.
2013 May 24 12:53 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |