Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Payment advice notes by email (change in sender id) and body

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.

Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question