01-29-2008 1:29 PM
would like to check with you all, currently I am reading a text file from interface manager and 'put' it into IDOC- basic type ORDERS05 and later auto create the Sales Order.
After that, I need to generate an text file regarding the status of the IDOC plus some other information from the new created Sales Order.
This text file need to send to the specify user thru external email like Lotus Notes.
Does anybody know which function module I can use ?
Thanks & Regards,
Chakri.
01-30-2008 7:22 AM
Hi,
Source : Google
Check this if useful.
*To prepare the subject line
CONCATENATE text-034 v_belnr text-035 INTO v_subject SEPARATED BY space.
CLEAR v_belnr.
*Add the recipients email address
CLEAR wa_receivers.
REFRESH t_receivers.
wa_receivers-receiver
= v_usrid.
wa_receivers-rec_type
= c_u.
wa_receivers-com_type
= c_int.
wa_receivers-notif_del = c_x.
wa_receivers-notif_ndel = c_x.
APPEND wa_receivers TO t_receivers.
CLEAR wa_receivers.
Describe the body of the message
CLEAR wa_packing_list.
REFRESH t_packing_list.
wa_packing_list-transf_bin = space.
wa_packing_list-head_start = c_1.
wa_packing_list-head_num
= c_0.
wa_packing_list-body_start = c_1.
DESCRIBE TABLE t_message LINES wa_packing_list-body_num.
wa_packing_list-doc_type
= c_raw.
APPEND wa_packing_list TO t_packing_list.
CLEAR wa_packing_list.
*Populate the subject/generic message attributes
wa_doc_data-obj_langu
= sy-langu.
wa_doc_data-obj_name
= c_saprpt.
wa_doc_data-obj_descr
= v_subject.
wa_doc_data-sensitivty = c_f.
CLEAR : v_subject,
v_belnr.
*Call the FM to post the message to SAPMAIL
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data
= wa_doc_data
put_in_outbox
= c_x
IMPORTING
sent_to_all
= v_sent_all
TABLES
packing_list
= t_packing_list
contents_txt
= t_message
receivers
= t_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.
*commit work.
*Status of the IDOC. need to be updated.
IF sy-subrc IS INITIAL.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = c_status68.
APPEND idoc_status.
CLEAR idoc_status.
ELSE. "If the mail was not sent.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = c_status63.
idoc_status-msgid = c_msgid.
idoc_status-msgno = c_mailfail.
APPEND idoc_status.
CLEAR idoc_status.
ENDIF.
ELSE. "If user-id(email-id) was not found
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = c_status63.
idoc_status-msgid = c_msgid.
idoc_status-msgno = c_mailnotfound.
APPEND idoc_status.
CLEAR idoc_status.
ENDIF.
Regards..
01-30-2008 7:22 AM
Hi,
Source : Google
Check this if useful.
*To prepare the subject line
CONCATENATE text-034 v_belnr text-035 INTO v_subject SEPARATED BY space.
CLEAR v_belnr.
*Add the recipients email address
CLEAR wa_receivers.
REFRESH t_receivers.
wa_receivers-receiver
= v_usrid.
wa_receivers-rec_type
= c_u.
wa_receivers-com_type
= c_int.
wa_receivers-notif_del = c_x.
wa_receivers-notif_ndel = c_x.
APPEND wa_receivers TO t_receivers.
CLEAR wa_receivers.
Describe the body of the message
CLEAR wa_packing_list.
REFRESH t_packing_list.
wa_packing_list-transf_bin = space.
wa_packing_list-head_start = c_1.
wa_packing_list-head_num
= c_0.
wa_packing_list-body_start = c_1.
DESCRIBE TABLE t_message LINES wa_packing_list-body_num.
wa_packing_list-doc_type
= c_raw.
APPEND wa_packing_list TO t_packing_list.
CLEAR wa_packing_list.
*Populate the subject/generic message attributes
wa_doc_data-obj_langu
= sy-langu.
wa_doc_data-obj_name
= c_saprpt.
wa_doc_data-obj_descr
= v_subject.
wa_doc_data-sensitivty = c_f.
CLEAR : v_subject,
v_belnr.
*Call the FM to post the message to SAPMAIL
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data
= wa_doc_data
put_in_outbox
= c_x
IMPORTING
sent_to_all
= v_sent_all
TABLES
packing_list
= t_packing_list
contents_txt
= t_message
receivers
= t_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.
*commit work.
*Status of the IDOC. need to be updated.
IF sy-subrc IS INITIAL.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = c_status68.
APPEND idoc_status.
CLEAR idoc_status.
ELSE. "If the mail was not sent.
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = c_status63.
idoc_status-msgid = c_msgid.
idoc_status-msgno = c_mailfail.
APPEND idoc_status.
CLEAR idoc_status.
ENDIF.
ELSE. "If user-id(email-id) was not found
idoc_status-docnum = idoc_contrl-docnum.
idoc_status-status = c_status63.
idoc_status-msgid = c_msgid.
idoc_status-msgno = c_mailnotfound.
APPEND idoc_status.
CLEAR idoc_status.
ENDIF.
Regards..