Value Mapping
Value Mapping
Common iflow; for every idoc ki ade RFT port vadutamu ade RFC destination vadutamu sap soide cpi lo
ki ragane using value mapping if idoc is Matmas it should go to this receiver if its orders it should to to
different receiver ani value mapping to we put conditions we didentify the receiver based on source
agency ..target agency..idoc type .. messge type we are routing messages
Value Mapping in sap cpi is a method used to maintain a relationship between different values
representing the same data objects across various systems ..technically it acts as a birectional lookup
table allowing for consistent data transformation during integration process
Value Mapping is used when there is a need for data consistency and integrity across different systems it
is particulary useful in scenarios where data needs to be adapted to specific business rules or when
dealing with large data sets
Suppose in source the Country code has INDIA but in the target we need to have Country code as IN
Default value :
Value Mapping:
Fixed values - specific to this iflow ..limited values .. we are using values at mapping level ..
Value Mapping : can be used Across the iflows ..Value Mapping table we are maintaining
outside of mapping..if there are n number of values ..
In Value Mapping table if values are frequently changing and its used across 10 iflows ..it will replicate
automatically..you don’t need to change in every iflow
In SAP Cloud Platform Integration (CPI), value mappings are used to convert values from one format or
representation to another. They play a crucial role in data transformation during integration scenarios.
Value mappings are typically employed when you need to map values between different systems or
applications that use different code sets, naming conventions, or data formats.
Error Handling:
Implement error handling mechanisms in your integration flow to manage issues related to value
mappings.
This can include logging, alerting, and reprocessing strategies.
Example:
Let's say you have a scenario where a source system sends a country code, and you need to map it to
the corresponding country name. You would define a value mapping with entries like:
Then, in your integration flow, when mapping data, you reference this value mapping to convert country
codes to country names.
Difference
Fixed Value Mapping: Fixed Value is very useful when you have lots of conditions coming in one source
fields during mapping, then to avoid the IfThenElse or UDF we go for Fixed Value mapping.
Example: if your source field contains 01 or 02 or 03 or.....12 and you want the result as JAN or FEB or
MAR or ......... DEC.
Advantage: Using fixed value table you can see the result immediately in the mapping.
Disadvantage: If you have used the same fixed value mapping at several places in you mapping then in
case of any change in fixed values you have to make the changes at several places. So in short fixed
value mapping is not good from the maintenance point of view.
Value Mapping: Value Mapping also works in the same way as fixed value mapping, only the thing is you
will get the result at run time only. And you have to define the value mapping in Integration directory.
Advantage: If you have used the same value mapping at several places in you mapping then in case of
any changes in values you don't have to make the changes in you mapping, just make the changes in in
value mapping in Integration Directory, that's it.
Disadvantage: you can't the see the result immediately in mapping. Results can be seen only at run time.
Fix values: Fix values table will be created internally in IR, and define values for field mapping.this
function generally used for fixed value transfermations during message mapping based on key values.
Value mapping: Value mapping table wil be created in ID and maintain values in value mapping table for
value transfermations during message mapping.
You use the value mapping function to map different representations of an object to each other. You
save the mapping rules for different objects in a value mapping table.
Example:
Fix value function is used when your source field may contain certain set of values for which you want to
produce values at target.
for example,
Source Target
IND 001
AUS 002
GER 008
For above mapping between source and target you can write fix value function,and in fix value function
you specify source value as key
The main difference between fix values and value mapping is:
1. Fix value deals with defining mapping table at design time that is in IR whereas for value mappingyou
need to specify this mapping table in ID.
2. Value mapping can be reused by specifying same party and agency but this is not the case with fix
values.
There is a solution to do it using the function "Fix Value Mapping" in Message Mapping. But the issue is
this is very time consuming and may cause the errors when we add more data. Here Value Mapping
comes into play, where we can add directly the data with their identifiers and directly call the Value
Mapping saved in Message Mapping.
Do you have a lot of fix value mappings to complete but are too lazy to enter as much data? Value
mapping is the method of choice! It is simple, efficient, trustworthy, and—believe me—the delight of
the lazy.
Let us now look how we can do this.
1. Go to your Integration package -> Artifact tab. Click on Add -> Value Mapping.
2. Select the Create radio button and click on Ok.
1. Open the Excel sheet and create the Table using the Delimiter, Source, and Target values.
3. Here the each colour represent the different elements of the Value Mapping.
4. Save the excel sheet as the .csv file. While saving the file, Go to Tools option.
5. Under the Encoding tab, select the Unicode (UTF-8), and save the file.
6. Open the Integration Package in the Cloud Integration and create the new Value Mapping File.
7. Click on Import in newly created value mapping.
Step 2 : Select Create Radio Button and Give a valid Name. (This step is sap cpi namespace )
A 1
B 2
C 3
Step 10 : Open the Integration Flow in edit Mode. Add a Message Mapping and a Content Modifier.
Choose Sender Adapter as SOAP.
Step 11 : Select SOAP Adapter. Under Connection tab, Give a relative address to define the Endpoint.
(/Mapping)
Step 12 : Select Message Mapping and Click on Create button highlighted below.
Step 13 : Give any Valid name for your Mapping. Click on Create.
Step 18 : Click on Source Element and drag to the target element to map respective fields. Now it will
look as below.
Step 21 : Place the Value Mapping block in center and Connect Source to input , valueMapping to
Target as shown in the below picture.
Step 22 : Click on Advanced and fill the required details same as the deployed Value Mapping in Step
7.
On Failure :
Expected Outcomes when the incoming Message has any other
value apart from the once maintained in the Value Mapping Used
On Failure ( in our case any value other than A, B , C)
Use Default It will pass the Default Value that is specified in the Default Value
Value field.
Throw
Exception This will throw an exception.
Step 23 : Click on OK at top right corner. It will redirect you to the Main Integration Flow.
Step 24 : You can edit your mapping any time from Processing tab of Message Mapping.
Step 25 : Select the Content Modifier. Under Message Body tab, choose Type=Expression and Body :
${in.body} to capture the incoming payload.
Step 26 : Save and Deploy.
Step 27 : In overview window, make sure that your flow is in Started state. Click on Copy
button highlighted under Endpoints tab to Copy the Endpoint.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:demo="http://cpi.sap.com/demo">
<soapenv:Header/>
<soapenv:Body>
<demo:Order_MT>
<orderNumber>A</orderNumber>
<Environment>CS</Environment>
</demo:Order_MT>
</soapenv:Body>
</soapenv:Envelope>
Step 30 : You will get back the result as below. Note that the OrderNumber is changed from A to 1 in
output. This is due to the use of Value Mapping.
Step 31 : Change orderNumber to B and C and click on Send. You should get the response
as 2 and 3 respectively.
Step 32 : Change the orderNumber to any random value. Say 45. Click on Send. You will get back
the same value 45. This is because we have used “Use Key” in On Failure field at Step 22.
Step 4: Choose the Upload Radio button. Give a New Name for your Value Mapping
Artifact. Browse and select the Previously Downloaded Zip file.
Step 5: Click on OK.
Step 6: you will get the following error. This is because the Downloaded Value Mapping Artifact is
already present in the tenant and Again you can’t upload the Artifact with the same name. Even
though you are giving a new name while uploading, the files in zip will still have the previous VM
name. This Name has to be changed.
Step 10:Change the SymbolicName from VM_Import to New_VM ( or any other custom
name ). Save the file.
Step 11: Select all the items and compress them to a new folder. DO NOT Compress the Parent folder.
It will lead to errors.
Step 14: Check the upload radio button. Give a valid name. Browse and select the newly zipped
folder as in Step 12. Click on OK.
Step 16: Since we are uploading the new Value Mapping in the same tenant as that Downloaded in
this demo, both Value Mapping Artifacts will have the same Agency Name. This is not allowed.
Therefore, Undeploy your previously Downloaded Value Mapping Artifact (VM_Import).
If the download and Upload Tenants are different, then no need for Un deploying.
Step 17: Open the Newly created Value Mapping and Verify the content. Deploy.