on 09-20-2008 10:40 AM
Hi experts ,
I am trying to change the sender name and body of the mail that is send by mail.does this code work i called SO_NEW_DOCUMENT_ATT_SEND_API1 in Z_PAN_EMAIL_00002040.
look in the code and also tell me me does this work out. can some one tell me what is the 'SAPoffice' in this code. (ls_document_data-obj_name = 'SAPoffice'.) in fill document data part.
FUNCTION Z_PAN_EMAIL_00002040.
*"----
""Local interface:
*" IMPORTING
*" REFERENCE(I_REGUH) LIKE REGUH STRUCTURE REGUH
*" CHANGING
*" REFERENCE(C_FINAA) LIKE FINAA STRUCTURE FINAA
*"----
data: zadrnr like adr6-addrnumber,
zsmtp_addr like adr6-smtp_addr,
zremark like adrt-remark,
begin of zcon occurs 0,
zadrnr like adr6-addrnumber,
zconnumber like adr6-consnumber,
zsmtp_addr like adr6-smtp_addr,
end of zcon.
refresh zcon.
select single adrnr into zadrnr from lfa1 where
lifnr = i_reguh-lifnr.
if sy-subrc = 0.
select addrnumber consnumber smtp_addr into table zcon
from adr6 where addrnumber = zadrnr.
endif.
loop at zcon.
clear zremark.
select single REMARK INTO ZREMARK FROM ADRT
where addrnumber = zcon-zadrnr
and consnumber = zcon-zconnumber.
TRANSLATE zREMARK TO UPPER CASE.
if sy-subrc = 0 and zremark = 'REMIT'.
zsmtp_addr = zcon-zsmtp_addr.
exit.
endif.
endloop.
IF zsmtp_addr <> ' '.
search zsmtp_addr for 'britishcouncil' .
if sy-subrc <> 0.
code modified to check if sy-subrc = 0.
C_FINAA-NACHA = 'I'.
CODE MODIFIED AS PER SAP NOTE 1033893 .
C_FINAA-NAMEP = 'Testname'.
internet address of partner company clerk has been changed by pradeep akula as per requirements.
C_FINAA-INTAD = zsmtp_addr.
C_FINAA-FORNR = 'Z_F110_IN_AVIS2'.
this zzmail_sender_addrr and zzmail_body_text did not work in testing.
C_FINAA-ZZMAIL_BODY_TEXT = 'This is a test body text'.
C_FINAA-ZZMAIL_BODY_TEXT = 'Payment Advice Notes attached, please do not discard this message .All vendors should please add their company name'.
endif.
ENDIF.
code changes done by pradeep akula for Body of mail .
CLASS cl_abap_char_utilities DEFINITION LOAD.
TYPES: t_solisti1 TYPE TABLE OF solisti1,
t_sopcklsti1 TYPE TABLE OF sopcklsti1,
t_somlreci1 TYPE TABLE OF somlreci1.
DATA: lt_content TYPE t_solisti1,
lt_packing_list TYPE t_sopcklsti1,
lt_header TYPE t_solisti1,
ls_document_data TYPE sodocchgi1,
l_subject TYPE solisti1-line,
l_content_lines TYPE i,
lt_receiver TYPE t_somlreci1,
l_address TYPE adr6-smtp_addr,
l_new_object_id TYPE sofolenti1-object_id,
l_sent_to_all TYPE sy-binpt,
l_msg_text TYPE string,
l_rc TYPE sy-subrc,
l_user TYPE sy-uname.
DATA: l_crlf(2) TYPE c.
DATA: BEGIN OF crlf,
x(1) TYPE x VALUE '0D',
y(1) TYPE x VALUE '0A',
END OF crlf.
l_crlf = cl_abap_char_utilities=>cr_lf.
receiver address
DATA: ls_receiver TYPE somlreci1.
ls_receiver-receiver = zsmtp_addr.
receiver address type (internet address)
ls_receiver-rec_type = 'U'.
communication type (send via internet)
ls_receiver-com_type = 'INT'.
APPEND ls_receiver TO lt_receiver.
SAP name: used for the shortcut to the inbox (optional)
l_user = p_user.
l_user = ' '.
mail subject
l_subject = p_subj.
DATA: ls_content TYPE solisti1,
ls_header TYPE solisti1.
fill the document data.
READ TABLE lt_content INDEX l_content_lines INTO ls_content.
ls_document_data-doc_size =
( l_content_lines - 1 ) * 255 + STRLEN( ls_content ).
ls_document_data-obj_name = 'SAPoffice'.
ls_document_data-obj_descr = 'Test mail form payment advice its working'.
ls_document_data-obj_prio = 5.
ls_document_data-priority = 5.
fill data of mail
DATA: ls_packing_list TYPE sopcklsti1.
update the packing list.
ls_packing_list-transf_bin = ' '.
ls_packing_list-body_start = 1.
ls_packing_list-body_num = l_content_lines.
ls_packing_list-doc_type = 'RAW'.
APPEND ls_packing_list TO lt_packing_list.
ls_header-line = 'Test header - Vish'.
append ls_header to lt_header.
ls_content-line = 'Test mail form payment advice what you want to print here'.
append ls_content to lt_content.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_document_data
commit_work = 'X'
IMPORTING
sent_to_all = l_sent_to_all
new_object_id = l_new_object_id
TABLES
packing_list = lt_packing_list
object_header = lt_header
contents_txt = lt_content
receivers = lt_receiver
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.
keep error message
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
INTO l_msg_text.
ENDIF.
endfunction.
Just debug the below code carefully.
my guess sender address would be picked from current user id address.so you need to check by debug which variable is passed to FM with contains of sender address and text.
once you find these than just overwite thease variable before passing the FM with your own values like text and sender address.
Amit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check SAP Note: https://service.sap.com/sap/support/notes/1033893
There is a description how to set the sender mail adress with BTE 2040 and 2050.
Greetings
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Pradeep,
you can change the sender, when you change the system-field SY-UNAME before calling FM SO_NEW_DOCUMENT_ATT_SEND_API1.
REPORT Z_TEST_SEND_MAIL.
.
.
h_uname must be a SAP-UserId.
sy-uname = h_uname.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
.
.
I tried it and it was successfull.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
will try
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.