SAP Document Compliance Germany eInvoice (E-Mail): How to change E-Mail during test phase
You are implementing SAP Document Compliance (eDocument) Germany eInvoice (E-Mail). You want to test if you can send an E-Mail with eInvoice attached and you want to see if the E-Mail arrives in your inbox successfully.
SAP Document Compliance (eDocument) Germany eInvoice (E-Mail) is also known as ZUGFeRD in German. The process starts with creating billing document or accounting document in SAP ERP or SAP S/4HANA. The eDocument is then being created automatically and can be displayed in eDocument Cockpit. You need to validate your eDocument on the Peppol Exchange service of SAP Document Compliance, cloud edition. At the same time, you have a custom development in place to upload files to eDocuments by calling UPLOAD_FILE_TO_EDOC method of CL_EDOC_API_FILE class. Please check EDOC_UPLOAD_FILE_EXAMPLE example report if you are looking for an example. A PDF/A-3 file is then generated with an embedded XML file and sent to a customer via E-Mail.
During the test phase, you would like to send the PDF/A-3 file to your own E-Mail instead of a real customer E-Mail. You implement CHANGE_EMAIL_TO_CUSTOMER method of EDOC_PARTNER_CONNECTOR BAdI.
In the attachment of SAP Note 2854966 – eDocument EU eInvoice (E-Mail): AIF Setup and BAdI Implementations, you have followed the step 9 BAdI EDOC_PARTNER_CONNECTOR.
Below is an example implementation.
METHOD if_edoc_partner_connector~change_email_to_customer. DATA: lv_email_adr_recipients_to LIKE LINE OF ct_emailadr_recipients_to, ls_address TYPE bapiaddr3, lt_bapiret TYPE TABLE OF bapiret2. MESSAGE 'CUST_IMPL: E-mail addresses (from, to) will change to your e-mail address' TYPE 'I'. CALL FUNCTION 'BAPI_USER_GET_DETAIL' EXPORTING username = sy-uname IMPORTING address = ls_address TABLES return = lt_bapiret. IF lt_bapiret IS INITIAL. cv_emailadr_sender = ls_address-e_mail. REFRESH ct_emailadr_recipients_to. lv_email_adr_recipients_to = ls_address-e_mail. APPEND lv_email_adr_recipients_to TO ct_emailadr_recipients_to. ENDIF. ENDMETHOD.
With above implementation, you can replace the E-Mail address of a customer with the E-Mail of the current system user. I believe that the tip mentioned in this blog will improve your experience when testing SAP Document Compliance (eDocument) Germany eInvoice (E-Mail).
For further context including on the standard solution offered by SAP, see the blog series All you wanted to know about the electronic invoice in Germany (also in German). For more information on SAP Document Compliance go to the related Community page. For detail on Peppol testing, see Peppol – Attention points for testing.