Processing of Digital Invoices Content
Processing of Digital Invoices Content
Processing of Digital Invoices Content
2017-06-08
Use
In Mexico, the law requires companies to issue electronic invoices and to use XML-based files as a medium for
invoice exchange. This exchange, referred to as Comprobantes Fiscales Digitales por Internet (CFDI), involves a
customer, a vendor, and a local authorized certification provider (Proveedor Autorizado de Certificación, PAC).
Note
As of 2014, companies must use CFDI and the old CFD schema is not supported anymore. For information
about how to migrate to the CFDI schema, see the SAP Note 1933263.
Companies issuing electronic invoices must request the PAC to certify each document. The PAC then assigns a
unique identification number (UUID) for each document on behalf of the tax authority (Servicio de Administración
Tributaria, SAT).
This function enables companies in Mexico to meet legal requirements when they create electronic invoices and
electronic debit or credit memos directly in Financial Accounting (FI). According to the Anexo 20 law in Mexico, all
companies that issue electronic invoices must protect the integrity of these documents by applying a digital
signature.
You can use Mexico-specific functions to sign electronic invoices digitally, for example, credit memos that you
send to your business partners.
Integration
You use digital invoices with for Mexico. In the environment, the system calls the invoice and tax amounts from
the leading ledger to collect data for the digital signature function.
You use the digital signature functions as part of the regular posting process in the Accounts Receivable
component in Financial Accounting. For more information, see .
You use a middleware product that is able to process inbound and outbound IDocs. You use the middleware for
the following purposes:
● To create XML files and send these files to your certified service provider (PAC) and to receive XML files from
this service provider
● To create electronic invoices that you send to your business partners
To print a customer invoice, you require third-party software that generates a graphical image that represents the
Quick Response Code (QR code) as specified in Anexo 20 (page 109). The graphical image is base64 encoded.
How the QR code is interpreted is dependent on your certified service provider (PAC).
● You have completed the settings described in Customizing for Digital Invoices [page 4]. These settings
enable the system to send and receive electronic invoice data.
● You or the operator of your middleware has implemented coding to generate XML files from the electronic
invoice data (IDoc) to create approval requests, cancellation requests, or customer invoices.
Features
In Mexico, some business practices require companies to create accounting documents, for example, customer
invoices, debit memos, and credit memos directly in Financial Accounting. When you create an invoice to send to
your customers, you can protect the integrity of the document using Public Key Cryptography Standards, which
use a private key and a public key. When you save invoices in the system, the system uses standard security
functions with the legally required encryption methods and your private key to sign the documents digitally. You
distribute the corresponding public key to the business partners to whom you want to send digital invoices. Your
business partners use the public key to verify the contents of the documents that you send.
For more information about the digital signature process, see Signing Electronic Invoices [page 5].
To meet legal requirements for creating or cancelling a digital document, you must request approval from the
Mexican authorities. For more information, see Approval and Cancellation of Digital Invoices [page 8].
To comply with legal requirements in Mexico for creating digital invoices, you must map some IDoc types
provided for invoice approval and cancellation requests and for customer invoices. For more information, see IDoc
Mapping for Digital Invoices [page 10].
Context
To set up your system to sign invoices digitally, you make the settings described below.
Procedure
1. Make all the settings described in Customizing for . These settings are required to trigger creation of the
digital signature.
2. To determine which invoices you want to sign digitally, make the following settings in Customizing for Cross-
Application Functions under General Application Functions Cross-Application Document Numbering
Mexico Automatic Document Numbering Assign Document Classes to Document Types :
Note
The section above includes general settings for Mexico, as well as specific settings depending on whether
you want to digitally sign billing documents in Sales and Distribution (SD) or invoices in Financial
Accounting (FI).
5. To send intermediate documents (IDocs) to an external system to generate an XML file, you must set up your
system to send IDocs.
For more information about setting up a system to send IDocs, see IDoc Interface/Electronic Data
Interchange. For more information about approval requests, approval responses, cancellation requests,
cancellation responses, and creation of digital invoices, see IDoc Mapping for Digital Invoices [page 10].
6. To ensure that iDocs are filled in accordance with CFDI catalog values published by SAT, make the settings in
Customizing for Cross-Application Components under General Application Components Digital Signature
Country-Specific Settings Mexico Digital Signature Settings General Settings Settings for iDoc Filling
with CFDI Catalog Data .
Use
You can use this process to meet legal requirements in Mexico by applying a digital signature to electronic
invoices that you send to your business partners as part of the billing process. For example, in Mexico, if your
customer pays within a specified period of time and is entitled to a discount, you must register the discount by
creating a credit memo in Financial Accounting (FI) and sending it to your customer.
The system signs the data in electronic invoices digitally using the algorithms and encryption standards stipulated
by Mexican law.
You use the encrypted data to generate an IDoc, which is sent to your middleware.
On the basis of the IDoc, the middleware generates an XML file for creating an approval request, a cancellation
request, or an invoice request. The middleware receives responses, which are sent to the SAP system as part of
the legal approval process.
You have made the settings described in Customizing for Digital Invoices [page 4].
Process
Note
When you save an invoice, the system creates an IDoc and sends the IDoc to the target system (for
more information, see Customizing for Digital Invoices [page 4]).
5. You use a middleware product to generate the XML file that you send to your business partners.
In line with the latest requirements stipulated by the Mexican authorities, you add any extra information, for
example, official codes or special tax payer data, to the XML file and then send it to your business partners.
For more information about generating the required XML file, see SAP Note 1943607 .
Note
The system that you use to generate the XML file can be a third-party system.
Use
This function enables you to encrypt the data in invoices as part of the digital signature process.
The system uses a combination of data stored in the invoice and data that it derives from the contents of the
invoice to compile a character string known as the original input message. The system forms the character string
in a specific order, which the Mexican authorities define.
Table 1:
Category Description
Address data for sales organization The address of your sales organization, if that differs from
your company’s address.
Tax Regime data The type of tax regime your company belongs to
Customer identification data The tax number and name of your customer
Sales or goods data Details of the goods or services that you sell
Customs data Details of the customs document that the authorities issue for
foreign trade
Property account data Relates only to lease agreements; for example, if a customer
rents a room in your building, your building has a property ac
count number.
Supplement ( Complemento ) for goods or services in invoice Additional data about the individual items in an invoice that
some companies are required by law to provide
Supplement ( Complemento ) for whole invoice Additional data at the header level of an invoice that some
companies are required by law to provide
Addendum ( Addenda ) Additional data that customers can choose to include in their
invoices
Note
According to Mexican law, some of the texts that the system derives must be in Spanish.
Since the system generates a character string for the original input message whenever you save an invoice, each
time you save an invoice, the system generates a different original input message and therefore a different digital
signature.
Use
This function enables you to meet business requirements in Mexico for requesting approval to create a digital
invoice or for cancelling an approved digital invoice.
Features
You use the Monitor Approval Requests report (transaction code CFDI_MONITOR) to monitor the process status
of a digital invoice and to trigger the generation or the cancellation of the digital invoice if this has been approved
by the SAT (Servicio de Administracíon Tributaria).
You use the Cancellation Request report (transaction code CFDI_CANC) to trigger the generation of a cancellation
request.
Use
This function enables you to meet business requirements in Mexico by printing digital invoices.
Although you send digitally signed invoices to your business partners electronically, some companies require you
to send a hard copy of the digital document.
You use the standard correspondence functions in Financial Accounting (FI) to print digital invoices. In line with
legal and local business requirements in Mexico, you can enhance the standard correspondence functions to
ensure that the printout contains the following data:
Table 2:
&tt= Total amount (17 characters: 10 characters for the integer part + . + 6 characters 21
for the decimal part)
&id= Unique identifier assigned to the invoice by the tax authorities (36 characters) 40
Example
?re=XAXX010101000&rr=XAXX010101000&tt=1234567890.123456&id=ad662d33-6934-459c-a128-
BDf0393f0f44
○ The QR code must be printed in a box with sides no lower than 2.75 cm.
Activities
To print a digital invoice, follow the standard procedure for printing correspondence. For more information, see .
The function for creating digital invoices to meet legal requirements in Mexico provides IDoc basic types for the
following:
● Invoice approval and cancellation requests and the responses to these requests
For more information, see IDoc Mapping for Invoice Approval and Cancellation Requests [page 11]
● Customer invoices
For more information, see IDoc Mapping for Customer Invoices [page 14]
Note
The IDoc types introduced below are part of the Comprobantes Fiscales Digitales por Internet (CFDI) solution.
These IDoc types do not support the inclusion of withholding tax data. If you want to add withholding tax data,
you can only do so for billing documents created in Sales and Distribution, by implementing the Business Add-
In (BAdI) method Get Withholding Tax Data of the Line Item (GET_LINE_ITEM_WHT) of the BAdI: SD Data
Determination (IDMX_DI_SDDATA_DET). To access this BAdI, in Customizing for Cross-Application
Components, choose General Application Components Digital Signature Country-Specific Settings
Mexico Digital Signature Settings Business Add-Ins (BAdIs) Digital Invoice Mexico: Data Determination
BAdI: SD Data Determination .
Use
The following basic types exist for the invoice approval and approval of invoice cancellation processes:
● Send invoice approval requests and invoice cancellation requests from SAP ERP (IDoc basic type
MXCFDIREQ001).
This basic type contains the data (that is, the original input message) that is required to generate the digital
signature and the data that is required for invoice approval requests (for example, the UUID and timestamp).
● Receive responses in SAP ERP from the authorities (PAC/SAT) (IDoc basic type MXCFDIRESP001)
This basic type contains the data sent by the authorities (for example, the UUID or digital stamp issued by the
government system).
Process
Figure 2: Flow for Invoice Approval and Cancellation Requests and Responses to These Requests
The IDoc basic type MXCFDIREQ001 is assigned the following message types:
The IDoc basic type MXCFDIRESP001 is assigned the following message types:
For more information, see IDoc Mapping for Invoice Approval Requests [page 12] and IDoc Mapping for Invoice
Cancellation Requests [page 13].
Use
During document posting, the digital signature is generated and the invoice approval request is triggered.
Process
The IDoc that contains the data that is required for generating the digital signature and for requesting approval is
created (IDoc basic type MXCFDIREQ001). Message type MX_CFDI_APPREQ is assigned to the IDoc to indicate
that it contains the invoice approval request. The IDoc is sent to the middleware and is converted into an XML
format. The middleware communicates with the PAC system to obtain the approval from the government system.
A response is sent (in XML format) from the PAC to the middleware. The middleware maps the XML response to
the response IDoc basic type (MXCFDIRESP001). Message type MX_CFDI_APPROV is assigned to this IDoc to
indicate that it contains the response to the invoice approval request.
Use
Before you can cancel an invoice that has already been approved, you have to request approval for the
cancellation from the government system.
Process
You trigger the invoice cancellation request using the report CFDI_CANC_REQ_MX (transaction code CFCICANC),
and the IDoc (MXCFDIREQ001) is created to send out the request. The message type MX_CFDI_CANAPPREQ is
assigned to the IDoc to indicate that the IDoc contains the invoice cancellation request.
The response to the invoice cancellation request is sent to SAP ERP via IDoc MXCFDIRESP001 with the message
type MX_CFDI_CANAPP.
Note that you cannot cancel an invoice document in SAP ERP until the response to the invoice cancellation
request has been received.
Use
The IDoc type MXCFDIINV001 contains the information needed to generate the final digital invoice, that is, the
official XML file that is sent to the customer.
The segments used for this IDoc type are the same as used for the IDoc type for the approval request
MXCFDIREQ001, with the following exceptions:
● The IDoc type additionally includes the segment E1EDMXCFDISTAMP, which is also used in the IDoc type
MXCFDIRESP001 to receive the approval data.
● The segment E1EDMXDFDICANC is not included. This segment is not needed to create the final electronic
invoice, since it contains only cancellation data.
Process
You can optionally manually select IDocs in the IDoc monitoring tool to trigger sending of electronic invoices to the
customer system. Alternatively, you can configure the middleware to generate electronic invoices on the basis of
the approval request.
In addition to the data from the approval request, the IDoc MXCFDIINV001 contains the digital signature and
optional addenda (if required by the invoice recipient). Addenda are optional nodes that contain business
The addenda texts are sent in both the approval request and final invoice IDocs in the segment E1EDKT1, field TID
= 'ADD', subsegment E1EDKT2, fields TDLINE + TDLINE + TDLINE.
In the invoice approval request, the segment and ID are omitted from the middleware mapping. In the final invoice,
however, the segment and ID are included in the XML file and are mapped to the corresponding element Addenda.
Coding Samples
Any software coding and/or code lines / strings ("Code") included in this documentation are only examples and are not intended to be used in a productive system
environment. The Code is only intended to better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and
completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, unless damages were caused by SAP
intentionally or by SAP's gross negligence.
Accessibility
The information contained in the SAP documentation represents SAP's current view of accessibility criteria as of the date of publication; it is in no way intended to be a
binding guideline on how to ensure accessibility of software products. SAP in particular disclaims any liability in relation to this document. This disclaimer, however, does
not apply in cases of willful misconduct or gross negligence of SAP. Furthermore, this document does not result in any direct or indirect contractual obligations of SAP.
Gender-Neutral Language
As far as possible, SAP documentation is gender neutral. Depending on the context, the reader is addressed directly with "you", or a gender-neutral noun (such as "sales
person" or "working days") is used. If when referring to members of both sexes, however, the third-person singular cannot be avoided or a gender-neutral noun does not
exist, SAP reserves the right to use the masculine form of the noun and pronoun. This is to ensure that the documentation remains comprehensible.
Internet Hyperlinks
The SAP documentation may contain hyperlinks to the Internet. These hyperlinks are intended to serve as a hint about where to find related information. SAP does not
warrant the availability and correctness of this related information or the ability of this information to serve a particular purpose. SAP shall not be liable for any damages
caused by the use of related information unless damages have been caused by SAP's gross negligence or willful misconduct. All links are categorized for transparency
(see: http://help.sap.com/disclaimer).