Context Variable to tMap in Talend OS

Table of contents

No heading

No headings in the article.

I have encountered a use case, in which I do not have any input rows and need to

  • read the value of a context variable

  • then apply some Java code to that value

  • and produce output to tMap component.

I have followed the following steps to do so.

  1. Create a new Job in Talend and add a tJavaFlex component to it.

  2. In the tJavaFlex component, use the context.your_variable_name to load the context variable.

  3. Write your Java code in the 'Main Code' section of the tJavaFlex component.

  4. Use the globalMap.put("output_variable_name",your_value) method to store the output data in the globalMap.

  5. Connect the tJavaFlex component to the tMap component using a Row > Main connection.

  6. In tMap component, use the ((String)globalMap.get("output_variable_name")) to get the data from the globalMap

  7. Run the job and check the results.

Note: Make sure that your context variable is defined and has a value before running the job.

Happy Learning !