Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using tjavarow component to transform a data flow

Hello guys! 

I've been doing talend for a month now and have finished almost all exercises provided by talendforge and also most exercises provided in the internet. But one advanced exercise really had me stuck for quite awhile, it was in exercise 10 where what i have to do is I have to configure a tjavaflex so that it will generate two NSS(honestly, until now I really dont know what's this): "2700392000000", and "1760991000000". You also have to create a month, year and department columns within the tjavaflex. After creating it somehow, you put another tjavarow where you will have to instantiate the variables corresponding to the output data. Im really sorry if this sounds so confusing, but the exercise really is(or how its written), but somehow I really want to know how to solve this exercise. Anyways, I'll be attaching the screenshot below and any help would be always appreciated 

Thanks and God Bless


 

Labels (2)
3 Replies
Anonymous
Not applicable
Author

With a tJavaFlex component, you have 3 code sections; start code, main code and end code. If you want to generate rows, you can use these sections in the following way to generate data rows. The below example is a simple example of how to generate 2 two rows with random data....
Start Code
for(int i = 0; i<2; i++){

The above will create a loop that will loop twice. Check For Loops out in regard to Java to see how this works. 

Main Code
row1.col1 = routines.TalendString.getAsciiRandomString(10);
row1.col2 = routines.TalendString.getAsciiRandomString(10);

The above will populate two columns (col1 and col2) with random Strings for each iteration of the loop. "row1" is the name of the row connected to the tJavaFlex.
End Code
}

The above simply ends the loop created in the Start Code.
Anonymous
Not applicable
Author

I know how to create a simple table using tjavaflex, its just that this one particular exercise really got me stuck...the table that it wanted me to output will look like this:

              Input        |                    Ouput                     |
NSS                       |     Month     | Year  | Department |
--------------------------------------------------------------- |
[font=Verdana, Helvetica, Arial, sans-serif] 2700392000000       |       03         | [/font][font=Verdana, Helvetica, Arial, sans-serif] 1970 |      92         |[/font]
[font=Verdana, Helvetica, Arial, sans-serif] 1760991000000       |       09         | [/font][font=Verdana, Helvetica, Arial, sans-serif] 1976 |      91         |[/font]




[font=Verdana, Helvetica, Arial, sans-serif] I only got to the part in creating the 2 NSS numbers and what really confuses me is how to use that to have the output like the one showed above where there is a "Month", "Year" & "department"......in the exercise, it uses a tjavarow to do that...but it didnt really specified on how to do it...

Anyways, I really appreciate any help from you guys 0683p000009MACn.png
[/font]

0683p000009MGlK.jpg
_AnonymousUser
Specialist III
Specialist III

Hi  novastorm33
I am not sure if you are looking for the code something like below-


one you have generated NSS in a variable called nss. you can use below code to generate rest of the fields-
[color=#5b5b5d][font=Verdana, Helvetica, Arial, sans-serif] month=nss.substring(3, 5);[/font][/color]
[color=#5b5b5d][font=Verdana, Helvetica, Arial, sans-serif] dept=nss.substring(5,7);[/font][/color]
year="19"+nss.substring(1, 3);


Thanks,
sag