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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
antdurif
Contributor
Contributor

Use row in routine

Hello,

In my job I used to call a routine in my tMap to construct a String with some informations I have (or not) in my input rows.

I call my routine function like and I use different attibutes inside the function.

 

Utils.getLigneBulk(row8, row9, row10) 
import project_name.job_name_0_1.JOB.row8Struct;
import project_name.job_name_0_1.JOB.row9Struct;
import project_name.job_name_0_1.JOB.row10Struct;
....

public static String getLigneBulk(row8Struct row8,row9Struct row9, row10Struct row10) {
// ....
}

 

But I have a problem in the routine with the classes and imports because it's refers to a missing type row8Struct (and I suppose it's the same for row9Struct and row10Struct).

However this worked in my previous job version on V6.x but not now in v8.x. Maybe I forgot some things. 

Thanks for any advises.
Best regards.

Antho

 

Labels (2)
1 Solution

Accepted Solutions
jlolling
Creator III
Creator III

The problem here is the class for a row e.g. row8Struc is defined inside the job as inner class. A routine must be compilable outside of a job thats why you cannot directly use these class. 

In Talend Open Studio v6 the code generation was different and the job classes and the classes from the routines was inside of one huge Java project. Since Talend 7 all jobs are its own Maven projects and the formally existing one huge Java project does not exists anymore.

If you want using this kind of object the only way is using reflection API (part of JDK).

Please note the routines will be compiled separately to its own jar. There is no context of a job to compile these classes.

What you also can do is, not writing a routine, instead write an inner class inside the job using tJavaFlex. You can always define your class in the Begin section of a tJavaFlex and use it in the flow if the tJavaFlex. 

View solution in original post

5 Replies
Shicong_Hong
Employee
Employee

I am not sure this way will work. However, you should add the dependency jar file which contain the classes you import to the routine.

Regards

Shicong

antdurif
Contributor
Contributor
Author

Thanks for the answer but I'm not sure to understand where add the depedency because the classes are in the same job where I call the routine.

Here a picture of my job to have a better view (the routine function call is made in the tMap_3 using other inputs datas).

antdurif_0-1709032356771.png

Best regards

jlolling
Creator III
Creator III

The problem here is the class for a row e.g. row8Struc is defined inside the job as inner class. A routine must be compilable outside of a job thats why you cannot directly use these class. 

In Talend Open Studio v6 the code generation was different and the job classes and the classes from the routines was inside of one huge Java project. Since Talend 7 all jobs are its own Maven projects and the formally existing one huge Java project does not exists anymore.

If you want using this kind of object the only way is using reflection API (part of JDK).

Please note the routines will be compiled separately to its own jar. There is no context of a job to compile these classes.

What you also can do is, not writing a routine, instead write an inner class inside the job using tJavaFlex. You can always define your class in the Begin section of a tJavaFlex and use it in the flow if the tJavaFlex. 

jlolling
Creator III
Creator III

Again, this will not work anymore. See my former comment about the reason. Use reflection api or use an inner class using the tJavaFlex component. You can put the tJavaFlex component between tUniqueRow_2 and tMap and class your routine class in the main part of the tJavaFlex. 

antdurif
Contributor
Contributor
Author

Thanks  @jlolling for explanations and especially for the differences between v6 and v8 code generation.

My other idea was to use tJava or tJavaFlex to do some of my routine function work, so your post confirms this. I will try.

Thanks again.