0% found this document useful (0 votes)
294 views

Value Mapping

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
294 views

Value Mapping

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Value Mapping

Real time use case: in CPI we will create two flows

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

 IDOC Sender -> CPI valuMapping ->Processdirect


 Process Direct sap cpi to Actual receiver(SFTP/REST API)

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

When do you use value Mapping :

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

Examples of value Mapping Sceanrios:

 Business Partner Translations: translating different business partners


 Country Code Mapping-converting country codes to country names
 Currency Code Mapping-Converting currency codes to currency names.

Suppose in source the Country code has INDIA but in the target we need to have Country code as IN

For that we are Conversions ->ValueMapping


If you use USE key ..if you get any other value apart from what you provided in Advance what ever
value you are receiving from source will be sent to target

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.

Here's a brief overview of how value mappings work in SAP CPI:

Define Value Mapping in SAP CPI:


In SAP CPI, you can define value mappings in the Integration Directory.
Go to the Design tab in the SAP CPI Cockpit and select the Integration Directory.
Create a new Value Mapping or select an existing one.
Create Value Mapping Entries:
Once you have a value mapping, you need to define the actual mappings between source and target
values.
For each value mapping, you can create entries that specify the source and target values along with any
necessary details or transformations.

Use Value Mapping in Message Mapping:


When designing your integration flow, you can use the value mapping in the message mapping step.
In the message mapping, you can reference the value mapping to perform value conversions.

Configuring Value Mapping in Integration Flow:


Within the Integration Flow, you'll configure the value mapping to be used.
This typically involves specifying the source and target contexts and associating the value mapping you
created.

Testing and Monitoring:


It's important to test your integration flow thoroughly to ensure that the value mappings are working as
expected.
The SAP CPI monitoring features allow you to track and analyze the execution of your integration flows,
including the value mapping steps.

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:

Source: "US" -> Target: "United States"


Source: "CA" -> Target: "Canada"
Source: "DE" -> Target: "Germany"

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,

Country(Alphabetic) Country(Numeric code)

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

and value as target in the table

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.

Create SAP CPI Value Mapping


Let us suppose there are too much data that need to value mapped from source to target in message
mapping, for example, there is data at the source side which needs to mapped at the target side as
shown below.

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.

3. Click on the new Value Mapping Created.


4. Click on the Edit button and then click on Add button.
5. Provide the Agency and Identifier for both the sender and the receiver side. Once the data has
been provided, Add the Values, to add more click on Add ,and continue adding your values.
6. Save and Deploy the Value Mapping.

Now, this is ready to use in the Message Mapping

Step-by-Step Guide: Importing Value Mapping in SAP Cloud Integration

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.

8. Select the csv file and upload the file.


9. The file will upload as shown below.
Its not possible to link iflows from manage integration artifact tile of Monitoring perspective. But you
can leverage correlation id in message monitoring which list down all related messages ( called from
main flow to multiple flows connected via process direct adapter )

CREATING SAP CPI VALUE MAPPING


Step 1 : Go to Artifacts tab of your Package. Add –> Value Mapping, This will add sap cpi value
mapping.

Step 2 : Select Create Radio Button and Give a valid Name. (This step is sap cpi namespace )

Step 3 : Click on the new Value Mapping Created.

Step 4 : Click on edit


Step 5 : Click on Add.

Step 6 : Fill the required details and Conversion Values.


Sourc Targ
e et

A 1

B 2

C 3

Step 7 : Save and Deploy.


Step 8 : In Overview Window, Make sure that the Value Mapping is started.

CREATING INTEGRATION FLOW


Step 9 : Go to Design Window and Create an Integration Flow under Artifacts.

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 14 : Click on Add Source Message.


Step 17 : It will look as below.

Step 18 : Click on Source Element and drag to the target element to map respective fields. Now it will
look as below.

Step 19 : Click on fx Symbol to edit the mapping for that element.


Step 20 : From the left window, choose Conversions –> Value Mapping

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 Key It will pass the incoming value as it is.

Use Default It will pass the Default Value that is specified in the Default Value
Value field.
Throw
Exception This will throw an exception.

I have used Use Key.

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.

TESTING THE ARTIFACTS


Step 28 : Open POSTMAN. Create a new request with type POST.
Paste the Endpoint copied in previous step in URL tab.
Type : Basic Auth
Username : Client ID
Password : Client Secret
Client Id and Client Secret you will get when you create Process Integration Runtime Instance during
tenant setup. ( Refer Step 34 of this post )
Step 29 : Under Body tab, Choose Raw radio button and XML message Type. Type the below input
message. Click on Send.

<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.

Uploading a Value Mapping in SAP CPI

DOWNLOADING A VALUE MAP


Step 1: Go to your Package where you have already created a Value Mapping Artifact.
Step 2: Click on the Actions button of your Value Mapping Artifact and select Download. This will
Download a Zip File.

UPLOADING A VALUE MAP


Step 3: Go to the Package where you want to Upload the Value Mapping. Under the Artifacts tab,
Click on Add –> Value Mapping.

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.

RECTIFYING THE ERROR


Step 7: Extract the Downloaded Zip File.
Step 8: Open the Folder –> META-INF folder.

Step 9: Open the MANIFEST file in word.

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 12: It should look as below.


Step 13: Go back to your Package. Under artifacts, Add –> Value Mapping.

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 15: That’s it!. Your Value Mapping will be created.

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.

Step 18: Use the artifact in Message Mapping.


U

You might also like