Application Development 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: 

Why cl_bcs=>send() sends a message for several times?

Former Member
0 Kudos
613

Hi, experts i've got a problem where cl_bcs=>send() sends a message for several times.

Why it's happening and how to fix that?

data : begin of user_msg OCCURS 0.
data : usnam type usnam.
data end of user_msg.
delete ADJACENT DUPLICATES FROM user_msg comparing usnam.
loop at user_msg into ls_user_msg.

select * from zstorn_logs
INTO CORRESPONDING FIELDS OF TABLE lt_tab
WHERE usnam = ls_user_msg-usnam
and zstorndate = sy-datum.
try.
perform htm.
send_request = cl_bcs=>create_persistent( ).
document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = lt_html
i_subject = 'Автоматический отпуск поставок' ).

CALL METHOD send_request->set_document( document ).
recipient = cl_sapuser_bcs=>create( ls_user_msg-usnam ).

CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.

CALL METHOD send_request->send( ).

COMMIT WORK and WAIT.
catch cx_bcs into bcs_exception.
* write: ls_vbeln_user-usnam.
write: 'Fehlertyp:'(002), bcs_exception->error_type.
exit.
ENDTRY.
clear lt_html.
clear send_request.
clear text.
clear document.
clear recipient.
clear str.
clear lt_tab.
clear curr_matnr.
endloop.

Here's in select i get data for every user in a loop.

And in 'perform htm' making an gtml table.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
497

As the internal table user_msg is not sorted by its definition, did you sort it explicitly before delete adjacent duplicates or is it sorted by construction (select order by)

6 REPLIES 6

abo
Active Contributor
497

You may edit the question instead of deleting and then reposting it: notifications are sent out twice!

xiswanto
Active Participant
0 Kudos
497

by 'several times' as in how many times? each user receive 2, 3, or how many mails?

perhaps you are receiving an extra status notification mail?

Former Member
0 Kudos
497

sometimes 2, sometimes 3, sometimes 8. It's absolutely random

No, it's just sent the same message for several times

raymond_giuseppi
Active Contributor
498

As the internal table user_msg is not sorted by its definition, did you sort it explicitly before delete adjacent duplicates or is it sorted by construction (select order by)

matt
Active Contributor
497

Love that you have lt_html, which is filled in a form HTM and therefore is clearly global, not local as the l prefix usually indicates.

Btw. CALL METHOD isn't necessary any more. You can use the more modern functional form.

And FORMs are considered obsolete and shouldn't be used for new programs.

Have you tried debugging?

Sandra_Rossi
Active Contributor
497

In short, cl_bcs=>send() does never send a message several times.

If a message is sent several times, it's because your program calls cl_bcs=>send() several times.

Debug your program consciously and rigorously till you understand where the bug really is and fix it.