2008 Jun 25 10:35 AM
Hi all,
IF the Difference between the Purchase requisition date and system date is 10days then i need to send a mail automatically to the mail ID of the Purchase requisition(PR) creator (EBAN-ERNAM) with the details of the Purchase requisition number , Purchase requisition item number and also with thes ome message like (ex:-Your PR will be deleted in the next two days)
I have to do a Report only not a work flow
This Program is an Batch program and will be scheduled every day Morning
Please suggest me how to solve this and if possible please give me the Sample program
Thansk & Regards
Ajay
2008 Jun 25 10:36 AM
FORM sub_send_mail USING p_string1 TYPE string
p_string2 TYPE string
p_string3 TYPE string.
DATA : l_i_objtxt TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0,
"Contents
l_wa_objtxt TYPE solisti1,
l_wa_doc_chng type sodocchgi1 , "Attributes of Mail
l_i_objpack TYPE STANDARD TABLE OF sopcklsti1 INITIAL SIZE 0,
"Packing list
l_wa_objpack TYPE sopcklsti1,
l_i_reclist TYPE STANDARD TABLE OF somlreci1 INITIAL SIZE 0,
"Receivers list
l_wa_reclist TYPE somlreci1 ,
l_tab_lines LIKE sy-tabix. "No. of lines
CONCATENATE p_string1 p_string2
INTO l_wa_doc_chng-obj_descr SEPARATED BY space.
IF p_string3 IS NOT INITIAL.
CONCATENATE l_wa_doc_chng-obj_descr p_string3
INTO l_wa_doc_chng-obj_descr SEPARATED BY space.
ENDIF.
l_wa_objtxt-line = l_wa_doc_chng-obj_descr.
APPEND l_wa_objtxt TO l_i_objtxt.
CLEAR l_wa_objtxt .
l_tab_lines = LINES( l_i_objtxt ) .
READ TABLE l_i_objtxt INTO l_wa_objtxt INDEX l_tab_lines.
IF sy-subrc = 0.
l_wa_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 +
STRLEN( l_wa_objtxt ).
ENDIF.
Creating the entry for the compressed document
CLEAR l_wa_objpack-transf_bin.
l_wa_objpack-head_start = 1.
l_wa_objpack-head_num = 0.
l_wa_objpack-body_start = 1.
l_wa_objpack-body_num = l_tab_lines.
l_wa_objpack-doc_type = 'RAW'.
APPEND l_wa_objpack TO l_i_objpack.
CLEAR l_wa_objpack .
CALL FUNCTION 'EFG_GEN_GET_USER_EMAIL'
EXPORTING
i_uname = sy-uname
IMPORTING
E_EMAIL_ADDRESS = l_wa_reclist-receiver.
l_wa_reclist-rec_type = 'U'.
APPEND l_wa_reclist TO l_i_reclist.
CLEAR l_wa_reclist .
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = l_wa_doc_chng
put_in_outbox = c_check
commit_work = c_check
TABLES
packing_list = l_i_objpack
contents_txt = l_i_objtxt
receivers = l_i_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc <> 0 .
write: 'Notification not send'.
ENDIF.
Reward point if helpful
2008 Jun 25 10:36 AM
FORM sub_send_mail USING p_string1 TYPE string
p_string2 TYPE string
p_string3 TYPE string.
DATA : l_i_objtxt TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0,
"Contents
l_wa_objtxt TYPE solisti1,
l_wa_doc_chng type sodocchgi1 , "Attributes of Mail
l_i_objpack TYPE STANDARD TABLE OF sopcklsti1 INITIAL SIZE 0,
"Packing list
l_wa_objpack TYPE sopcklsti1,
l_i_reclist TYPE STANDARD TABLE OF somlreci1 INITIAL SIZE 0,
"Receivers list
l_wa_reclist TYPE somlreci1 ,
l_tab_lines LIKE sy-tabix. "No. of lines
CONCATENATE p_string1 p_string2
INTO l_wa_doc_chng-obj_descr SEPARATED BY space.
IF p_string3 IS NOT INITIAL.
CONCATENATE l_wa_doc_chng-obj_descr p_string3
INTO l_wa_doc_chng-obj_descr SEPARATED BY space.
ENDIF.
l_wa_objtxt-line = l_wa_doc_chng-obj_descr.
APPEND l_wa_objtxt TO l_i_objtxt.
CLEAR l_wa_objtxt .
l_tab_lines = LINES( l_i_objtxt ) .
READ TABLE l_i_objtxt INTO l_wa_objtxt INDEX l_tab_lines.
IF sy-subrc = 0.
l_wa_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 +
STRLEN( l_wa_objtxt ).
ENDIF.
Creating the entry for the compressed document
CLEAR l_wa_objpack-transf_bin.
l_wa_objpack-head_start = 1.
l_wa_objpack-head_num = 0.
l_wa_objpack-body_start = 1.
l_wa_objpack-body_num = l_tab_lines.
l_wa_objpack-doc_type = 'RAW'.
APPEND l_wa_objpack TO l_i_objpack.
CLEAR l_wa_objpack .
CALL FUNCTION 'EFG_GEN_GET_USER_EMAIL'
EXPORTING
i_uname = sy-uname
IMPORTING
E_EMAIL_ADDRESS = l_wa_reclist-receiver.
l_wa_reclist-rec_type = 'U'.
APPEND l_wa_reclist TO l_i_reclist.
CLEAR l_wa_reclist .
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = l_wa_doc_chng
put_in_outbox = c_check
commit_work = c_check
TABLES
packing_list = l_i_objpack
contents_txt = l_i_objtxt
receivers = l_i_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc <> 0 .
write: 'Notification not send'.
ENDIF.
Reward point if helpful