Six Stars

Data Mapper, use of SetVariable function

What is best practice on where to use the SetVariable input?  For every record of the input, we have an HL7 output where we want to put the current date and time (yyyyMMdd_hhmmss), however we want this timestamp to be the same for all records of the input set being sent for the current run.  So in other words, we can't have the minutes and seconds change for each record of current run.

 

Do we just put the SetVariable function in a Value tab of some output we aren't using?  Should we put it in the Util tab or some other area?

 

We need it to set the variable just once.  The root of our output is a Simple Loop that matches the input root for each record.

1 ACCEPTED SOLUTION

Accepted Solutions
Eight Stars

Re: Data Mapper, use of SetVariable function

Hi,

 

1-Yes you can use a setvariable function on root element:

Capture.PNG

And then use it inside the loop:

Capture.PNG

2-You can use system variables:

In you job you use a tSetEnv component:

Capture.PNG

Then you can get it in your map:

 

Capture.PNG

 

3-I don't know if it is possible to get globalmap variables inside TDM...

 

Eric

7 REPLIES
Eight Stars

Re: Data Mapper, use of SetVariable function

Hi,

 

You could just update a context variable in your job with this timestamp and then use this context variable in your map ?

 

Eric

Six Stars

Re: Data Mapper, use of SetVariable function

We could be we wanted to avoid creating a context variable just for this if possible.  If there is a way to reference a GlobalMap variable, it would be feasible however.

Five Stars

Re: Data Mapper, use of SetVariable function

You can very well use a global variable that will be available for any component within the current job. You can set it using tSetVar component (or u can also do this within tJava) and access it using globalMap.get("<var_name>")

Six Stars

Re: Data Mapper, use of SetVariable function

Is globalMap available in the Data Mapper though?  I have not been successful in referring to that globalMap object within TDM.

Five Stars

Re: Data Mapper, use of SetVariable function

Ah..Its the TDM. Did not notice that. I have no experience with TDM but I presume that it must be there in that too. Just note that standard jobs are different from Big data jobs. I presume TDM supports big data jobs (I might be off base here). If your job is a Big data job, then you would not have this. Can you confirm if this is a Standard job?

 

Maybe if you can share screenshot of your job design, I might be able to understand it.

Eight Stars

Re: Data Mapper, use of SetVariable function

Hi,

 

1-Yes you can use a setvariable function on root element:

Capture.PNG

And then use it inside the loop:

Capture.PNG

2-You can use system variables:

In you job you use a tSetEnv component:

Capture.PNG

Then you can get it in your map:

 

Capture.PNG

 

3-I don't know if it is possible to get globalmap variables inside TDM...

 

Eric

Six Stars

Re: Data Mapper, use of SetVariable function

Hi eric, sorry for the delayed response and thank you very much for the detailed reply with options, both of which will work for us. You're hired!