09-05-2009 9:08 AM
Hi to all
My requirement is :
As soon as the Delivery Schedule are created in me38, I have to send this delivery schedules through email to my vendor.
In Nace
Appliance type: EL.
OutPut type : LPET.
I can able see print preview through ME9E. But I need to send this document as mail to vendor. How I can do this, Please guide me.
For this any UseExits or Bapi available ..
Thanks & regards
venkatesh.M
10-27-2009 5:06 AM
10-27-2009 12:55 PM
Hi,
I can give u code how to send the mail .. I have done the same requirement for the BADI MB_CHECK_LINE_BADI. Please find the code ...
To send Mail
GETTING THE MAIL ID.
SORT it_usr21 BY bname.
SORT it_adr6 BY addrnumber persnumber.
LOOP AT it_ymm_br_bm_fs_id INTO is_ymm_br_bm_fs_id.
READ TABLE it_usr21 INTO is_usr21 WITH KEY bname = is_ymm_br_bm_fs_id-bname BINARY SEARCH.
IF sy-subrc = 0.
READ TABLE it_adr6 INTO is_adr6 WITH KEY addrnumber = is_usr21-addrnumber
persnumber = is_usr21-persnumber BINARY SEARCH.
IF sy-subrc = 0.
is_reclist-receiver = is_adr6-smtp_addr.
is_reclist-rec_type = 'U'.
APPEND is_reclist TO it_reclist.
CLEAR is_reclist.
ENDIF.
ENDIF.
ENDLOOP.
Create Message Body
Title and Description
is_doc_chng-obj_name = 'MAIL'.
is_doc_chng-obj_descr = 'Goods receipts pending for your Approval'.
main text
is_objtxt-line = 'This is an automatically generated mail. Please do not reply to it.'(028).
APPEND is_objtxt TO it_objtxt.
is_objtxt-line = space.
APPEND is_objtxt TO it_objtxt.
Attachment
is_objtxt-line = 'WSP'.
is_objtxt-line+8(18) = 'Material Code'.
is_objtxt-line+26(40) = 'Description'.
is_objtxt-line+67(10) = 'Batch'.
is_objtxt-line+78(19) = 'D.O.M'.
is_objtxt-line+100(30) = 'Days Since Mfg'.
APPEND is_objtxt TO it_objtxt.
CLEAR is_objtxt.
SORT it_makt BY matnr.
LOOP AT it_ymm_sl_gr_chk INTO is_ymm_sl_gr_chk.
w_vkbur = is_ymm_sl_gr_chk-kunnr.
is_objtxt-line = w_vkbur.
w_matnr = is_ymm_sl_gr_chk-matnr.
is_objtxt-line+8(18) = w_matnr.
READ TABLE it_makt INTO is_makt WITH KEY matnr = is_ymm_sl_gr_chk-matnr BINARY SEARCH.
IF sy-subrc = 0.
w_arktx = is_makt-maktx.
ENDIF.
is_objtxt-line+26(40) = w_arktx.
w_charg = is_ymm_sl_gr_chk-charg.
is_objtxt-line+67(10) = w_charg.
WRITE is_ymm_sl_gr_chk-hsdat TO w_hsdat USING EDIT MASK '__.__.____'.
is_objtxt-line+78(19) = w_hsdat.
w_maxlz = is_mkpf-budat - is_ymm_sl_gr_chk-hsdat.
is_objtxt-line+102(30) = w_maxlz.
APPEND is_objtxt TO it_objtxt.
ENDLOOP.
write packing list (main)
DESCRIBE TABLE it_objtxt LINES w_lines_tx.
READ TABLE it_objtxt INTO is_objtxt INDEX w_lines_tx.
is_doc_chng-doc_size = ( w_lines_tx - 1 ) * 255 + STRLEN( is_objtxt ).
CLEAR is_objpack-transf_bin.
is_objpack-head_start = 1.
is_objpack-head_num = 0.
is_objpack-body_start = 1.
is_objpack-body_num = w_lines_tx.
is_objpack-doc_type = c_raw.
APPEND is_objpack TO it_objpack.
SENDING THE MAILS TO VENDORS/PURCHASING GROUPS
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = is_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = it_objpack
contents_txt = it_objtxt
receivers = it_reclist
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.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
w_count = 1.
EXPORT w_count FROM w_count TO MEMORY ID 'W_COUNT'.
ENDIF.
ENDIF.
11-14-2010 11:17 AM
11-15-2015 7:08 AM
Hi Venketesh,
Can u please explain how you have achieved this.
Regards
Aman