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: 

CL_SAPUSER_BCS=>CREATE

Former Member
0 Kudos

Hi all,

Existing customize program is using Class CL_BCS to perform email sending. And im using method SET_SENDER to set the mail sender id. Then existing prog is using CL_SAPUSER_BCS=>CREATE to get the sender id and convert to First name and last name and eventually display as sender.

Im using CL_SAPUSER_BCS=>CREATE and prob facing now is, the method is just accept SAP user id but not others. But for my case, the sender might not necessary a SAP user id.

So could u guys please comment if there other way to set the sender id like internet mail address(yahoo id) instead of a valid SAP user id?

Please comment.

1 ACCEPTED SOLUTION

former_member194669
Active Contributor
0 Kudos

Create a sap dummy id use for it. system will collect the sender mailid from SU3

10 REPLIES 10

former_member194669
Active Contributor
0 Kudos

It will work sy-uname (or sapuser id) only. But my question is your are sending mail from sap and set the sender user id other than sap ?


call method send_request->set_document( document ).
sender = cl_sapuser_bcs=>create( sy-uname ).

call method send_request->set_sender
exporting
i_sender = sender.

0 Kudos

Hi a®s, appreaciate your prompt reply.

Yes you are right, im sending a mail from SAP but the sender id is not a SAP ID.

former_member194669
Active Contributor
0 Kudos

Otherwise


call method send_request->set_document( document ).
sender = cl_sapuser_bcs=>create( 'ZTESTER' ). " And ZTESTER userid in SU3 maintain Yahoo email id 

call method send_request->set_sender
exporting
i_sender = sender.

0 Kudos

Hi a®s, thanks again for your advice.

But for my case i can't to have a SAP id due to business requirement. This is my scenario:

1. PO info is sending by third party

2. Once info send to SAP, then PO creation will take place.

3. Immediately PO will be created and then mail will send out. FYI, PO creator is the third-party id where it doesn't appear in SAP.

Please comment.

former_member194669
Active Contributor
0 Kudos

Create a sap dummy id use for it. system will collect the sender mailid from SU3

former_member194669
Active Contributor
0 Kudos

try this way


  data: v_sender TYPE ad_smtpadr.
  v_sender = 'abc.yahoo.com'.
  sender = cl_cam_address_bcs=>create_internet_address( v_sender ).
 

0 Kudos

Hi a®s, again thanks for your help.

BTW, im wondering why should i add the code that u mentioned? in the std class?

Please comment.

0 Kudos

Hi a®s,

I got you now and i have my problem solved. thanks.

0 Kudos

Hi,

Can u plz give idea about the solution i am also struck with the same problem.

I am using the following code then also it is not sending mails.

data: V_SENDER type AD_SMTPADR.

V_SENDER = 'abc.yahoo.com'.

data: SENDER type ref to CL_CAM_ADDRESS_BCS.

SENDER = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( V_SENDER ).

call method WA_SENDREQ->SET_SENDER

exporting

I_SENDER = SENDER.

Thanks

Anil D

Former Member
0 Kudos

Please use following solution for your purpose.


DATA:
   gv_sent_to_all   TYPE os_boolean,
   gr_send_request  TYPE REF TO cl_bcs,
   gr_bcs_exception TYPE REF TO cx_bcs,
   gr_recipient     TYPE REF TO if_recipient_bcs,
   gr_sender        TYPE REF TO if_sender_bcs,
   ls_sender        TYPE   ad_smtpadr VALUE 'sender@email.de',
   ls_recipient     TYPE   ad_smtpadr VALUE 'receiver@email.de'.

TRY.

     "Create send request
     gr_send_request = cl_bcs=>create_persistent( ).

     gr_sender = cl_cam_address_bcs=>create_internet_address(
               i_address_string = ls_sender
           ).

     "Add sender to send request
     CALL METHOD gr_send_request->set_sender
       EXPORTING
         i_sender = gr_sender.


     gr_recipient = cl_cam_address_bcs=>create_internet_address(
       i_address_string = ls_recipient ).
     "Add recipient to send request
     CALL METHOD gr_send_request->add_recipient
       EXPORTING
         i_recipient = gr_recipient
         i_express   = 'X'.

     "Send email
     CALL METHOD gr_send_request->send(
       EXPORTING
         i_with_error_screen = 'X'
       RECEIVING
         result              = gv_sent_to_all ).

     "Commit to send email
     COMMIT WORK.

     "Exception handling
   CATCH cx_bcs INTO gr_bcs_exception.
ENDTRY.