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: 

Email Func:BCS Classes-Customizing the sender and receiver

Former Member
0 Kudos

Hi All,

In my functionality previously, I used FM 'SO_DOCUMENT_SEND_API1' wherein I can freely customized the sender and recipient. But I need to change it to BCS class due to 50 character limitation in Subject.

Please see thread .


DATA: recipient          TYPE REF TO if_recipient_bcs.

*SENDER*
"Set Sender
      sender = cl_sapuser_bcs=>create( sy-uname ).
      CALL METHOD send_request->set_sender
        EXPORTING
          i_sender = sender.

The code above would always trigger the email of the owner of SY-UNAME. In my case, I need a custom one email, let's say, a hard coded non SY-UNAME email.

What I did:

Change the data definition of sender as follow, but this would give me not compatible type parameter.


DATA: sender             TYPE REF TO if_sender_bcs.

"sender = cl_sapuser_bcs=>create( '<sender_email_literal_goes_here>' ).

Question: Is this possible? or the class is fixed to SY-UNAME's email?

1 ACCEPTED SOLUTION

kesavadas_thekkillath
Active Contributor
0 Kudos

Hi ,

FYI,

you can also check in se38 for BCS*

11 REPLIES 11

Former Member
0 Kudos

Hi All, again.. continuation..

RECIPIENT

Question: How can I change the single hard code recipient email pulling the data from an Internal Table?


DATA: recipient          TYPE REF TO if_recipient_bcs.

      recipient = cl_cam_address_bcs=>create_internet_address(
                                        '<recipient_email_literal_goes_here>' ).

*     add recipient with its respective attributes to send request
      CALL METHOD send_request->add_recipient
        EXPORTING
          i_recipient = recipient
          i_express   = 'X'.

Thanks All.

Former Member
0 Kudos

Just found the answer on sender-ID on thread

[CLASS cl_bcs Query for sender mail id|;

kesavadas_thekkillath
Active Contributor
0 Kudos

Hi ,

FYI,

you can also check in se38 for BCS*

0 Kudos

Hi Keeshav,

Yes I already checked BCS programs 1-6, but they all use only 1 Recipient Email. Thanks.

0 Kudos

Check this.

Here S_EMAIL is selection screen input with multiple email ids


        LOOP AT S_EMAIL.
          LV_RECEIVER =  S_EMAIL-LOW..
          LR_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( LV_RECEIVER ).

          CALL METHOD LR_CL_SEND_REQUEST->ADD_RECIPIENT
            EXPORTING
              I_RECIPIENT = LR_RECIPIENT
              I_EXPRESS   = 'X'.
        ENDLOOP.

0 Kudos

Hi ArS,


DATA: w_receiver TYPE string.

LOOP AT itab_email ASSINGNING <fs_email>.

      recipient = cl_cam_address_bcs=>create_internet_address( w_receiver ).

ENDLOOP.

I'm having an error: w_receiver is not type-compatible with formal parameter I_ADDRESS_STRING,

I also tried using


DATA: w_receiver(50) TYPE c.

but still have the same error.

0 Kudos

Try with


data: w_receiver        TYPE ad_smtpadr.

This will resolve the issue

0 Kudos

Hi ArS, it's working now as a program.

Still part of the thread.

Now I want to create a FM for this:

In my Function Group>TOP INCLUDE, I have


DATA:  sender           TYPE REF TO if_sender_bcs,
             w_sender     TYPE ad_smtpadr.

In my FM code:

IMPORT Parameter:

SENDER TYPE AD_SMTPADR


sender = cl_cam_address_bcs=>create_internet_address( w_sender ).

      CALL METHOD send_request->set_sender
        EXPORTING
          i_sender = sender.

SYNTAX ERROR: The field "SENDER" cannot be changed.

0 Kudos

Ars has been very patient with you, even though your questions are getting more and more basic. Hope he gets the credit he deserves.

By the way: When using sender as IMPORT parameter, you can not change it. Use the changing parameter instead or exporting when you are not already importing and existing sender (which would not be logical in your case).

0 Kudos

Thank ArS, problem solved.

0 Kudos

Thanks Mickey, problem solved.