<?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: [resolved] New to Pass row1 directly to routine without using dynamic schema in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-New-to-Pass-row1-directly-to-routine-without-using/m-p/2309295#M80523</link>
    <description>I followed the steps . Now, it is working for me. Thanks a lot Richard Hall.</description>
    <pubDate>Sun, 08 May 2016 04:31:18 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-05-08T04:31:18Z</dc:date>
    <item>
      <title>[resolved] New to Pass row1 directly to routine without using dynamic schema</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-New-to-Pass-row1-directly-to-routine-without-using/m-p/2309293#M80521</link>
      <description>I have a business scenario like, reading data from source and pass it as a whole(row1 connector name) to a routine and extract data data from the row1 inside routine without using dynamic schema feature of talend.&amp;nbsp;&lt;BR /&gt;I have created a job where where I am reading data from tRowGenerator , then pass it to tJava . In tJava, I am printing row1. I am not able to display the value of row1. It is displayed as an object. Please help on this.</description>
      <pubDate>Sat, 07 May 2016 11:58:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-New-to-Pass-row1-directly-to-routine-without-using/m-p/2309293#M80521</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-05-07T11:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] New to Pass row1 directly to routine without using dynamic schema</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-New-to-Pass-row1-directly-to-routine-without-using/m-p/2309294#M80522</link>
      <description>Ok, you can do what you want, but I don't see why you would want to. However, I like a challenge and I guess you must have a reason, so here is how you do it. You will have to excuse my bad example, but hopefully it will give you enough info. I have created a job that you can see below.... 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009ME5V.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/146316iB3D108B9AEA73E84/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009ME5V.png" alt="0683p000009ME5V.png" /&gt;&lt;/span&gt; 
