Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

catch cx_send_req_bcs.

Former Member
0 Likes
3,536

Hello Gurus

There is a little problem with this code.

In an other Program the coding works.

The Problem when the input is one row -> it work. When the input is more. Error.

*********Dokument versenden**********

try. "

call method "

mail_send_request->send( " Email send

exporting "

i_with_error_screen = ' ' "

receiving "

result = sent_to_all ). " Send_Status

if sent_to_all = 'X'. " Send succes?

endif. "

catch cx_send_req_bcs. "

write: 'Error by send'. "

endtry. "

commit work. " LUW close

Thanks for help

Chris

1 ACCEPTED SOLUTION
Read only

sonu_p2
Active Participant
0 Likes
1,997

Hello,

Check out the code below :-

DATA : tl_ltext TYPE bcsy_text.

DATA : l_sent_to_all TYPE os_boolean,

l_send_request TYPE REF TO cl_bcs,

l_document TYPE REF TO cl_document_bcs,

l_recipient TYPE REF TO if_recipient_bcs,

l_recpt TYPE adr6-smtp_addr.

TRY.

l_send_request = cl_bcs=>create_persistent( ).

CATCH cx_send_req_bcs.

PERFORM catch_exception.

ENDTRY.

*C--> lines of the internal table have the error messages

REFRESH tl_ltext.

IF t_err_crchg[] IS NOT INITIAL.

APPEND LINES OF t_err_crchg TO tl_ltext.

ENDIF.

APPEND LINES OF t_error TO tl_ltext.

IF t_error1[] IS NOT INITIAL.

wa_error-error = text-018.

APPEND wa_error TO tl_ltext.

CLEAR wa_error.

APPEND LINES OF t_error1 TO tl_ltext.

ENDIF.

*C--> Create the document and catch any exceptions

TRY.

l_document = cl_document_bcs=>create_document( i_type = text-015

i_text = tl_ltext i_subject = text-006 ).

CATCH cx_document_bcs.

PERFORM catch_exception.

ENDTRY.

TRY.

CALL METHOD l_send_request->set_document( l_document ).

CATCH cx_send_req_bcs.

PERFORM catch_exception.

ENDTRY.

*C--> Create the internet address and catch any exceptions

CLEAR l_recpt.

LOOP AT t_email INTO wa_email.

l_recpt = wa_email-val1.

TRY.

l_recipient = cl_cam_address_bcs=>create_internet_address( l_recpt )

.

CATCH cx_address_bcs.

PERFORM catch_exception.

ENDTRY.

TRY.

CALL METHOD l_send_request->add_recipient

EXPORTING

i_recipient = l_recipient

i_express = c_x.

CATCH cx_send_req_bcs.

PERFORM catch_exception.

ENDTRY.

ENDLOOP.

*C--> send the mail document to all the email addresses specified

CLEAR l_sent_to_all.

TRY.

CALL METHOD l_send_request->send

EXPORTING

i_with_error_screen = c_x

RECEIVING

result = l_sent_to_all.

COMMIT WORK AND WAIT.

CATCH cx_send_req_bcs.

PERFORM catch_exception.

ENDTRY.

<b>Reward points if helpful :-)</b>

thanks,

Sachin

4 REPLIES 4
Read only

athavanraja
Active Contributor
0 Likes
1,997

what do you mean by

"when the input is one row -> it work"

what input you are referring to?

Read only

0 Likes
1,997

When i put one one Entry in this Fm Example 100 it work

When i put more Entry Example 100, 200, 300

The catch cx_send_req_bcs brings an Erorr.

Read only

0 Likes
1,997

which FM?

do you mean when you send more emails its failing?

Read only

sonu_p2
Active Participant
0 Likes
1,998

Hello,

Check out the code below :-

DATA : tl_ltext TYPE bcsy_text.

DATA : l_sent_to_all TYPE os_boolean,

l_send_request TYPE REF TO cl_bcs,

l_document TYPE REF TO cl_document_bcs,

l_recipient TYPE REF TO if_recipient_bcs,

l_recpt TYPE adr6-smtp_addr.

TRY.

l_send_request = cl_bcs=>create_persistent( ).

CATCH cx_send_req_bcs.

PERFORM catch_exception.

ENDTRY.

*C--> lines of the internal table have the error messages

REFRESH tl_ltext.

IF t_err_crchg[] IS NOT INITIAL.

APPEND LINES OF t_err_crchg TO tl_ltext.

ENDIF.

APPEND LINES OF t_error TO tl_ltext.

IF t_error1[] IS NOT INITIAL.

wa_error-error = text-018.

APPEND wa_error TO tl_ltext.

CLEAR wa_error.

APPEND LINES OF t_error1 TO tl_ltext.

ENDIF.

*C--> Create the document and catch any exceptions

TRY.

l_document = cl_document_bcs=>create_document( i_type = text-015

i_text = tl_ltext i_subject = text-006 ).

CATCH cx_document_bcs.

PERFORM catch_exception.

ENDTRY.

TRY.

CALL METHOD l_send_request->set_document( l_document ).

CATCH cx_send_req_bcs.

PERFORM catch_exception.

ENDTRY.

*C--> Create the internet address and catch any exceptions

CLEAR l_recpt.

LOOP AT t_email INTO wa_email.

l_recpt = wa_email-val1.

TRY.

l_recipient = cl_cam_address_bcs=>create_internet_address( l_recpt )

.

CATCH cx_address_bcs.

PERFORM catch_exception.

ENDTRY.

TRY.

CALL METHOD l_send_request->add_recipient

EXPORTING

i_recipient = l_recipient

i_express = c_x.

CATCH cx_send_req_bcs.

PERFORM catch_exception.

ENDTRY.

ENDLOOP.

*C--> send the mail document to all the email addresses specified

CLEAR l_sent_to_all.

TRY.

CALL METHOD l_send_request->send

EXPORTING

i_with_error_screen = c_x

RECEIVING

result = l_sent_to_all.

COMMIT WORK AND WAIT.

CATCH cx_send_req_bcs.

PERFORM catch_exception.

ENDTRY.

<b>Reward points if helpful :-)</b>

thanks,

Sachin