Sie sind auf Seite 1von 16

PUBLIC

2017-06-08

Processing of Digital Billing Documents


Content

1 Processing of Digital Billing Documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3


1.1 Customizing for Digital Billing Documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Customizing for SD Reversal Documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
1.3 Signing Electronic Billing Documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Digital Signature Creation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4 Approval and Cancellation of Digital Invoices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.5 Printing of Digital Billing Documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.6 IDoc Mapping for Digital Invoices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10
IDoc Mapping for Invoice Approval and Cancellation Requests. . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
IDoc Mapping for Customer Invoices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13

Processing of Digital Billing Documents


2 PUBLIC Content
1 Processing of Digital Billing Documents

Use

In Mexico, the law requires companies to issue electronic billing documents 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 1914863.

Companies issuing electronic billing documents 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 and send electronic
billing documents. According to the Anexo 20 law in Mexico, all companies that issue electronic billing documents
must protect the integrity of these documents by applying a digital signature.

You can use Mexico-specific functions to sign electronic digitally. You send the digitally signed billing document,
for example, a digital invoice, to your business partners.

Integration

You use the digital signature functions as part of the regular billing process in the Sales and Distribution
component. For more information, see .

You use the digital signature process together with for Mexico.

Prerequisites

You have created an electronic billing document in the Sales and Distribution component.

You have performed the settings described in Customizing for Digital Billing Documents [page 4].

Features

When you bill your customers for goods or services that you sell, you can protect the integrity of billing
documents using Public-Key Cryptography Standards, which use a private key and a public key. When you save

Processing of Digital Billing Documents


Processing of Digital Billing Documents PUBLIC 3
billing documents 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 billing documents. 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 Billing Documents [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].

In case you need to send a hard copy of the digital billing document, you can print it as required. For more
information, see Printing of Digital Billing Documents [page 9].

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].

1.1 Customizing for Digital Billing Documents

Context

To set up your system to sign billing documents digitally, you make the settings described below.

Procedure

1. Make all the settings described in . These settings are required to trigger the creation of digital signature.
2. To determine which billing documents 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 :
○ Specify which accounting document types are relevant for the digital signature process by assigning a
document class to the corresponding accounting document type.
○ For each of the accounting document types that you want to sign digitally, on the Details screen, select
Generate Official Document Number, with Date Control in the Official Doc. Number (Official Document
Number) field.
3. To enable the system to digitally sign billing documents for use in Mexico, perform the activities in
Customizing for Cross-Application Components under General Application Components Digital Signature
Country-Specific Settings Mexico Digital Signature Settings .

Note
The section above comprises general settings for Mexico, as well as specific settings depending on
whether you want to digitally sign SD billing documents, or invoices in Financial Accounting (FI) too.

Processing of Digital Billing Documents


4 PUBLIC Processing of Digital Billing Documents
4. To send intermediate documents (IDocs) to an external system to generate an XML file, 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].
5. 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 .

1.2 Customizing for SD Reversal Documents

Use

When using a new ODN for the canceling document, you have to cancel the SD document and you have to transfer
the SD canceling document to FI.

Prerequisites

Caution
To ensure that the SD reversal document are correct when a new ODN is retrieved, you must implement the
user exit as described in SAP Note .

To ensure that only one number range interval is used for one company code so that the billing documents are
sequentially numbered in that company code, you must implement the user exit as described in SAP Note
595327 .

1.3 Signing Electronic Billing Documents

Use

You can use this process to meet legal requirements in Mexico by applying a digital signature to electronic billing
documents that you send to your business partners as part of the billing process.

The system signs the data in electronic billing documents digitally using the algorithms and encryption standards
stipulated by Mexican law.

Processing of Digital Billing Documents


Processing of Digital Billing Documents PUBLIC 5
You use the encrypted data as the basis for generating a digital billing document, which you can send as an XML
file, or a printout.

Prerequisites

You have made the settings described in Customizing for Digital Billing Documents [page 4].

