Four Stars

tjavaflex last row

Hello,i'm working on this component. I read all row of a file, and after i read a group of them i do some operation on the rows. The problem is that the job don't add the last rows to the result, this because my code "don't knows" that is the last row . There is a method that i can say to the component attention this is the last row?
Sorry for my bad english
10 REPLIES
Fifteen Stars

Re: tjavaflex last row

Put the code that needs to be fired on the last row in the "End Code" section, which is fired after the last row, if that will work. There is no method to identify the last row I'm afraid. Otherwise you *could* get the number of rows from the source component (in a different subjob) and then keep a count in the Main Code section of your JavaFlex. Then compare the total number of rows with the count.
Rilhia Solutions
Four Stars

Re: tjavaflex last row

i put the code in the End code but this solution didn't work
Fifteen Stars

Re: tjavaflex last row

What exactly are you trying to do. I just reread your initial post and it looks like you are trying to do something over all of the rows. If that is the case, calling a method on the last row will not work. The tJavaFlex calls the MainCode on every row. It doesn't automatically "remember" previous rows unless you build that functionality in. If you tell us exactly what you want to achieve, we can maybe help you out.
Rilhia Solutions
Four Stars

Re: tjavaflex last row

I have a table and i'm looking all of his rows. Now some of this rows have a coloumn that have the same value, it's a thing like an ID. Now all rows that have the same "ID" i have to sum all the value and save this value in a variable. The problem is that when he find the last row the job don't recognize it and the code end. If in the end code of the tjavaflex i insert statement like put in the output line this value, nothing heppened.
Fifteen Stars

Re: tjavaflex last row

I see. Why not use the tAggregateRow for this? Unless there is something that this component does not do, you are "recreating the wheel"
Rilhia Solutions
Four Stars

Re: tjavaflex last row

i need to use tjava flex because i need to do some logical operation too. You have other idea? because when i try in the end code to look what is write on the row i find the correct value, but i don't find this row after the tjavaflex component
Fifteen Stars

Re: tjavaflex last row

OK, well you don't actually need to know when the last column is reached. If you need to perform logic that cannot be performed in any other way, why not create a data class to hold your data and create a new object for each instance of a new key. Store these objects in a HashMap. For every row that comes in, check to see if the object exists in the HashMap. If it does, retrieve it and perform whatever action you want to perform on the data. If it does not, then create a new instance of the object, add the data and then add it to the HashMap. At the end of the tJavaFlex reference the HashMap using a globalMap. Then in another tJavaFlex you can iterate over the HashMap and output your data in rows.
A loose example of this sort of processing can be found here (https://www.rilhia.com/tutorials/load-data-dynamic-number-files). In this example, I am writing data to different files created and stored in a HashMap.
Rilhia Solutions
Four Stars

Re: tjavaflex last row

i resolve the issue. I count the number of row in another tjavaflex, i put this value in the global map, and use it for control the last row
Thank for your help Smiley Happy
Fifteen Stars

Re: tjavaflex last row

In my first post I said you could get the row count from the source component. There is a globalMap variable for this which would save you having to use a tJavaFlex
Rilhia Solutions
Four Stars

Re: tjavaflex last row

i know is this the reason because i have used it
thank you Smiley Happy