You can enhance your solution by implementing BAdIs that enable the user actions and status maintenance in the Create and Submit eDocument
report.
By implementing the TRIGGER
method of the EDOC_INTERFACE_CONNECTOR
BAdI defined in the ES_EDOCUMENT
enhancement spot, you can enable actions in the report that allow you to perform the following processing steps.
Processing step you want to trigger | Action you perform in the Create and Submit eDocument report |
Request approval from SUNAT
Implementation necessary for Basic solution only. End of the note. | Submit |
Get Status from SUNAT | Tax Authorities |
Send eDocuments to customers
Valid only for invoices, debit or credit memos End of the note. | Send to Customer |
The eDocument changes its status after each action is performed. To synchronize the system with the current eDocument status, in the implementations of the TRIGGER method you can use the COMMUNICATE_PROCESS_STEP
method of the CL_EDOCUMENT_PE
. For each status change, you use a different parameter. For Peru, you can implement the following status change:
eDocument Status | Description |
| eDocument has been sent to the interface; you can optionally implement that the XML is attached to the eDocument. |
| eDocument has been submitted to SUNAT. |
| eDocument has been either approved or rejected by SUNAT. Valid for invoices, credit and debit memos. |
| eDocument has been signed. Valid for boletas only. |
| Valid for daily summary and voiding requests only. |
For more information refer to the BAdI implementation and methods documentation available directly in the system. For details on how to implement the BAdIs for enhancing the Basic solution for Peru, see SAP Note 2074583.
Note
Relevant for eDocument Full solution only.
Some information required by the SUNAT is customer-specific and therefore not part of the standard mapping done by the SAP AIF for Peru. If you want to create eDocuments for documents you created in SD or FI , you must add some fields to the XML after the SAP AIF mapping.
You can use the SET_OUTPUT_DATA
method of the eDocument Adaptor
BAdI (EDOC_ADAPTOR
) to fill your customer-specific fields. For more information, refer to the method documentation directly in the system or to the SAP Note 2065874
Note
If you implement the above mentioned BAdI, you have full control over the complete XML structure and all values that have already been filled by the system during the standard mapping. If the modified XML does not correspond to the structure that is expected by the tax authorities, you will receive an error. In this case, check your BAdI implementation for the points mentioned in the SAP Note 2065874.
Note
Relevant for eDocument Full solution only.
The eDocument Full solution for Peru enables you to send the eDocuments you created for your invoices or boletas to the tax authorities and/or your customers. It is a legal requirement that such documents are digitally signed, and also that any print representation of them contains a barcode with the digital signature. The system stores the eDocument information in the EDOPEINV
table, including the necessary information to build the barcode (stored as a binary string) which are in the following fields:
DIGEST_VALUE (Resumen)
SIGNATURE (Firma Digital)).
To include this information in your print representation, you follow the steps below:
Read the data as mentioned below:
The combination of source document type (SOURCE_TYPE) and source document key (SOURCE_KEY) identifies the record in the eDocument table (EDOCUMENT):
For billing documents: SOURCE_TYPE=SD_INVOICE and SOURCE_KEY= VBRK-VBELN (billing document number)
For accounting documents: SOURCE_TYPE=FI_INVOICE and SOURCE_KEY=concatenation of BKPF-BUKRS (company code), BKPF-BELNR (accounting document number) and BKPF-GJAHR (fiscal year).
In the eDocument table (EDOCUMENT), find the unique indentifier of the eDocument (EDOC_GUID) .
Once you know the EDOC_GUID of the record, you can look for it in the EDOPEINV for the fields DIGEST_VALUE and SIGNATURE. To be able to print them, you encode them in base64 using the SSFC_BASE64_ENCODE function module.
Fore more information, see the SAP Note 2045615