&lt;BR /&gt;A tRowGenerator and a tJavaFlex. The tRowGenerator is connected to a row called "row1". Talend generates code from you configuration of its components. So we need to take a look at the code. For this, I am going to the Code tab. Here is the code for the class created for "row1".... 
&lt;BR /&gt; 
&lt;PRE&gt;	public static class row1Struct implements&lt;BR /&gt;			routines.system.IPersistableRow&amp;lt;row1Struct&amp;gt; {&lt;BR /&gt;		final static byte[] commonByteArrayLock_LOCAL_PROJECT_Test = new byte;&lt;BR /&gt;		static byte[] commonByteArray_LOCAL_PROJECT_Test = new byte;&lt;BR /&gt;		public String newColumn;&lt;BR /&gt;		public String getNewColumn() {&lt;BR /&gt;			return this.newColumn;&lt;BR /&gt;		}&lt;BR /&gt;		public String newColumn1;&lt;BR /&gt;		public String getNewColumn1() {&lt;BR /&gt;			return this.newColumn1;&lt;BR /&gt;		}&lt;BR /&gt;		public String newColumn2;&lt;BR /&gt;		public String getNewColumn2() {&lt;BR /&gt;			return this.newColumn2;&lt;BR /&gt;		}&lt;BR /&gt;		public String newColumn3;&lt;BR /&gt;		public String getNewColumn3() {&lt;BR /&gt;			return this.newColumn3;&lt;BR /&gt;		}&lt;BR /&gt;		public String newColumn4;&lt;BR /&gt;		public String getNewColumn4() {&lt;BR /&gt;			return this.newColumn4;&lt;BR /&gt;		}&lt;BR /&gt;		private String readString(ObjectInputStream dis) throws IOException {&lt;BR /&gt;			String strReturn = null;&lt;BR /&gt;			int length = 0;&lt;BR /&gt;			length = dis.readInt();&lt;BR /&gt;			if (length == -1) {&lt;BR /&gt;				strReturn = null;&lt;BR /&gt;			} else {&lt;BR /&gt;				if (length &amp;gt; commonByteArray_LOCAL_PROJECT_Test.length) {&lt;BR /&gt;					if (length &amp;lt; 1024&lt;BR /&gt;							&amp;amp;&amp;amp; commonByteArray_LOCAL_PROJECT_Test.length == 0) {&lt;BR /&gt;						commonByteArray_LOCAL_PROJECT_Test = new byte;&lt;BR /&gt;					} else {&lt;BR /&gt;						commonByteArray_LOCAL_PROJECT_Test = new byte;&lt;BR /&gt;					}&lt;BR /&gt;				}&lt;BR /&gt;				dis.readFully(commonByteArray_LOCAL_PROJECT_Test, 0, length);&lt;BR /&gt;				strReturn = new String(commonByteArray_LOCAL_PROJECT_Test, 0,&lt;BR /&gt;						length, utf8Charset);&lt;BR /&gt;			}&lt;BR /&gt;			return strReturn;&lt;BR /&gt;		}&lt;BR /&gt;		private void writeString(String str, ObjectOutputStream dos)&lt;BR /&gt;				throws IOException {&lt;BR /&gt;			if (str == null) {&lt;BR /&gt;				dos.writeInt(-1);&lt;BR /&gt;			} else {&lt;BR /&gt;				byte[] byteArray = str.getBytes(utf8Charset);&lt;BR /&gt;				dos.writeInt(byteArray.length);&lt;BR /&gt;				dos.write(byteArray);&lt;BR /&gt;			}&lt;BR /&gt;		}&lt;BR /&gt;		public void readData(ObjectInputStream dis) {&lt;BR /&gt;			synchronized (commonByteArrayLock_LOCAL_PROJECT_Test) {&lt;BR /&gt;				try {&lt;BR /&gt;					int length = 0;&lt;BR /&gt;					this.newColumn = readString(dis);&lt;BR /&gt;					this.newColumn1 = readString(dis);&lt;BR /&gt;					this.newColumn2 = readString(dis);&lt;BR /&gt;					this.newColumn3 = readString(dis);&lt;BR /&gt;					this.newColumn4 = readString(dis);&lt;BR /&gt;				} catch (IOException e) {&lt;BR /&gt;					throw new RuntimeException(e);&lt;BR /&gt;				}&lt;BR /&gt;			}&lt;BR /&gt;		}&lt;BR /&gt;		public void writeData(ObjectOutputStream dos) {&lt;BR /&gt;			try {&lt;BR /&gt;				// String&lt;BR /&gt;				writeString(this.newColumn, dos);&lt;BR /&gt;				// String&lt;BR /&gt;				writeString(this.newColumn1, dos);&lt;BR /&gt;				// String&lt;BR /&gt;				writeString(this.newColumn2, dos);&lt;BR /&gt;				// String&lt;BR /&gt;				writeString(this.newColumn3, dos);&lt;BR /&gt;				// String&lt;BR /&gt;				writeString(this.newColumn4, dos);&lt;BR /&gt;			} catch (IOException e) {&lt;BR /&gt;				throw new RuntimeException(e);&lt;BR /&gt;			}&lt;BR /&gt;		}&lt;BR /&gt;		public String toString() {&lt;BR /&gt;			StringBuilder sb = new StringBuilder();&lt;BR /&gt;			sb.append(super.toString());&lt;BR /&gt;			sb.append("");&lt;BR /&gt;			return sb.toString();&lt;BR /&gt;		}&lt;BR /&gt;		/**&lt;BR /&gt;		 * Compare keys&lt;BR /&gt;		 */&lt;BR /&gt;		public int compareTo(row1Struct other) {&lt;BR /&gt;			int returnValue = -1;&lt;BR /&gt;			return returnValue;&lt;BR /&gt;		}&lt;BR /&gt;		private int checkNullsAndCompare(Object object1, Object object2) {&lt;BR /&gt;			int returnValue = 0;&lt;BR /&gt;			if (object1 instanceof Comparable &amp;amp;&amp;amp; object2 instanceof Comparable) {&lt;BR /&gt;				returnValue = ((Comparable) object1).compareTo(object2);&lt;BR /&gt;			} else if (object1 != null &amp;amp;&amp;amp; object2 != null) {&lt;BR /&gt;				returnValue = compareStrings(object1.toString(),&lt;BR /&gt;						object2.toString());&lt;BR /&gt;			} else if (object1 == null &amp;amp;&amp;amp; object2 != null) {&lt;BR /&gt;				returnValue = 1;&lt;BR /&gt;			} else if (object1 != null &amp;amp;&amp;amp; object2 == null) {&lt;BR /&gt;				returnValue = -1;&lt;BR /&gt;			} else {&lt;BR /&gt;				returnValue = 0;&lt;BR /&gt;			}&lt;BR /&gt;			return returnValue;&lt;BR /&gt;		}&lt;BR /&gt;		private int compareStrings(String string1, String string2) {&lt;BR /&gt;			return string1.compareTo(string2);&lt;BR /&gt;		}&lt;BR /&gt;	}&lt;BR /&gt;&lt;/PRE&gt; 
&lt;BR /&gt;I am assuming that you are proficient in Java, so won't explain this. But you can see that the class if public. Therefore we can use this.&amp;nbsp; 
&lt;BR /&gt;I next created a routine (it is very poorly named as I did this quickly). You can see that below..... 
&lt;BR /&gt; 
&lt;PRE&gt;package routines;&lt;BR /&gt;import local_project.test_0_1.Test.row1Struct;&lt;BR /&gt;/*&lt;BR /&gt; * user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but&lt;BR /&gt; * it must be before the "{talendTypes}" key.&lt;BR /&gt; * &lt;BR /&gt; * 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character,&lt;BR /&gt; * long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short |&lt;BR /&gt; * Short&lt;BR /&gt; * &lt;BR /&gt; * 3. {Category} define a category for the Function. it is required. its value is user-defined .&lt;BR /&gt; * &lt;BR /&gt; * 4. {param} 's format is: {param} &amp;lt;type&amp;gt; &amp;lt;name&amp;gt;&lt;BR /&gt; * &lt;BR /&gt; * &amp;lt;type&amp;gt; 's value should be one of: string, int, list, double, object, boolean, long, char, date. &amp;lt;name&amp;gt;'s value is the&lt;BR /&gt; * Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't&lt;BR /&gt; * added. you can have many parameters for the Function.&lt;BR /&gt; * &lt;BR /&gt; * 5. {example} gives a example for the Function. it is optional.&lt;BR /&gt; */&lt;BR /&gt;public class TestRoutine {&lt;BR /&gt;    public static void rowHandlingTest(row1Struct myRow) {&lt;BR /&gt;        &lt;BR /&gt;    	System.out.println("My Row = "+myRow.toString());&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;/PRE&gt; 
&lt;BR /&gt;I am importing the "row1Struct" class from the job I created (therefore this routine will only work with this job) and have created a simple method to print out the columns from the row1Struct class (it prints out some other bits as well, but you modify this to what you want). 
&lt;BR /&gt;Now, we need to call this routine. I do that in a tJavaFlex. The reason I do that is because it can receive row data. The tJava is not great for this. The code I have used is shown below. This code goes in the "Main Code" section of the tJavaFlex..... 
&lt;BR /&gt; 
&lt;PRE&gt;routines.TestRoutine.rowHandlingTest(row1);&lt;/PRE&gt; 
&lt;BR /&gt;Now, when the job is run, I get the following printed to the output.... 
&lt;BR /&gt; 
&lt;PRE&gt;My Row = local_project.test_0_1.Test$row1Struct@5cb27de5&lt;BR /&gt;My Row = local_project.test_0_1.Test$row1Struct@5cb27de5&lt;BR /&gt;My Row = local_project.test_0_1.Test$row1Struct@5cb27de5&lt;BR /&gt;My Row = local_project.test_0_1.Test$row1Struct@5cb27de5&lt;BR /&gt;My Row = local_project.test_0_1.Test$row1Struct@5cb27de5&lt;/PRE&gt; 
&lt;BR /&gt;The row1Struct class' toString method outputs each record as above, but if you want just the column data you can select that as you wish.&amp;nbsp; 
&lt;BR /&gt;Hope this helps.</description>
      <pubDate>Sat, 07 May 2016 17:49:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-New-to-Pass-row1-directly-to-routine-without-using/m-p/2309294#M80522</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-05-07T17:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] New to Pass row1 directly to routine without using dynamic schema</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-New-to-Pass-row1-directly-to-routine-without-using/m-p/2309295#M80523</link>
      <description>I followed the steps . Now, it is working for me. Thanks a lot Richard Hall.</description>
      <pubDate>Sun, 08 May 2016 04:31:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-New-to-Pass-row1-directly-to-routine-without-using/m-p/2309295#M80523</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-05-08T04:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] New to Pass row1 directly to routine without using dynamic schema</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-New-to-Pass-row1-directly-to-routine-without-using/m-p/2309296#M80524</link>
      <description>&lt;P&gt;@Richard Hall​&amp;nbsp;hello Rhall. I followed the steps .&lt;/P&gt;&lt;P&gt;But when i run the job I get an error as follows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could not find or load main class user_test.comparetwononpublishfiles_0_1.CompareTwoNonPublishFiles&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following are the row classes corresponding the row link that i have imported in my custom routine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import user_test.comparetwononpublishfiles_0_1.CompareTwoNonPublishFiles.inpStruct;&lt;/P&gt;&lt;P&gt;import user_test.comparetwononpublishfiles_0_1.CompareTwoNonPublishFiles.refStruct;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 13:03:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-New-to-Pass-row1-directly-to-routine-without-using/m-p/2309296#M80524</guid>
      <dc:creator>TomG1</dc:creator>
      <dc:date>2021-08-24T13:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] New to Pass row1 directly to routine without using dynamic schema</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-New-to-Pass-row1-directly-to-routine-without-using/m-p/2309297#M80525</link>
      <description>&lt;P&gt;I am using talend 7.3&lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 13:03:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-New-to-Pass-row1-directly-to-routine-without-using/m-p/2309297#M80525</guid>
      <dc:creator>TomG1</dc:creator>
      <dc:date>2021-08-24T13:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] New to Pass row1 directly to routine without using dynamic schema</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-New-to-Pass-row1-directly-to-routine-without-using/m-p/2309298#M80526</link>
      <description>&lt;P&gt;Hi @Jijo George​,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This post is a few years old and it seems that the configuration of Studio has changed so that you cannot reference a Job as a library anymore. I am sure it can be hacked, but there is a simpler way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If your row is called row1, then to get a String representation of the whole row you can simply use....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;System.out.println(row1.toString());&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Replace System.out.println() with whatever method you want to pass the values to. You can use some String manipulation to retrieve the values from there. &lt;/P&gt;</description>
      <pubDate>Tue, 24 Aug 2021 14:47:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-New-to-Pass-row1-directly-to-routine-without-using/m-p/2309298#M80526</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-08-24T14:47:30Z</dc:date>
    </item>
  </channel>
</rss>

