Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Can you show some screenshots of your job configuration, since I do not understand what you are trying to do. Are you reading in an MD5 String? I'll need a bit more info
In a similar situation:
Input
MASTER_CODE | COMM |
XLMA | C-123-1 |
AAAA | A-111-1 |
BBBB | C-123-1 |
BBBB | D-123-1 |
CCCC | C-333-3 |
XLMS-A | C-553-2 |
XLMS-A | D-323-1 |
XLMS-A | E-311-3 |
Desired output
MASTER_CODE | COMM |
XLMA | C-123-1 |
AAAA | A-111-1 |
BBBB | C-123-1 |
D-123-1 | |
CCCC | C-333-3 |
XLMS-A | C-553-2 |
D-323-1 | |
E-311-3 |
I'm trying to do it using tJavaRow but no luck, this is the code I'm using:
Your Java is incorrect. The "equals" method doesn't assign a value, it checks to see if two values are equal. This should work....
if(globalMap.get("PrevRow")!=null&&((String)globalMap.get("PrevRow")).equals(row1.MASTER_CODE)){ row2.MASTER_CODE = ""; }else{ globalMap.put("PrevRow",row1.MASTER_CODE); row2.MASTER_CODE = ((String)globalMap.get("PrevRow")); row2.COMM = row1.COMM; }
Thanks for your reply!
This almost solves it. The remaining issue is that the COMM field is not showing the correct values:
MASTER_CODE | COMM | Should be |
XLMA | C-123-1 | |
AAAA | A-111-1 | |
BBBB | C-123-1 | |
C-123-1 | D-123-1 | |
CCCC | C-333-3 | |
XLMS-A | C-553-2 | |
C-553-2 | D-323-1 | |
C-553-2 | E-311-3 |
Excellent, this worked! Simply moving the COMM field out of the IF statement solves it.
Thanks for your help!
Sorry, I wrote that straight to the forum without testing it. I meant the COMM field to be outside of the IF hence it was only included once.
i also need to get next record's value for process. i didn't find the solution in forum. kindly share the solution u got
How do you decide the next row , it should be based on a column. for example , for a customer-purchase information file i would consider that the next row is based upon his purchase date ie , for a customer A (considering two purchases for him) the next row will be the row having the maximum date and the current row will be the row having minimum date. So the next and the current rows are always dependent upon a column (date,sequential number,rank etc.)
Hence , for the above example ,sorting descending upon the purchase-date column on every customer group , we can get the next purchase date for the customer row with current purchase date by fetching the previous date value using tmemorize or a variable storing the previous value.
In Java , it is always a top down approach and we cant get the next iteration's value sitting on the current iteration . The above solution would be a workaround to achieve what you want.