Process

1. To bill your customers for goods or services that you sell, you create a billing document in the system.
2. When the data in the billing document is complete, you save the billing document.

Note
Only when you release the document to Financial Accounting (FI) does the system place the final digital
seal on the document, after which you must not make any further changes.

3. You release the billing document to FI.


The system determines whether the billing document requires a digital signature, for example, by checking
your Customizing settings for automatic document numbering and whether the company code is specific to
Mexico.
4. The system signs the document digitally and places a digital seal on the document as follows:
○ The system uses standard security functions to sign the billing document digitally. For more information,
see Digital Signature Creation [page 7].
○ The system stores the data required for the digital signature process in text fields in the billing document
and in child segments of the intermediate document (IDoc) for a billing document.
For more information about the data that the system stores in text fields, see Customizing for Cross-
Application Components under General Application Components Digital Signature Country-Specific
Settings Mexico Settings for Documents in Sales and Distribution Determine Text IDs to Store Billing
Document Data .

Note
After you release a billing document to FI, you must not make any more changes to the billing document.
This point in time signals the final digital seal on the billing document.

5. You send the IDocs to the system that generates the XML file using standard output control functions in Sales
and Distribution (SD).
If you want to send a digitally signed billing document in a single IDoc, you must release the billing document
to FI before you generate the IDoc and send it to the required target system.
For more information, see .
6. You use SAP NetWeaver Process Integration (SAP NetWeaver PI) or another system 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.

Processing of Digital Billing Documents


6 PUBLIC Processing of Digital Billing Documents
To find out which IDoc fields the system uses to store the data that you use to generate the XML file, see
Customizing for Cross-Application Components under General Application Components Digital Signature
Country-Specific Settings Mexico Settings for Documents in Sales and Distribution Check Location of
Data in IDoc Segments .
For more information about generating the required XML file, see SAP Note 1296042 .

Note
The system that you use to generate the XML file can be a third-party system.

1.3.1 Digital Signature Creation

Use

This function enables you to encrypt the data in billing documents as part of the digital signature process.

Features

The system uses a combination of data stored in the billing document and data that it derives from the contents of
the billing document 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.

The character string comprises the following data:

Table 1:

Category Description

Document data Official document numbering information, document type,


and payment information.

Company code data Your company's tax number and name.

Company address data Your company's full address.

Address data for sales organization Contains the address of your sales organization, if that differs
from your company's address.

Tax Regime data Contains the type of tax regime your company belongs to.

Customer identification data The tax number and name of your customer.

Customer's address The full address of your customer.

Sales or goods data Details of the goods or services that you sell.

Processing of Digital Billing Documents


Processing of Digital Billing Documents PUBLIC 7
Category Description

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 billing Contains additional data about the individual items in a billing
document document that some companies are required by law to pro­
vide.

Tax data Shows the tax type, rate, and amount.

Supplement (“Complemento”) for whole billing document Contains additional data at the header level of a billing docu­
ment that some companies are required by law to provide.

Addendum (“Addenda”) Contains additional data that customers can choose to in­
clude in their billing documents.

Note
According to Mexican law, some of the texts that the system derives must be in Spanish.

To crunch the data in a character string to the required number of characters for the subsequent processing
steps, the system applies the MD5 hash algorithm to the original input message. The result is a character string
that comprises 32 characters. To place a unique fingerprint on the data, the system encrypts the hashed message
by applying your private key to the hashed message. The resulting message digest is 172 characters long.

Since the system generates a character string for the original input message whenever you save billing
documents, each time you save a billing document, the system generates a different original input message and
therefore a different digital signature.

Note
The system does not apply the final digital seal to a billing document until you release the billing document to
Financial Accounting (FI).

1.4 Approval and Cancellation of Digital Invoices

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.

Processing of Digital Billing Documents


8 PUBLIC Processing of Digital Billing Documents
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.

1.5 Printing of Digital Billing Documents

Use

This function enables you to meet business requirements in Mexico by printing digital billing documents.

