Extending Electronic Outgoing Invoices for Government Tracking using In-App Extensibility
Nowadays, technology and digitalization are powerful means of preventing and dealing with corruption. The public sector has been tremendously changed by the digital transformation, which has brought benefits like transparency, efficiency, better delivery of services and accountability.
In Italy, the government issues CUP and CIG codes to identify contracts or assignments with public investments. These codes help the government to track the financial data. Also, following the same purpose, a purchase order number reference is required in the accounting document, functionality which is not available in the standard solution, but that can be achieved as described in the following blog post.
- CUP (Codice Unico di Progetto) – Unique Project Code
- CIG (Codice Identificativo Gara) – Tender Identification Code
These codes and the customer purchase order ID needs to be reported in the electronic invoice.
After the accounting document is posted from “Create Outgoing Invoices” app, it’s transferred to eDocument Cockpit and the following tags have to be filled in the XML of eDocument Cockpit:
18.104.22.168 <IdDocumento> – purchase order number (field required)
22.214.171.124 <CodiceCUP> – CUP code;
126.96.36.199 <CodiceCIG> – CIG code;
In order to bring the purchase order number into the XML line of IdDocumento, an approach would be to create a Custom Business Object that contains the Invoice Number and the Purchase Order Reference number.
|Invoice Number||Purchase Order Reference|
This Custom Business Object will be available for a key user to fill the data from the generated UI. If needed, custom logic can be added at the Business Object nodes level for actions or validations.
Also, a BAdI enhancement is needed for bringing the Purchase Order Reference associated to the Invoice Number and to populate the IdDocumento XML field. We will get into more details in the BAdI Implementation section.
You have administrative access to SAP S/4HANA Cloud and have implementation experience in the system. Coding experience is also necessary, since this extensibility solution requires implementation of a coding logic.
|Business Role||Business Role ID|
|Administrator||SAP _ BR _ ADMINISTRATOR|
In-App Extensibility Enhancement
Custom Business Object Creation
Log in to SAP S/4HANA Cloud system with the business role as administrator.
Navigate to the Extensibility group: App Custom Business Objects, select “New” and add the name of the Custom Business Object. Save the identifier of the Custom Business Object because it will be used in the BAdI implementation, then select “Create”.
On the Edit Custom Business Object page, check the “User Interface” and “Back End Service” so that a key user will be able to add new records from this Business Object UI.
If validations or custom logic is necessary at the level of the Business Object item, also check the “Determination and Validation” box.
In the “Fields” tab, add the Invoice Number and Purchase Order Reference fields. Here a length of 50 characters was chosen for the Invoice Number and a length of 200 characters for the Purchase Order Reference. Depending on the configuration of the Invoice Numbers and Purchase Order numbers in your system, you can set these numbers accordingly. This Business Object will be populated with the Purchase Order References and the Accounting Document numbers (Invoice Number).
Save and Publish the Custom Business Object.
Assigning the Custom Business Object to a Business Catalog
In order to access the UI of this Custom Business Object, this has to be assigned to a business catalog, from which a key user can select the tile associated to it and fill the information.
Select the “Maintain Catalogs” link from the published Custom Business Object page.
Select the “Add” button from the Custom Catalog Extensions page.
Select the Business Catalog from the list.
Check the Business Catalog box and select the “Publish” button.
Add values to the Custom Business Object
Select the “Purchase Order References” tile from the Billing Documents group.
Select “Create” and add new values to the Custom Business Object.
The appropriate BAdI enhancement should be done in the Document Compliance Business Context, in the BAdI called “Italy XML file filling”.
Select the “Custom fields and logic” app from the Extensibility group.
There select the “Document Compliance” business context, the “Italy: XML File Filling” BAdI Description and add the Implementation Description, then select “Create”.
For the complete section of coding, please check the note (Login required):
For testing, we need to check if the purchase order number corresponding to the invoice, which was previously saved into the Custom Business Object, is displayed under the IDDocumento tag in the XML file generated for the invoice.
First, we will check if the extensibility capability was enabled in the system. Then, using the eDocument cockpit app, we will generate an XML for an already issued invoice and then check the IDDocumento tag.
As a final validation, we will check the Custom Business Object and see if the pair of purchase order number and invoice number are matching what is displayed in the XML file.
Validate extensibility function
Check in the system that the extensibility function is available – validate also the key user namespace in the given usage
Testing the xml file creation for the newly enhanced fields
Open the app eDocument Cockpit
Select via the checkbox the already created customer invoice
Display Preview of XML File
Choose a directory to download
Open in the folder the newly created document with e.g. Notepad++
Search for <DatiContratto> or <IdDocumento> or for the new field:
You should now be able to see the newly enhanced fields with a corresponding entry.
Test via App Custom Business Objects
Check of the technical implementation – use for this a user with corresponding rights like e.g. the Business Role Administrator (Business Role ID SAP_BR_ADMINISTRATOR)
Open the newly created business object in the corresponding namespace – current name in the test system: YY1_PURCHASEORDERREFERENCE
For the validation of the purchase order references the newly created invoice numbers should be visible.
With these steps you are extending the electronic outgoing invoices for government tracking.
For this you are using the In-App extensibility including usage of a BAdI enhancement which is needed for bringing the purchase order reference associated to the invoice number and to populate the corresponding XML fields.
Thank you for reading this blog post. Time to test! Please leave your comment and feedback.
Further information on extending localization you can find here.