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: 

Send email at future date and time

Former Member
0 Kudos

Is it possible and how to send email with future send date and time using object class CL_BCS. I was able to email using OO but it send immediately.

Now, I need to send email with PDF attachment to a customer at future date and time and there is FM SO_OBJECT_SEND where you can set the send attribute in table RECEIVERS field RCDAT and RCTIM but I don't know all about the parameter in this FM to attach PDF format file. Does anyone have a sample? Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You can send the email in the future using the OO methods as well. Just not well documented but if you dig into the class itself, you'll find that CL_BCS has a public attribute called SEND_REQUEST which is of type CL_SEND_REQUEST_BCS. This class has a method to set the send time.

Example below, I'll set it 6 minutes from now.


data: lv_timestamp type timestamp.

GET TIME STAMP FIELD lv_timestamp.

lv_timestamp = CL_ABAP_TSTMP=>ADD( tstmp = lv_timestamp  secs = 360 ).

lr_cl_bcs->SEND_REQUEST->set_send_at( lv_timestamp ).

lr_cl_bcs->send( space ).

5 REPLIES 5

Former Member
0 Kudos

Run this program in background and specify your futute date and time.

I used the following FM before to create pdf and attachment to send an email. Try using this FMs

  • to create pdf from spool

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

  • send mail with attachment

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

Former Member
0 Kudos

You can send the email in the future using the OO methods as well. Just not well documented but if you dig into the class itself, you'll find that CL_BCS has a public attribute called SEND_REQUEST which is of type CL_SEND_REQUEST_BCS. This class has a method to set the send time.

Example below, I'll set it 6 minutes from now.


data: lv_timestamp type timestamp.

GET TIME STAMP FIELD lv_timestamp.

lv_timestamp = CL_ABAP_TSTMP=>ADD( tstmp = lv_timestamp  secs = 360 ).

lr_cl_bcs->SEND_REQUEST->set_send_at( lv_timestamp ).

lr_cl_bcs->send( space ).

0 Kudos

Hi Daniel,

Thanks. It works perfectly. You save my day, I've been looking for this for quite some time. Thanks.

Hi PV,

Thanks for the quick answer I use that function

'SO_NEW_DOCUMENT_ATT_SEND_API1' but it is easier to use OO.

aki

0 Kudos

Is it possible to do this in non-OO using the FMs you have mentioned?

0 Kudos

You can use FM 'SO_OBJECT_SEND' and set the attributes receivers-rcdat for sending future date and receivers-rctim for future time.

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

  • FOLDER_ID = ' '

  • FORWARDER = ' '

  • OBJECT_FL_CHANGE = ' '

object_hd_change = object_hd

  • OBJECT_ID = ' '

object_type = 'RAW'

outbox_flag = 'X'

owner = sy-uname

  • STORE_FLAG = ' '

  • DELETE_FLAG = ' '

sender = sy-uname

  • CHECK_SEND_AUTHORITY = ' '

  • CHECK_ALREADY_SENT = ' '

  • GIVE_OBJECT_BACK =

  • ORIGINATOR = ' '

  • ORIGINATOR_TYPE = 'J'

  • LINK_FOLDER_ID = ' '

  • SEND_REQUEST_OID = ' '

IMPORTING

object_id_new = oid

sent_to_all = to_all

  • ALL_BINDING_DONE =

office_object_key = okey

  • ORIGINATOR_ID =

  • E_SEND_REQUEST_OID =

TABLES

objcont = objcont

  • OBJHEAD =

  • OBJPARA =

  • OBJPARB =

receivers = receivers

  • PACKING_LIST =

  • ATT_CONT =

  • ATT_HEAD =

  • NOTE_TEXT =

  • LINK_LIST =

  • APPLICATION_OBJECT =

EXCEPTIONS

active_user_not_exist = 1

communication_failure = 2

component_not_available = 3

folder_not_exist = 4

folder_no_authorization = 5

forwarder_not_exist = 6

note_not_exist = 7

object_not_exist = 8

object_not_sent = 9

object_no_authorization = 10

object_type_not_exist = 11

operation_no_authorization = 12

owner_not_exist = 13

parameter_error = 14

substitute_not_active = 15

substitute_not_defined = 16

system_failure = 17

too_much_receivers = 18

user_not_exist = 19

originator_not_exist = 20

x_error = 21

OTHERS = 22

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.