Provide the Pedimento Number (Mexico) on e-Document using Custom Logic
This blog post describes a sample business scenario to provide the Pedimento Number on an e-document for sales invoice and explains how such an extension is possible on SAP S/4HANA Cloud.
A material imported into Mexico is given a Pedimento Number by the company, which is then given to its customers and tax authorities. Using the extensibility features of SAP S/4HANA Cloud, you have the possibility to provide this Pedimento Number on the e-document for sales invoice for the authorities.
In this example, we describe how to implement a custom logic using the Batch Management approach and then providing a Pedimento Number on the e-document.
Note: This extensibility approach could also be used for any other information that must be put in the e-Document for a sales invoice.
Process flow for e-Document Filling with Custom Logic (Test system picture)
You have administrative access to SAP S/4HANA Cloud and have implementation experience on the system. Coding experience is also necessary since this extensibility solution requires the implementation of a coding logic.
|Area||Business Role ID / Business User|
Business Role ID: SAP_BC_CORE_EXT
Business User: Administrator
Implement custom logic to provide a Pedimento Number on the e-Document (USE HEADING LEVEL 5)
- Log in to SAP S/4HANA Cloud system with the business role as administrator.
- Navigate to the Extensibility group: App Custom Fields and Logic- Custom Logic and create a new logic under the BAdI, Mexico: Custom Data Filling
- Choose Business context, eDocument: Mexico
- Choose BAdI Description, Mexico: Custom Data Filling
- Use the Addenda (additional information) change field to enter customer specific logic, for instance, a logic for filling a Pedimento Number from Batch Characteristic.
Note: In the new BAdI implementation, using the input parameters as filters to find the correct Pedimento Number, fill the pediment_num field that is part of the ct_pediment_data output table.
- Choose a suitable CDS view, with a released status, to retrieve the content configured in Batch Management. In our example, to retrieve the Pedimento Number from goods receipt for the specific purchase order, use the CDS View I_ClfnObjectCharcValForKeyDate.
Note: The Pedimento Number can be found in the CharcValue field, having the key field ClfnObjectInternalID
- Retrieve the input parameters using the CDS view I_journalentryitem.
Warning: The salesdocumentnumber parameter from the console is translated into the reference document number (billing document number) in the backend.
- Retrieve the ClfnObjectInternalID from the I_Batch view filtering on the product and plant
- Retrieve the CharcValue from the I_ClfnObjectCharcValForKeyDate view, using the ClfnObjectInternalID previously selected.
- Use the Addenda (additional information) (pediment_num field that is part of the ct_pediment_data output table) field to fill the value needed (e.g. Pedimento Number) as an Output parameter.
Sample code for BAdI Implementation
The sample code for the BAdI implementation for Mexico Pedimento Number is available in the GitHub repository. Use the following link to access the sample – sample_code_for_badi_implementation.abap.
Test the implementation
Preparation for Testing the Implementation
Prior to testing the implementation, you must prepare a Batch Characteristic for a Material Item in Batch Management. You can do so by using respective business users for apps login:
- Manage Characteristics App (Business user role BOM_ENGINEER)
Create the Pedimento Number as a batch characteristic. Please save the characteristic name because you will use it further in the BAdI implementation, for example, ‘PEDIMENTO’;
- Manage Classes App (Business user role BOM_ENGINEER)
Create a Batch Class for a created batch characteristic;
- Manage Product Master Data App (Business user role PRODMASTER_SPECIALIST)
Create a new Material and flag it as Batch Management. Later, assign the Material to the Batch Class.
Note: the length of the Pedimento Number could be set to 30.
Testing the implementation
1. Enter the Pedimento Number on Goods Receipt with Purchase Order reference:
- Manage Purchase Orders App (Business user role PURCHASER)
Create a Purchase Order for the material item containing the Pedimento Number as a batch characteristic;
- Post Goods Receipt App (Business user role INVENTORY_MANAGER)
Create a Goods Receipt and enter the Pedimento Number in the Batch Characteristic field.
2. Get a Batch characteristic (Pedimento Number) on the e-Document for Sales Invoice:
- Create Sales Orders App (Business user role INTERNAL_SALES_REP)
Create a sales order;
- Create Outbound Delivery with Order Reference App
- (Business user role SHIPPING_SPECIALIST)
Create Outbound Delivery and Post Goods Issue;
- Create Billing document – VF01 App (Business user role BILLING_CLERK)
Create a sales document and post to FI. The system will create an e–document;
- eDocument Cockpit App (Business user role BILLING_CLERK)
Choose the e-document created in the Create Billing document – VF01 app. Choose Display XML to get XML file. Open the XML file with help of any XML Handler. The XML Pedimento Number should appear in the Addenda field.
The Pedimento number of 21 characters is populated to the XML, however, the number of characters allowed is a maximum of 30. The Pedimento number can then be seen in the eDocument invoice for Mexico.
With this example, we have shown how you can implement a logic using the Batch Management approach for providing of Pedimento Number on the e-document using the extensibility features of SAP S/4HANA Cloud.