‎2022 Aug 18 12:51 PM
‎2022 Aug 18 12:55 PM
Your create_internet_address method call should be inside the loop. In it's current form you would only have a recipient for the last LOOP iteration.
‎2022 Aug 18 5:49 PM
ryan.crosby2 Like this? Is it still sending one send request instead of multiple
‎2022 Aug 18 6:13 PM
If you want multiple send requests then you wouldn't LOOP at recipients, but rather one level higher and assign the recipient to the corresponding send request.
‎2022 Aug 19 3:02 AM
‎2022 Aug 19 9:50 AM
All your questions miss information. Why don't you just ask one question containing the whole program that we may test for you? (that would be a 30-lines program)
You don't explain if you use BCS or one of the old SO function modules.
If you use BCS, then you should use cl_cam_address_bcs=>create_internet_address + method add_recipient, and LT_REC is useless.
If you use one of the old SO function modules, then you should NEITHER use cl_cam_address_bcs=>create_internet_address NOR the method add_recipient, as you use the parameter RECEIVERS = LT_REC.
‎2022 Aug 19 12:51 PM
Where/How did you add those recipients to the mail, post part of your your code similar to
lo_recipient = cl_cam_address_bcs=>create_internet_address( lv_recept_addr ).
lo_bcs->add_recipient( lo_recipient ).
NB: If user can input list of users within a select-options, you could/should resolve this list with a SELECT or a call of BAPI_USER_GETLIST, as soon as you don't insure user can only input some individual values (no range, no wildcard, using SELECT_OPTIONS_RESTRICT)
‎2022 Aug 19 1:27 PM
SELECTION-SCREEN BEGIN OF BLOCK bl2 WITH FRAME TITLE text-010.
SELECT-OPTIONS:
s_inbox FOR bname NO INTERVALS, "SAP ID
s_email FOR bname NO INTERVALS. "External Email(HOWEVER SAP USER ID IS INPUTTED HERE)
SELECTION-SCREEN END OF BLOCK bl2.
DATA: LT_DEST TYPE TABLE OF solmrecil,
LX_DEST LIKE LINE OF LT_DEST,
lx_bapiaddr3 TYPE bapiaddr3,
lt_bapiret2 TYPE STANDARD TABLE OF bapiret2,
lo_send_request TYPE REF TO cl_bcs,
lo_sender TYPE REF TO cl_sapuser_bcs,
l_recipient TYPE REF TO if_recipient_bcs,
lo_recipient TYPE ad_smtpadr.
LOOP AT s_inbox ASSIGNING FIELD-SYMBOL(<lfs_inbox>).
IF <lfs_inbox> IS ASSIGNED.
lx_dest-receiver = <lfs_inbox>-low.
lx_dest-rec_type = lc_b.
APPEND lx_dest TO lt_dest.
CLEAR: lx_dest.
ENDIF.
ENDLOOP.
LOOP AT s_email.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = s_email-low
IMPORTING
address = lx_bapiaddr3
TABLES
return = lt_bapiret2.
IF line_exists( lt_bapiret2[ type = 'E' ] ).
CONTINUE.
ENDIF.
CHECK lx_bapiaddr3-e_mail IS NOT INITIAL.
lt_dest = VALUE #( BASE lt_dest[]
( rec_type = 'U'
receiver = lx_bapiaddr3-e_mail
express = abap_false ) ).
ENDLOOP.
"THIS CODE SENDS ONE EMAIL TO MULTIPLE RECIPIENTS
LOOP AT s_inbox[] ASSIGNING FIELD-SYMBOL(<s_inbox>).
lo_sender = cl_sapuser_bcs=>create( <s_inbox>-low ).
ENDLOOP.
lo_send_request->add_recipient( lo_sender ).
"THIS CODE SENDS ONE SEND REQUEST TO ONE EMAIL INSTEAD OF MULTIPLE EMAILS
l_recipient = cl_cam_address_bcs=>create_internet_address(
lx_bapiaddr3-e_mail ).
CALL METHOD lo_send_request->add_recipient
EXPORTING
i_recipient = l_recipient.
‎2022 Aug 19 3:32 PM
What do you expect from your code, just debug it once
Do you intend to use CL_BCS or obsolete FM, seems you are lost in the middle of a conversion?
Suggestion:
‎2022 Aug 19 12:59 PM
sandra.rossi Apologies as I was just maintaining this old program and new into ABAP. My goal was just to send multiple send requests.
In this code: the s_email is from a select-option parameter where in users will input multiple SAP IDs and the code below will check its internet address.
SELECTION-SCREEN BEGIN OF BLOCK bl2 WITH FRAME TITLE text-010.
SELECT-OPTIONS:
s_inbox FOR bname NO INTERVALS, "SAP ID
s_email FOR bname NO INTERVALS. "External Email(HOWEVER SAP USER ID IS INPUTTED HERE)
SELECTION-SCREEN END OF BLOCK bl2.
DATA: LT_DEST TYPE TABLE OF solmrecil,
LX_DEST LIKE LINE OF LT_DEST,
lx_bapiaddr3 TYPE bapiaddr3,
lt_bapiret2 TYPE STANDARD TABLE OF bapiret2,
lo_send_request TYPE REF TO cl_bcs,
lo_sender TYPE REF TO cl_sapuser_bcs,
l_recipient TYPE REF TO if_recipient_bcs,
lo_recipient TYPE ad_smtpadr.
LOOP AT s_inbox ASSIGNING FIELD-SYMBOL(<lfs_inbox>).
IF <lfs_inbox> IS ASSIGNED.
lx_dest-receiver = <lfs_inbox>-low.
lx_dest-rec_type = lc_b.
APPEND lx_dest TO lt_dest.
CLEAR: lx_dest.
ENDIF.
ENDLOOP.
LOOP AT s_email.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = s_email-low
IMPORTING
address = lx_bapiaddr3
TABLES
return = lt_bapiret2.
IF line_exists( lt_bapiret2[ type = 'E' ] ).
CONTINUE.
ENDIF.
CHECK lx_bapiaddr3-e_mail IS NOT INITIAL.
lt_dest = VALUE #( BASE lt_dest[]
( rec_type = 'U'
receiver = lx_bapiaddr3-e_mail
express = abap_false ) ).
ENDLOOP.
"THIS CODE SENDS ONE EMAIL TO MULTIPLE RECIPIENTS
LOOP AT s_inbox[] ASSIGNING FIELD-SYMBOL(<s_inbox>).
lo_sender = cl_sapuser_bcs=>create( <s_inbox>-low ).
ENDLOOP.
lo_send_request->add_recipient( lo_sender ).
"THIS CODE SENDS ONE SEND REQUEST TO ONE EMAIL INSTEAD OF MULTIPLE EMAILS
l_recipient = cl_cam_address_bcs=>create_internet_address(
lx_bapiaddr3-e_mail ). CALL METHOD lo_send_request->add_recipient
EXPORTING
i_recipient = l_recipient.
‎2022 Aug 19 1:50 PM
This program is incorrect. I have just explained why.
You'd better create a small program, activate it, test it, then share it with your question.