Tuesday 27 March 2018

Strange !!! Mapping Variable Value Taking Persistent value from Repository

Today we are going to discuss behavior of mapping variables persistent values.Most of experienced informatica developers have used the concept of assigning mapping variable value to workflow variable using post session variable assignment feature.Passing mapping variables  is quite handy in many scenarios where you want to perform some action on basis of value passed from mapping i.e. you might to send an email or start another session.

Normally it is done in below way 
  1. Define a Mapping variable 
  2. Assign value to variable using setvar functions
  3. Pass value to workflow parameter is using postsession variable assignementAll is good till we encounter error VAR_27049 : Mapping variable name: [$$MAP_VAR], persisted value: [9], run instance name []. 

Most of us are confused about this issue and try different way to overcome this by assigning value on parameter file etc.
Mapping variables are different from normal programming language variables as they have below features
  1. Mapping variables have an aggregation set, which is either Maximum or Minimum. (See Informatica Designer >Mappings > Parameters and Variables).
  2. Mapping variables are assigned to a variety of values during the session run; the final value of the variable is either the maximum or the minimum of the values. 
  3. In the related mapping, if the aggregation is set to Max, the final value is the maximum value. That means that if the value given in the parameter file is lower than the value already in the repository, it will be ignored. 
Below example will make it more clear
Consider that in the we are using max type of variable , the value is *1000* for the VAR1 mapping variable. 
2018-02-23 18:02:59 : INFO : (6615 | DIRECTOR) : (IS | myinteg_IS) : node01 : TM_6962 : The variable [$$WFVAR1] will be assigned from [$$VAR1] 
2018-02-23 18:02:59 : INFO : (6615 | DIRECTOR) : (IS | myinteg_IS) : node01 : VAR_27048 : Persisting mapping variable values to the repository. 
2018-02-23 18:02:59 : INFO : (6615 | DIRECTOR) : (IS | myinteg_IS) : node01 : VAR_27049 : Mapping variable name: [$$VAR1], persisted value: [1000], run instance name []. 

If mapping variable comes out greater than 1000 in mapping then it will work fine.But if Value  comes less than 1000, it keeps the persistent value and only gets reset if the Parameter file value is Reset via Workflow Manager. 
You can reset mapping variable in the Workflow session gets "reset" (right-click the Session task and select View Persistent Values. Click Reset Values to delete existing variable values),This is a manual step and not feasible with automated runs.
Solution :Apparently there is no direct solution to avoid this,you might need to design your mapping in such a way that it gets value more than value saved in repository (or less in case of aggregation type defined as minimum),You can try to prefix it with running number