Saft
Saft
12-Fev-2009
SAFT-PT: Standard Audit File for Tax Purposes for Portugal RTXDART_PT
Contents
1. Introduction ............................................................................................................................... 1 2. Overview .................................................................................................................................... 2 3. Product data determination for FI invoices ................................................................................. 3 4. Product data customizing for FI invoices ..................................................................................... 6 5. DART preparation ....................................................................................................................... 7 6. DART configuration (FTWP) ........................................................................................................ 8 7. Data Extract (FTW1A) ................................................................................................................. 9 8. Tax data customizing (transaction: PTDART_TAX) ..................................................................... 12 9. Create XML file ......................................................................................................................... 13 10. Optimize memory configuration ............................................................................................. 15 11. Splitting files........................................................................................................................... 15 12. Merge XML files with report RDART_FILE_MERGE .................................................................. 15 13. Recommendations for splitting extracts and merging files ...................................................... 16 14. How to fill specific fields with a user exit: ............................................................................... 17 15. Configure date fields in the DMEE tree ................................................................................... 19 16. Create a transaction for report RTXDART_PT and RDART_FILE_MERGE .................................. 19
1. Introduction
According to Portaria n 321-A/2007 of Portuguese legislation, published on March 26thby the Portuguese government, a new requirement became mandatory as of fiscal year 2008 for all companies that use computerized means to manage their accounting and billing procedures. This new obligation consists in producing a file, the so-called SAF-T-PT file, whenever required by the Tax Authorities for auditing purposes. This file contains the data from the Accounting and Billing systems. Considering the fact that companies use the most diverse systems for their data processing, which at the same time are subject to verification by Tax Authorities, it was found necessary to follow a norm in order to obtain the same data export independently from the source so that the auditor is not forced to acquire skills in various systems. The structure of the file is thus a standard to follow in all cases and is described in the Portaria. According to the legally required file format and content the XML file consists of the following sections:
Page 1
12-Fev-2009
Most of the data can be read directly from the system (DART Extract or Data Base Tables) to populate the fields in the XML file. However, some data has to be derived under specific conditions before being sent to the file. Whenever this is the case it is explained in this document. The objective is to obtain one SAFT-PT XML file for one fiscal year containing all the relevant data. The SAP Notes 1082823 and 1293083 provide the required functionality that enables SAP ERP users to create the SAF-T_PT file according to Portuguese Legislation - Portaria 321a/2007. Each one of the programs is suitable for different situations: Note 1293083 refers to the program RSAFT_PT_XML. This program is suitable for all company codes, from small to very large amount of data. You may produce a file for the data of a complete year. Additional notes add corrections and should be implemented. Note 1082823 refers to the program RTXDART_PT. This program is suitable only for company codes with a small to medium amount of data (< 1Mio FI or SD documents per year; < 999 line items per SD document ; < 250.000 Customers / Vendors / Materials). Additional notes add corrections or additional functionality and should be implemented as well. The notes are mentioned under Related Notes. For example note 1321746 adds functionality to RTXDART_PT for FI-invoices; these invoices are manually created invoices in FI or invoices created out of SAP Real Estate. This Manual refers to Report RTXDART_PT and focuses particularly on the creation of the xml file for FI invoices. Nevertheless, the user should be aware that he can use this report to create a SAFT file for Master Data and SD invoices as well.
2. Overview
All solutions work based on the same process: Step 1: Produce a data extract in DART with the relevant data for single periods or for the complete fiscal year; Step 2: Run the XML conversion report (RTXDART_PT) to produce an XML file out of the data in the DART extract. This program will create a file in the legally required format. Step 3: Merge the single XML files in case you create files for small subperiods instead of one for the complete period as requested. Use program RDART_FILE_MERGE for this step. If you create a file for the complete year right away you will not need to execute this step. Step 4: Download the file on your local PC with program RFASLDPC or get it directly from the server.
Page 2
12-Fev-2009
Page 3
12-Fev-2009
2.
For FI manual invoice (non RE) with a clear identification of the Product based on GL account: o If the FI invoice does not fulfill the criteria for situation 1 then it is automatically identified as an FI manual invoice. In this case the product can be identified according to the GL account range it is posted to. The product numbering is customized in table PTSAFT_MATACCNT . o The Materials Master Data Record (table MARA) or Table SAFT_PT_FIMD (if MARA is not to be used for the same reason as explained under 1.) shall be used to store the relevant Product data for these documents and maintained accordingly. The product number shall be taken as customized in table PTSAFT_MATACCNT. o Customizing: Master Data Record (table MARA) or Table SAFT_PT_FIMD PTSAFT_MATACCNT for Product numbering according to GL-Account. o Process:
3.
FI manual invoice (non RE) based on GL line item text: o This is an exceptional situation and is therefore treated as customer specific. If the FI invoice does not fulfill the criteria for situation 1 and 2 then it is automatically identified as an FI manual invoice whose product data will be identified according to GL line item text and GL account range. The program will call a user exit passing the Line Item Text and it will return the ProductCode; This is customized in a customer specific table. o The structure SAFTPT_PRODS shall be used to maintain the product master data as required for the Master Data in the xml file. o This approach should be used only as an exception for documents that cannot be categorized easily as described in point 1 and 2. o Customizing: User Exit FI-Invoices Case 1 (see chapter 14 in this document) User Exit FI-Invoices Case 2 (see chapter 14 in this document) User Exit FI-Invoices Case 3 (see chapter 14 in this document) o Process:
Page 4
12-Fev-2009
XML Field
ProductType
Description
Indicator for product type; for FI invoices it is generally related to a service. (Set P for products, S for services and O for Others). Unique code to identify the product
Manda tory
* For FI invoices from RE: read TXW_MAT; For FI invoices where product is dependent on GL-Accnt: read TXW_MAT or SAFTPT_FIMD-PRODUCTCODE For FI invoices where product corresponds to GL-line item text based on GL-Accnt range: read structure SAFTPT_PRODS. For FI invoices from RE: read TXW_MAT; For FI invoices where product is dependent on GL-Account: read TXW_MAT or SAFTPT_FIMD; For FI invoices where product corresponds to GL-line item text based on GL-Account range: read structure SAFTPT_PRODS. *
2.4.2.
ProductCode
2.4.4.
ProductDescription
Product description
For FI invoices from RE: read TXW_MAT; For FI invoices where product is dependent on GL-Account: read TXW_MAT or SAFTPT_FIMD; For FI invoices where product corresponds to GL-line item text based on GL-Account range: read structure SAFTPT_PRODS. Equal ProductCode (2.4.2.)
* 2.4.5. ProductNumberCode EAN Code. If not available fill field with ProductCode (2.4.2.) *
Page 5
12-Fev-2009
XML Field
ProductCode
Description
Product code derived from the FI document *
Mandatory
SAP Solution
For FI invoices from RE: concatenate the fields TZB0ARANTYP and TZB0A-SBEWART to compose the product code; For FI invoices where product is dependent on GLAccount: read PTSAFT_MATACCNT and based on GLAccount find the Product Code. For FI invoices where product corresponds to GL-line item text based on GL-Account range: read user exit and customer specific table and identify Product Code according to GL line item text. For FI invoices from RE: read TXW_MAT; For FI invoices where product is dependent on GLAccount: read TXW_MAT or SAFTPT_FIMD; For FI invoices where product corresponds to GL-line item text based on GL-Account range: read user exit and customer specific table and identify ProductDescription according to GL line item text. per default = 1 N/A
4.1.4.10.4.
ProductDescription
4.1.4.10.5. 4.1.4.10.6.
Quantity UnitOfMeasure
Meaning
Client Company code Product number Product description Product group
PTSAFT_MATPRE (optional) Define Product Number Prefix: As Material Master Data records are created for RE Services/Products with numbering taken from the concatenation of TZB0A-RANTYP and TZB0ASBEWART, number prefixes may have to be defined to avoid duplicated Material Number.
Field Name
MANDT BUKRS MAT_PREFIX
Meaning
Client Company code Product number prefix for RE invoices
PTSAFT_MATACCNT Define Product Number depending on GL-Account: where there is a clear relationship between the GL account and the service/product from the invoice the product data can be defined based on the GL Account
Field Name
MANDT BUKRS GLACCOUNT MATNR
Meaning
Client Company code General ledger account Product number
Page 6
12-Fev-2009
SAFTPT_FIMD Maintain Product Master Data: this can be used whenever the Material Master Data is not suitable: this table is only used to read Master Data for the XML file; so whatever is maintained in this table will be transferred to the xml file.
Field Name
MANDT COMPANY_CODE GLACCOUNTFROM GLACCOUNTTO PRODUCTCODE PRODUCTTYPE PRODUCTGROUP PROD_DESCRIPTION
Meaning
Client Company code From General ledger account To General ledger account Product number Product type Product group Product description
SAFTPT_PRODS This is filled at runtime for line item text based Product data using User Exit Case 2. This will provide the Product Master Data for this kind of invoices.
Field Name
MATNR MTREF CNAME1 MAKTX EAN11
Meaning
Product number Product type Product group Product description EAN11 code
5. DART preparation
a) Check DART version: proceed as follows: for 4.6C release: (1) SE11 -> Utilities-> Other Dictionary objects (2) insert DART1 in Type Group (3) click on display for releases > 4.6C: (1) SE12 -> Select radio button "Type Group" (2) -> Enter DART1 (3) -> Click on "Display" or "F7"; under section of constants you can find: CONSTANTS: dart1_rl LIKE txw_c_v0-dart_rl VALUE '2.5'. This indicates the DART version. Please note that the minimal requirement is DART version 2.4. If this is not the case in your system please carry out the upgrade of the DART tool first. Please refer to the relevant SAP Notes (component CA-GTF-DRT) and make also sure that error correction notes related to DART are implemented. (Please check OSS note 945615 for some more details on DART tool). To upgrade DART release from 2.3 to 2.4, refer the note: 810014 This note has correction instruction and also SAR files (in the note attachment); Implement both correction instruction and the SAR file. b) Assign the DART data volume to your company code Execute transaction SM30; specify TXW_C_BUKRS; Assign the data volume ALL to the company code.
Page 7
12-Fev-2009
Go to tab Master Data Check the selection check box Enable master data segment selection; this activates the fields on the selection screen when running the data extract enabling you to make the selection when running the extract.
Go to tab Technical Settings Make sure that the technical settings are adequately defined according to your system environment. The figures shown here are only examples and may not be the best configuration for your system Page 8
12-Fev-2009
The limitation of data volume may be convenient for testing purposes and you can select or unselect it later on the selection screen.
b) File Directories: Create the file directories where to locate the data extract Go to Details to define Directory Set, Directory Set Description, the file location; you may receive an error message XW163: file name is limited to n digits. This is an Operating System issue. Proceed as follows: SM30, enter V_FILESYS and press maintain. Here you can define more digits for the respective operating system. Click Create
12-Fev-2009
Plant Customer Master Vendor Customer Master
Select radio button Select all and then press button Select individual master data segments in order to restrict the selection. Data file Data file name (any user defined file name) Directory set (defined previously using FTWP)
After executing the extract use transaction FTWF to browse the file extract.
Page 10
12-Fev-2009
Note: To obtain the following section of the Audit File you need to select the following data source items:
Audit File Section Data source FTW1A DART segment(s); Selection RSAFT_FIRE screen fields Is created automatically when running RTXDART_PT DART segment: Selection Screen fields: TXW_COMPC Company ID Tax Accounting Basis Header Comment
MasterFiles General Ledger Customer To include One-time-Customers: DART segment: TXW_GLACC DART segment: TXW_CUST_E1 Selection Screen field: Finance documents (FI) DART segment: TXW_BSEC DART segment: TXW_LFAS TXW_VENDOR Selection Screen field: Finance documents (FI) DART segment: TXW_BSEC DART segment: TXW_MAT TXW_PLANT Table: PTDART_TAX_DATA Selection Screen field: Finance documents (FI) DART segment: TXW_BSEC
Product
Page 11
12-Fev-2009
RSAFT_FIRE
The fields in table PTDART_TAX_DATA have the following meaning: Field Tx Tax type Tax Descr Content Tax code define whether the tax code refers to VAT (IVA) or to Stamp Tax (imposto de selo) (IS) Define to which region the tax code refers to (concatenated with tax type: IVACON for Continente; IVARAA for Regio Autnoma dos Aores; IVARAM for Regio Autnoma da Madeira; IS for Stamp Tax; Code for tax rate type: 1 Intermdia (Intermediate); 2 Normal; 3 Reduzida (Reduced); 4 Isenta (Exempted); 5 Outras (Others); Full text for tax rate type: Normal; Intermdio; Reduzida; Isenta Tax percentage SAFT field Description
Run the transaction PTDART_TAX; Press the button Maintain. Click the button New Entries and specify the values for all the fields and save the entries. Example: Page 12
12-Fev-2009
Condition rate 12 20 5 0 n/a 1
Page 13
12-Fev-2009
Field name Data extract data Data file name Directory set Master Data Extract File
Meaning The extract for which you want to create the xml file Where the extract files are stored The extract file that contains the relevant master data; fill only in case it is not included in the data file (first field) itself. Please consider the details explained under point 9 and the recommendations given. Please keep in mind that when creating the XML file for Billing documents you need to indicate the correspondent Master Data extract in order to obtain a complete file as some of the required data is taken from the Master Data tables (e.g. Addresses). This is only necessary in case the master data is in a separate extract. The company code for which you created the extract and want to create the xml file. The fiscal year for which you created the extract and want to create the xml file. The relevant plants for the company code to which you want to limit the Materials Master Data Select the Ledger Check this radio button if your Portuguese Chart of Accounts is the main Chart of Accounts in your Company Code Master Data (KTOPL) check this radio button if your Portuguese Chart of Accounts is Check parallel Chart of Accounts in your Company Code Master Data (KTOP2) Field CompanyID in File Header: Registration Number of the company Field TaxAccountingBasis in File Header: Specify for which data you are creating the file: financial data, or billing data, or integrated data: Contabilidade or Facturao or Integrado Contabilidade e Facturao Field HeaderComment in File Header: fill with you own free text File name of the target xml file you want to create
Company specific data Company Code Fiscal year Plants Ledger Legal chart of accounts Primary Chart of Account
Check this box if you have FI invoices Specify the document type(s) for the FI invoices; only FI documents with this document type will be selected as invoices. Line item selection for documents Doc.types shown with GL Select the document type of the FI invoices for which you want to show the GL lines in the file; this is the default configuration of the report Doc.types shown with BP Select the document type of the FI invoices for which you want to show the Business Partner lines in the file; SD Billing documents Check this box if you have SD invoices
c. Execute: to execute in online mode press Enter or F8. You can also run the report in background. This is recommended if you are processing a huge amount of data. When the execution of the report is finished you will receive a success message. 2. Obtain the XML: use program RFASLDPC or from the server. a. The XML file can be downloaded with the program RFASLDPC or it can be fetched directly from the server (if you have a Unicode system you have to convert the file to ANSI format locally). b. When running RFASLDPC specify File type as **.
Page 14
12-Fev-2009
Page 15
12-Fev-2009
b. Execute the report. Once the file is created you will receive a success message. 2. Obtain XML file: program RFASLDPC or from the server The XML file can be downloaded with the program RFASLDPC or it can be fetched directly from the server.
Page 16
12-Fev-2009
Description
12-Fev-2009
Note: From the report key fields will be sent to the above user exit and transaction also the transaction type. Work area wa_master will contain the key fields, For TRANSACTION_TYPE = 1. Wa_master will contain values for ProductCode and ProductGroup. User has to fill the value for variable PRODUCT_TYPE based on above 2 fields For TRANSACTION_TYPE = 2. Wa_master will contain the key fields JOURNAL_ID, TransactionID and also other related to the document header and the line item (RecordID, AccountID ). User has to fill the value for variable TDGL_DESC based on the key fields present in the work area wa_master. For TRANSACTION_TYPE = 3. Wa_master will contain the key fields InvoiceNo, LineNumber and also other related to the document header and the line item User has to fill the value for variable INVOICE_TYPE based on the key fields present in the work area wa_master. Depending on the TRANSACTION_TYPE (report will pass the value while calling the user exit), respective export parameters can be filled using the work are wa_master. FI Invoices User exit details Case 1: * 4.1.4.10.3 / 4.1.4.10.4 CALL FUNCTION 'ZPT_USER_EXIT_DART' EXPORTING wa_master = wa_master transaction_type = '1' IMPORTING prod_code = wa_master-sd_matnr Case 2 : SAFT_PTPRODS . Master data creation. Case 3: product based on line item text / other cases. CALL FUNCTION 'ZPT_USER_EXIT_DART' EXPORTING WA_MASTER = wa_master TRANSACTION_TYPE = '5' IMPORTING PROD_CODE = wa_master-sd_matnr PROD_DESCRIPTION = prod_desc TABLES IT_EXPREPROD = IT_EXPREPROD. Page 18
12-Fev-2009
Step 2: You will see the following screen; proceed as follows: Specify Transaction code e.g. safpt_merge (you can specify your own name for this) Specify Short text, e.g. Dart PT: XML file merge report (you can specify your own name for this) Select radio button : Program and selection screen (report transaction)
Page 19
12-Fev-2009
Step 3: System will show the following screen. Proceed as follows: Specify Program : RDART_FILE_MERGE Select all GUI support parameters Save the transaction. Specify package as ID-FI.
Page 20