Sharing data between two message mappings through Dynamic Configuration
Here I would discuss the use of custom namespace & custom field in dynamic configuration to share data between two message mappings.I had created a message mapping between the DESADV.DELVRY07 IDoc & a target structure. For mapping of a certain target field, I had the condition of populating based on the value of a qualifier say if QUALF=006 then populate from NTANF. I cannot provide the actual target structure so I have created a sample structure while creating this blog. Here is what the logic was like:
However, in the next release of the project, for another market the requirement was to populate the target field with NTANF when QUALF had a different value say 007. Also I was asked to not to manipulate the above existing mapping which was being used for previous market. So I created a new operation mapping which would have two message mappings:
1. The existing mapping in which I populate target when QUALF=006
2. A new message mapping with target structure as source as well as target, in this one I would populate the target field when QUALF=007.
Now I had to send the value of NTANF when QUALF=007 to the second mapping, but this value was not being sent at all to the target field in the first mapping. So I had to share data between the two message mappings such that the value of a field in first mapping is available to the target field in the second mapping. I tried using Global variable but it did not work for me as it works within the same message mapping. So the solution was to use custom namespace in dynamic configuration.
Here is how the value of NTANF when QUALF = 007 was populated in a custom field in dynamic configuration:
1. A UDF created as shown below whose input will be the value of NTANF when QUALF =007:
2. Now the required value is being populated in this custom field as shown below. The local variable ‘var1’ to which the output of the UDF is mapped to is not being used anywhere in the mapping.
3. Now in the second mapping I am retrieving the value from this custom field from another UDF as shown below. Note that the name of custom field & custom namespace given in UDF are exactly the same as in the UDF in first message mapping.
4. The field into which NTANF corresponding to QUALF=007 is to be populated is mapped from the UDF as shown below:
5. Now the two mappings are added into operation mapping as shown below.
6. Now here I am testing it in the Operation mapping level. For QUALF=006 I have NTANF as 20130702 while for QUALF=007, I have NTANF as 20130709:
7. When I execute from Step1 to Step 1 i.e first message mapping, I get value of NTANF corresponding to QUALF =006:
8. When I tested from Step1 to Step2 i.e both mappings are executed one after the other, I got the value of NTANF corresponding to QUALF=007:
Thus I was able to share data between two message mapping using dynamic configuration.
Nice Blog Adarsh...
How do we read more than one value in the udf?
Is it requirement such that you want to pass values of more than one field? Then you can create another UDF with another custom namespace & fetch values from that namespace in second mapping. Notice the namespace in the UDF is a custom one & you can create another one for second field.
Yes. I want to pass values of 5 fields from one mapping to another. So does that mean that I need to create 5 UDF's?
Not necessarily. You can concatenate the values before passing into the UDF & while retrieving the values, you can do a substring.
Nice Work .. & can we pass the array also?
This is nice blog however I want to pass that variable value across two mapping.
But those two mapping will not be used in same operation mapping.
I want to share data in two mapping and and across two operation mapping as well.
Is there any alternative approach ?