Although you send digitally signed billing documents to your business partners electronically, some companies
require you to send a hard copy of the digital document.

Features

You use the standard output functions in Sales and Distribution (SD) to print digital billing documents. In line with
legal and local business requirements in Mexico, you can enhance the standard output functions to ensure that
the printout comprises the following data:

● Original input message


● Signed message digest
To ensure that the system can print all characters in the message digest, the system applies base 64
encoding to the message digest.
● The legally-defined standard text “this document is a printout of a fiscal invoice” in Spanish (“Este documento
es una impression del comprobante fiscal”)

Activities

To print a digital billing document, follow the standard procedure. For more information, see .

Processing of Digital Billing Documents


Processing of Digital Billing Documents PUBLIC 9
1.6 IDoc Mapping for Digital Invoices

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 10]
● Customer invoices
For more information, see IDoc Mapping for Customer Invoices [page 13]

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 .

1.6.1 IDoc Mapping for Invoice Approval and Cancellation


Requests

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).

Processing of Digital Billing Documents


10 PUBLIC Processing of Digital Billing Documents
Process

Figure 1: Flow for Invoice Approval and Cancellation Requests and Responses to These Requests

Message types are assigned to each IDoc basic type to indicate the contents of the IDoc.

The IDoc basic type MXCFDIREQ001 is assigned the following message types:

● MX_CFDI_APPREQ: Invoice approval requests


● MX_CFDI_CANAPPREQ: Invoice cancellation requests

The IDoc basic type MXCFDIRESP001 is assigned the following message types:

● MX_CFDI_APPROV: Responses to invoice approval requests


● MX_CFDI_CANAPP: Responses to invoice cancellation requests

For more information, see IDoc Mapping for Invoice Approval Requests [page 12] and IDoc Mapping for Invoice
Cancellation Requests [page 12].

Processing of Digital Billing Documents


Processing of Digital Billing Documents PUBLIC 11
1.6.1.1 IDoc Mapping for Invoice Approval Requests

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.

Figure 2: Flow for Invoice Approval Requests

1.6.1.2 IDoc Mapping for Invoice Cancellation Requests

Use

Before you can cancel an invoice that has already been approved, you have to request approval for the
cancellation from the government system.

Processing of Digital Billing Documents


12 PUBLIC Processing of Digital Billing Documents
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.

Figure 3: Flow for Invoice Cancellation Requests

1.6.2 IDoc Mapping for Customer Invoices

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.

Processing of Digital Billing Documents


Processing of Digital Billing Documents PUBLIC 13
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
information and that represent extensions to the standard defined by the tax authorities. Since some PACs reject
addenda to avoid validation errors, such addenda must be added after the stamping (digital signature) process.

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.

Figure 4: Customer Invoice (XML File)

Processing of Digital Billing Documents


14 PUBLIC Processing of Digital Billing Documents
Important Disclaimers and Legal Information

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).

Processing of Digital Billing Documents


Important Disclaimers and Legal Information PUBLIC 15
go.sap.com/registration/
contact.html

© 2017 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any
form or for any purpose without the express permission of SAP SE
or an SAP affiliate company. The information contained herein may
be changed without prior notice.
Some software products marketed by SAP SE and its distributors
contain proprietary software components of other software
vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company
for informational purposes only, without representation or warranty
of any kind, and SAP or its affiliated companies shall not be liable for
errors or omissions with respect to the materials. The only
warranties for SAP or SAP affiliate company products and services
are those that are set forth in the express warranty statements
accompanying such products and services, if any. Nothing herein
should be construed as constituting an additional warranty.
SAP and other SAP products and services mentioned herein as well
as their respective logos are trademarks or registered trademarks
of SAP SE (or an SAP affiliate company) in Germany and other
countries. All other product and service names mentioned are the
trademarks of their respective companies.
Please see http://www.sap.com/corporate-en/legal/copyright/
index.epx for additional trademark information and notices.

Das könnte Ihnen auch gefallen