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

CREATE_INTERNET_ADDRESS

walkerist79
Participant
10 REPLIES 10
Read only

Ryan-Crosby
Active Contributor
0 Likes
2,916

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.

Read only

walkerist79
Participant
0 Likes
2,916

ryan.crosby2 Like this? Is it still sending one send request instead of multiple

Read only

Ryan-Crosby
Active Contributor
0 Likes
2,916

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.

Read only

walkerist79
Participant
0 Likes
2,916

ryan.crosby2 I'm sorry I didn't catch it

Read only

Sandra_Rossi
Active Contributor
2,916

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.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,916

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)

Read only

0 Likes
2,916
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.
Read only

0 Likes
2,916

What do you expect from your code, just debug it once

  • What should you do for user-id of s_inbox (add their internal sap mail to recipient list?)
  • What shoudl you do for user-id of s_email (add their external mail to recipient list?)

Do you intend to use CL_BCS or obsolete FM, seems you are lost in the middle of a conversion?

Suggestion:

  • Move the add_recipient in the corresponding loops
  • Dont use lo_sender as the variable name for a recipient
Read only

walkerist79
Participant
0 Likes
2,916

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.
Read only

Sandra_Rossi
Active Contributor
0 Likes
2,916

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.