<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using globalMap into file output name in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Using-globalMap-into-file-output-name/m-p/2353584#M119741</link>
    <description>&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;Move tJava to be the first component before tFileInputDelimited, eg:&lt;/P&gt;&lt;P&gt;tFileList--iterate--tJava--oncomponentOK--tFileInputDelimited.......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please try and let me know if it works. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Shong&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jul 2023 05:25:31 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-07-18T05:25:31Z</dc:date>
    <item>
      <title>Using globalMap into file output name</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Using-globalMap-into-file-output-name/m-p/2353583#M119740</link>
      <description>&lt;P&gt;Dear Community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm new with talend and appreciate you could help me on this. I want to extract files from .csv and output as .csv with custom name variable. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000kYhjfAAC.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/153487i759F3558215BAC9B/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000kYhjfAAC.png" alt="0695b00000kYhjfAAC.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The file name output is depending on the input file. For example the input file is file_1_2011. The output file should be file_1_20201130. The date should be the last date of the month. On tjava i have create a script for this. I use globalMap.put to assign the final file name and call it in tFileOutputDelimited. The issue now is the first file name comes out great however the second file become null. As below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000kYhkEAAS.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/151452i477A9B1E42DB24E6/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000kYhkEAAS.png" alt="0695b00000kYhkEAAS.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I try to print out the globalMap and it display the correct value:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000kYhkOAAS.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/157329i2233397EB3CF10B3/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000kYhkOAAS.png" alt="0695b00000kYhkOAAS.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please find my tjava code as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;System.out.println("Processing file: "+ ((String)globalMap.get("tFileList_1_CURRENT_FILE")));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;String file_process = ((String)globalMap.get("tFileList_1_CURRENT_FILE"));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;String file_process_F = file_process.substring(0, 23);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;String file_date = file_process.substring(23, 27);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;String year = StringHandling.LEFT(file_date, 2);&lt;/P&gt;&lt;P&gt;String month = StringHandling.RIGHT(file_date, 2);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;String year_F;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (year.contains("20")){&lt;/P&gt;&lt;P&gt;	year_F = "2020";&lt;/P&gt;&lt;P&gt;}else if (year.contains("21")){&lt;/P&gt;&lt;P&gt;	year_F = "2021";&lt;/P&gt;&lt;P&gt;}else {&lt;/P&gt;&lt;P&gt;	year_F = "00";&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;String testDate = year_F + "/" + month + "/" + "01";&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date test = TalendDate.getLastDayOfMonth(TalendDate.parseDate("yyyy/MM/dd", testDate));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;String FinalDate = TalendDate.formatDate("yyyyMMdd", test) + ".csv";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;String Output = file_process_F + FinalDate;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;globalMap.put("Output", Output);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;System.out.println(((String)globalMap.get("Output")));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry if my scripting is bad. Appreciate if anyone can help &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 21:34:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Using-globalMap-into-file-output-name/m-p/2353583#M119740</guid>
      <dc:creator>ZulFast</dc:creator>
      <dc:date>2024-11-15T21:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using globalMap into file output name</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Using-globalMap-into-file-output-name/m-p/2353584#M119741</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;Move tJava to be the first component before tFileInputDelimited, eg:&lt;/P&gt;&lt;P&gt;tFileList--iterate--tJava--oncomponentOK--tFileInputDelimited.......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please try and let me know if it works. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Shong&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 05:25:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Using-globalMap-into-file-output-name/m-p/2353584#M119741</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-07-18T05:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using globalMap into file output name</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Using-globalMap-into-file-output-name/m-p/2353585#M119742</link>
      <description>&lt;P&gt;Works like a charm. Thank you sir. I wonder why the flow should be this way&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 05:44:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Using-globalMap-into-file-output-name/m-p/2353585#M119742</guid>
      <dc:creator>ZulFast</dc:creator>
      <dc:date>2023-07-18T05:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using globalMap into file output name</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Using-globalMap-into-file-output-name/m-p/2353586#M119743</link>
      <description>&lt;P&gt;The variable should be initialized before it is used. If tJava component is in another iterate flow, there is no guarantee that it will be executed before tFileOutputDelimited.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 09:14:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Using-globalMap-into-file-output-name/m-p/2353586#M119743</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-07-18T09:14:23Z</dc:date>
    </item>
  </channel>
</rss>

