Using mapping variables in a post-session command - informatica

Workflow generates three files (header, detail, trailer) which I combine via post-session command. There are two variables which are set in my mapping, which I want to use in the post-session command like so:
cat header1.out detail1.out trailer1.out > OUTPUT_$(date +%Y%m%d)_$$VAR1_$$VAR2.dat
But this doesn't work and the values are empty, so I get OUTPUT_20151117__.dat.
I've tried creating workflow variables and assigning them via pre-session variable assignment, but this doesn't work either.
What am I missing? Or was this never going to work?

Can you see the values assigned to those variables on the session log or do they appear empty as well?

Creating workflow variables is what I'd try, but you need to assign the values with the post-session variable assignment.

Basically, you store values in a variable in your mapping and pass the values up to the workflow after the session succeeded. Here is how you can achieve that:
Define a Workflow variables $$VAR1 and $$VAR2
Define the variables in your mapping, but chose different names! So i.e. $$M_VAR1 and $$M_VAR2
In your mapping, assign the values to your mapping variables through the functions SetVariable(var as char, value as data type)
In your session, select Post-session on success variable assignment.
In step 4, the current value from $$M_VAR1 (mapping variable) is stored in your workflow variable $$VAR1 and can then be used in the workflow in command tasks like you asked.
A few notes:
I'm not 100% sure if the variable assignment is exectured before the post-session command. If the command is executed first, you could execute your command tasks in an external command task after your session.
Pre-Session variable assignment is used if you pass a value from a workflow variable down to a mapping variable. You can use this if your variables $$VAR1 or $$VAR2 are used inside another mapping and need to be initialized at the beginning.

Related

Postman, Set on evraibale for "run session"

I know that we can set a variable in different scopes via a pre-request script, but can we set one for on "execution" or "run of test".
I have a folder that contains two requests to validate a scenario where the first one will create a resource with an unique id and the second one will fail by trying to create a resource with the same unique id.
I would like to generate that unique value each time the collection is run. At this time I use a collectionVariables to test and set when not present but that variable is kept between each "retry".
Can I create a variable that will be the same only for one execution of a collection ?
Thanks
I have similar cases, where I store the values in Environment variables and then unset them in the Pre-request script of the first request:
pm.environment.unset("myVariable");
So, my solution is the same as the one suggested by #so cal cheesehead.
I create a variable in either the folder pre-request or the first request script. And unset it after the last test in the last request.
The sad part is that the initialization and destruction of this variable is spread in different scripts.

How can I save value of dynamic variable in Postman?

Postman allows to generate random dummy data by using pre-defined variables, on example this one would be replaced by random company name:
{{$randomCompanyName}}
Using pre-defined variables multiple times return different values per request.
The question is how to save once generated value to the variable for further usage on example in tests, something like(it doesn't work):
pm.variables.set("company", {{$randomCompanyName}});
Thanks.
You can use the .replaceIn() function with that {{...}} syntax in the sandbox.
pm.globals.set("company", pm.variables.replaceIn('{{$randomCompanyName}}'));
I've used a global variable to store the value as you would want to use it again. You could also use either the environment or collectionVariables scope to do the same thing.

Using a Parameter in Expression Transformation

I have a workflow in which I've set up an expression transformation to select $$Param for a particular field, and then within the target properties I've set a delete value. I've tried this by substituting $$Param for a hardcoded value and it works fine, however, for some reason when I put in $$Param, it doesn't actually do the delete. Is there a reason? Am I doing something wrong?
Just for clarification, the workflow executes successfully - no error is thrown but it's not doing what it's supposed to.
Thanks in advance,
$$Param needs to be passed thru a parameter file and you have the option to set an initial value when you declare the parameter in the mapping under Mappings > Parameter and Variables.
Have you looked at the session log to see what's the override value of $$Param is being used? If it's a SQL delete, try to turn see in the session log the query being executed in the database.

Mapping variable is not set in Mapping

I am trying to realize some mappings as supposed in this answer. I created a mapping, which reads from a table in which a date for incremental load is stored. After that I set a mapping variable to pass this date value to the next mapping. In the Post-session on success variable assignment the mapping variable is stored in a workflow variable and passed to the next mapping.
Here is the mapping to read the date value and store it in the mapping variable. The value is stored in the variable in the expression, the port is an output, which is linked to a dummy target. This target simply writes it in a flat file.
The port expression is SETVARIABLE($$LOAD_FROM_DATE,LOAD_DATE).
My problem is that the value is read correctly, but it is not persisted in the mapping variable. It is always falling back on the date default value. Where is my mistake?
So you basically need to calculate a value from one mapping and use it in the second? If so, I have implemented something similar and it works fine for me. I have the port where I set variable (RESULT_LOAD in your case) value marked as a variable port. In the workflow you will be defining a variable to capture the variable value from mapping, mark it as persistent so that the value is stored in the repository after each run.

Set Mapping variable in Expression and use it in Source Filter

I have two tables in different databases. In a table A is the data, in the other table B are information for incremental load of the data from the first table. I want to load from table B and store the date of the last successful load from table A in a mapping variable $$LOAD_DATE. To achieve this, I read a date from table B and use the SETVARIABLE() function in a expression to set the $$LOAD_DATE variable. The port in which I do this is marked as output and writes into a dummy flat file. I only read on row of this source!
Then I use this $$LOAD_DATE variable in the Source Filter of the Source Qualifier of table A to only load new records which are younger than the date stored in the $$LOAD_DATE variable.
My problem is that I am not able to set the $$LOAD_DATE variable correctly. It is always the date 1753-1-1-00.00.00, which is the default value for mapping variables of the type date/time.
How do I solve this? How can I store a date in that variable and use it later in a Source Qualifiers source filter? Is it even possible?
EDIT: Table A has too much records to read them all and filter them later. This would be to expensive, so they have to be filtered at source filter level.
Yes, it's possible.
In the first map you have to initialize the variable, like this:
In first session configuration you have to define the Post-session on success variable assignment:
The second map (with your table A) will get the variable after this configuration of the session in Pre-session variable assignment:
It will work.
It is not possible to set a mapping variable and use it's value somewhere else in the same run, because, the variable is actually set when the session completes.
If you really want to implement it using mapping variables you have to create two mappings, one for setting the mapping variable and another for actual incremental load. You can pass a mapping variable value from one session to another in a workflow using a workflow variable. https://stackoverflow.com/a/26849639/2626813
Other solutions could be to use a lookup on B and a filter after that.
You can also write some scripts to query table B and modify the parameter file with the latest $LOAD_DATE value prior to executing the mapping.
Since we're having two different DBs, use two sessions. Get values in the first one and pass the parameters to the second one.