07-31-2008 6:15 AM
Hi all,
I need to Send a mail to the Purchase reuisition Creator if the Purchaser order is Released
IF the field VSTAT in the table NAST is "1" then we can say that the PO is released.
How can we do this.
Please suggest me if any Userexit or BADI exists for this requirement or haw can we achieve this
Regards
Ajay
07-31-2008 6:26 AM
Hi,
For using SAP we can send the mail to the correspodning user...
Iam sending code for that..
If u need any further information plz let me know.
lwa_docu_data-obj_name = 'TEXT'.
lwa_docu_data-obj_descr = 'TEXT'.
lt_attach1-line = 'See the attachment'.
APPEND lt_attach1.
CLEAR lt_attach1.
lt_attach1-line = 'S-> Success'.
APPEND lt_attach1.
CLEAR lt_attach1.
lt_attach1-line = 'E-> Error'.
APPEND lt_attach1.
DESCRIBE TABLE lt_attach1 LINES lv_lines.
READ TABLE lt_attach INDEX lv_lines.
lwa_docu_data-doc_size = ( lv_lines - 1 ) * 255 + STRLEN( lt_attach1 ).
lt_obj_header-head_start = 1.
lt_obj_header-head_num = 0.
lt_obj_header-body_start = 1.
lt_obj_header-body_num = lv_lines.
lt_obj_header-doc_type = 'RAW'.
APPEND lt_obj_header.
CLEAR lt_obj_header.
LOOP AT gt_mail INTO gs_mail.
CONCATENATE gs_mail-no_rec
gs_mail-no_sap
gs_mail-no_suc
gs_mail-no_err
gs_mail-status
gs_mail-regid
gs_mail-bpnum
gs_mail-desc INTO lt_attach SEPARATED BY con_tab.
CONCATENATE con_cret lt_attach INTO lt_attach.
APPEND lt_attach.
CLEAR: gs_mail, lt_attach.
ENDLOOP.
GET PARAMETER ID 'ZMAIL' FIELD gv_code.
SELECT zzmailid
FROM zweb_codes
INTO TABLE lt_mail
WHERE zzcode EQ gv_code.
LOOP AT lt_mail INTO lwa_mail.
lv_mail = lwa_mail-mailid.
lt_rec_list-receiver = lv_mail.
lt_rec_list-rec_type = 'U'.
APPEND lt_rec_list.
clear: lwa_mail, lv_mail.
ENDLOOP.
DESCRIBE TABLE lt_attach LINES lv_lines.
Object Attachment detail
lt_obj_header-transf_bin = 'X'.
lt_obj_header-head_start = 1.
lt_obj_header-head_num = 1.
lt_obj_header-body_start = 1.
lt_obj_header-body_num = lv_lines.
DESCRIBE TABLE lt_attach LINES lt_obj_header-body_num.
lt_obj_header-obj_name = 'TEXT'.
lt_obj_header-doc_type = 'XLS'.
lt_obj_header-obj_descr = 'TEXT'.
lt_obj_header-doc_size = lt_obj_header-body_num * 255.
APPEND lt_obj_header.
CLEAR lt_obj_header.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_docu_data
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = lt_obj_header
contents_bin = lt_attach
contents_txt = lt_attach1
receivers = lt_rec_list
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.
.
07-31-2008 6:23 AM
07-31-2008 6:26 AM
Hi,
For using SAP we can send the mail to the correspodning user...
Iam sending code for that..
If u need any further information plz let me know.
lwa_docu_data-obj_name = 'TEXT'.
lwa_docu_data-obj_descr = 'TEXT'.
lt_attach1-line = 'See the attachment'.
APPEND lt_attach1.
CLEAR lt_attach1.
lt_attach1-line = 'S-> Success'.
APPEND lt_attach1.
CLEAR lt_attach1.
lt_attach1-line = 'E-> Error'.
APPEND lt_attach1.
DESCRIBE TABLE lt_attach1 LINES lv_lines.
READ TABLE lt_attach INDEX lv_lines.
lwa_docu_data-doc_size = ( lv_lines - 1 ) * 255 + STRLEN( lt_attach1 ).
lt_obj_header-head_start = 1.
lt_obj_header-head_num = 0.
lt_obj_header-body_start = 1.
lt_obj_header-body_num = lv_lines.
lt_obj_header-doc_type = 'RAW'.
APPEND lt_obj_header.
CLEAR lt_obj_header.
LOOP AT gt_mail INTO gs_mail.
CONCATENATE gs_mail-no_rec
gs_mail-no_sap
gs_mail-no_suc
gs_mail-no_err
gs_mail-status
gs_mail-regid
gs_mail-bpnum
gs_mail-desc INTO lt_attach SEPARATED BY con_tab.
CONCATENATE con_cret lt_attach INTO lt_attach.
APPEND lt_attach.
CLEAR: gs_mail, lt_attach.
ENDLOOP.
GET PARAMETER ID 'ZMAIL' FIELD gv_code.
SELECT zzmailid
FROM zweb_codes
INTO TABLE lt_mail
WHERE zzcode EQ gv_code.
LOOP AT lt_mail INTO lwa_mail.
lv_mail = lwa_mail-mailid.
lt_rec_list-receiver = lv_mail.
lt_rec_list-rec_type = 'U'.
APPEND lt_rec_list.
clear: lwa_mail, lv_mail.
ENDLOOP.
DESCRIBE TABLE lt_attach LINES lv_lines.
Object Attachment detail
lt_obj_header-transf_bin = 'X'.
lt_obj_header-head_start = 1.
lt_obj_header-head_num = 1.
lt_obj_header-body_start = 1.
lt_obj_header-body_num = lv_lines.
DESCRIBE TABLE lt_attach LINES lt_obj_header-body_num.
lt_obj_header-obj_name = 'TEXT'.
lt_obj_header-doc_type = 'XLS'.
lt_obj_header-obj_descr = 'TEXT'.
lt_obj_header-doc_size = lt_obj_header-body_num * 255.
APPEND lt_obj_header.
CLEAR lt_obj_header.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_docu_data
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = lt_obj_header
contents_bin = lt_attach
contents_txt = lt_attach1
receivers = lt_rec_list
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.
.
07-31-2008 6:27 AM
Plz tell whether you want internal mail or external of SAp
rgds
rajesh
07-31-2008 6:50 AM
07-31-2008 7:15 AM
then you should go for workflow... which will send mail to SAP Internal mail box.. as work item