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

Message to users

Former Member
0 Likes
730

Hi guys. I have a list of devices that have installation dates. Using the current date, I would like to send a message (somehow) to a list of certain users that certain devices have been installed for five years or more.

Is the best way to do a daily or weekly check on the table and compare the installation dates with the current date? If so, how would I send the message with a list of the devices to selected users. Mind you, some or all of the users may not be logged on but they need to see the message.

Thanks

Rapula

6 REPLIES 6
Read only

Former Member
0 Likes
694

As per my understanding of your requirement...I think weekly would be a better idea !!

calculate the list date = current date - 5 years.

you can select the list of devices from the table with

using the list date.

depending on the category of device you can get the userlist from another table.

call the fm to send out an email with device list as attachement.

Regards

Anurag

Read only

0 Likes
694

Thanks Anurag

This looks very helpful but looses me when you say 'call the fm to send out an email'. What is the fm and houw do I do that?

Rapula

Read only

0 Likes
694

Do you mean the fm MESSAGE_SEND_AS_MAIL?

Read only

0 Likes
694

FM name : SO_NEW_DOCUMENT_SEND_API1

Read only

0 Likes
694

As an example you can fill these details

OBJECT_CONTENT-LINE with 'Test Mail'

RECEIVERS-RECEIVER with your sap login id

RECEIVERS-REC_TYPE with 'B'.

And execute the FM.

Then check your Business workplace inbox. (T.Code SBWP)

P.S. Dont forget to reward points, if this is helpful

Message was edited by: Anish Thomas

Read only

0 Likes
694

Hello Rapula,

I have attached the sample code for the email piece here the one being is used to send the data as an attachment but the one in comments is for sending the same as body text. Also, it would be nice if you reward all useful answers ...cheers..let us know if you need further information.

Sample code -


form SEND_EMAIL tables IT_MESSAGE type T_MESSAGE.

data: IS_DOCDATA type SODOCCHGI1,

IS_RECEIVERS type SOMLRECI1,

IS_RECEIVERS_COPY type SOMLRECI1,

IT_RECEIVERS type table of SOMLRECI1,

IS_CONTENT type SOLISTI1,

IT_CONTENT type table of SOLISTI1,

*500369789+

l_txt(255) type c,

lt_objpack TYPE TABLE OF sopcklsti1 WITH HEADER LINE,

lt_objhead TYPE TABLE OF solisti1 WITH HEADER LINE,

lt_objtxt TYPE TABLE OF solisti1 WITH HEADER LINE,

l_tab_lines TYPE i,

l_att_type LIKE soodk-objtp.

*500369789+

IS_DOCDATA-OBJ_NAME = 'MAIL'.

IS_DOCDATA-PRIORITY = 5.

IS_DOCDATA-OBJ_LANGU = SY-LANGU.

IS_DOCDATA-NO_CHANGE = 'X'.

IS_DOCDATA-OBJ_DESCR = SY-CPROG.

loop at IT_MESSAGE into IS_MESSAGE.

clear : IS_CONTENT, l_txt. "500369789+

move is_message-line to l_txt. "500369789+

  • move IS_MESSAGE-LINE to IS_CONTENT-LINE. "500369789-

move l_txt to IS_CONTENT-LINE. "500369789+

append IS_CONTENT to IT_CONTENT.

endloop.

*---select_email_address

select single

EMAILADDR

CCEMAILADDR

into (IS_RECEIVERS-RECEIVER, IS_RECEIVERS_COPY-RECEIVER)

from ZGL_EMAILCTRL

where IDENT = ''

and ZPROGRAM = 'Z_L_SO_CREA'

and ACTIVE = 'X'.

if IS_RECEIVERS-RECEIVER is not initial.

IS_RECEIVERS-REC_TYPE = 'U'.

IS_RECEIVERS_COPY-REC_TYPE = 'U'.

IS_RECEIVERS_COPY-COPY = 'X'.

append IS_RECEIVERS to IT_RECEIVERS.

append IS_RECEIVERS_COPY to IT_RECEIVERS.

*500369789+

lt_objhead-line = 'USA Order Report'.

append lt_objhead.

DESCRIBE TABLE lt_objhead LINES l_tab_lines.

CLEAR lt_objpack-transf_bin.

lt_objpack-doc_size = STRLEN( lt_objhead ).

lt_objpack-head_start = 1.

lt_objpack-head_num = 1.

lt_objpack-body_start = 1.

lt_objpack-body_num = 1.

lt_objpack-doc_type = 'RAW'.

APPEND lt_objpack.

l_att_type = 'RAW'.

DESCRIBE TABLE it_content LINES l_tab_lines.

READ TABLE it_content into is_content INDEX l_tab_lines.

lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255.

lt_objpack-doc_size = lt_objpack-doc_size + STRLEN( is_content ).

lt_objpack-transf_bin = 'X'.

lt_objpack-head_start = 1.

lt_objpack-head_num = 2.

lt_objpack-body_start = 1.

lt_objpack-body_num = l_tab_lines.

lt_objpack-doc_type = l_att_type.

lt_objpack-obj_name = 'ATTACHMENT'.

concatenate 'Usa' SY-DATUM+6(2) SY-DATUM+4(2) into

lt_objpack-obj_descr. "#EC *

APPEND lt_objpack.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = IS_DOCDATA

commit_work = 'X'

TABLES

packing_list = lt_objpack

  • object_header = lt_objhead

contents_txt = lt_objhead

contents_bin = it_content

receivers = it_receivers

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

*500369789+

*500369789-

  • SEND EMAIL FOR PLANTS

  • call function 'SO_NEW_DOCUMENT_SEND_API1'

  • exporting

  • DOCUMENT_TYPE = 'RAW'

  • DOCUMENT_DATA = IS_DOCDATA

  • COMMIT_WORK = 'X'

  • tables

  • OBJECT_CONTENT = IT_CONTENT

  • RECEIVERS = IT_RECEIVERS

  • exceptions

  • TOO_MANY_RECEIVERS = 1

  • DOCUMENT_NOT_SENT = 2

  • OPERATION_NO_AUTHORIZATION = 4

  • others = 99.

*500369789-

if SY-SUBRC <> 0.

endif.

endif.

endform. "send_email