In this blog, I am going to explain what is value-mapping, importance and how to implement it.?
Value Mapping in SAP CPI is a critical feature that enables seamless and consistent data transformation between disparate systems in an integration landscape.
- In integration scenarios, you frequently encounter scenarios where a "country code" might be "US" in one system (source), "USA" in another (target).
- Similarly, "material type" could be "ROH" in SAP ERP and "Raw Material" in a manufacturing execution system.
Without a centralized mapping, data becomes inconsistent, leading to errors, incorrect reporting, and operational inefficiencies.
Various features of Value-Mapping:
- Centralized Management and Governance: Value Mappings are stored as separate artifacts within integration packages, providing a structured way to manage and govern conversion rules. This centralization aids in documentation, auditing, and ensuring adherence to enterprise-wide data standards.
- Improved Maintainability and Agility: Value Mappings allow for dynamic updates without necessarily changing the iFlow's core logic. Business users or functional consultants (with appropriate access) can often manage these mappings directly in the CPI tenant, empowering them to react quickly to changes without requiring full developer involvement for every minor adjustment.
- Enhanced Reusability: Value Mappings are reusable artifacts. Once defined, they can be used across any message mapping within the same integration package, promoting consistency and reducing development effort. If a value changes (e.g., a new country code is introduced), you only need to update the Value Mapping artifact once, and all dependent iFlows automatically inherit the change upon deployment.
- Bidirectional Mapping: Value Mapping in CPI supports bidirectional lookups. This means you can not only map from a source value to a target value but also, if needed, reverse the lookup from the target value back to its original source value, which can be useful in certain integration scenarios or for reconciliation purposes.
First, create Value-Mapping
Under Package<sample> > Artifacts >Add>Value Mapping
Then, save and deploy it.
Create a simple iflow ...
Under Message Mapping, specify source meta data and target meta data, here I used same meta data.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="emprecords">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="emprecord">
<xs:complexType>
<xs:sequence>
<xs:element name="empid" type="xs:unsignedShort" />
<xs:element name="emplname" type="xs:string" />
<xs:element name="empfname" type="xs:string" />
<xs:element name="empage" type="xs:unsignedByte" />
<xs:element name="emporigin" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
On Failure is essential when there is no incoming field is available.
Where you can select ...below options based on your required.
- Use Key,
- Use Default value
- Throw exception
Now, test the iflow with below given input and you will get given output.
Input Data/Payload:
<?xml version="1.0"?>
<emprecords>
<emprecord>
<empid>4001</empid>
<emplname>Paul</emplname>
<empfname>David</empfname>
<empage>20</empage>
<emporigin>INDIA</emporigin>
</emprecord>
<emprecord>
<empid>4002</empid>
<emplname>PP</emplname>
<empfname>Ramesh</empfname>
<empage>20</empage>
<emporigin>Germany</emporigin>
</emprecord>
<emprecord>
<empid>4003</empid>
<emplname>DD</emplname>
<empfname>Kiran</empfname>
<empage>20</empage>
<emporigin>United States</emporigin>
</emprecord>
<emprecord>
<empid>4004</empid>
<emplname>DD</emplname>
<empfname>Desh</empfname>
<empage>20</empage>
<emporigin>India</emporigin>
</emprecord>
<emprecord>
<empid>4005</empid>
<emplname>DD</emplname>
<empfname>Raju</empfname>
<empage>20</empage>
<emporigin>Swiss</emporigin>
</emprecord>
<emprecord>
<empid>4006</empid>
<emplname>DD</emplname>
<empfname>Pavan</empfname>
<empage>20</empage>
<emporigin>Brazil</emporigin>
</emprecord>
</emprecords>
Output Data/Payload:
<?xml version="1.0" encoding="UTF-8"?>
<emprecords>
<emprecord>
<empid>4001</empid>
<emplname>Paul</emplname>
<empfname>David</empfname>
<empage>20</empage>
<emporigin>IN</emporigin>
</emprecord>
<emprecord>
<empid>4002</empid>
<emplname>PP</emplname>
<empfname>Ramesh</empfname>
<empage>20</empage>
<emporigin>GM</emporigin>
</emprecord>
<emprecord>
<empid>4003</empid>
<emplname>DD</emplname>
<empfname>Kiran</empfname>
<empage>20</empage>
<emporigin>-NA-</emporigin>
</emprecord>
<emprecord>
<empid>4004</empid>
<emplname>DD</emplname>
<empfname>Desh</empfname>
<empage>20</empage>
<emporigin>IN</emporigin>
</emprecord>
<emprecord>
<empid>4005</empid>
<emplname>DD</emplname>
<empfname>Raju</empfname>
<empage>20</empage>
<emporigin>-NA-</emporigin>
</emprecord>
<emprecord>
<empid>4006</empid>
<emplname>DD</emplname>
<empfname>Pavan</empfname>
<empage>20</empage>
<emporigin>BLR</emporigin>
</emprecord>
</emprecords>
Sample Output:
Under Conversions> Fix Values or Value Mapping
Thanks for reading :-)
No comments:
Post a Comment