Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
rwnetwork
Creator
Creator

Only getting last value in Job

Good Morning Community,

Can anyone see why I am only getting the last value in a list of 170 products?  

So for example, in the list below, I am only getting the X.

A

B

C

...

X

 

Please anyone, this is a blocker on a deadline.  Thank you Community! 0683p000009MACJ.png

 

 

0683p000009M9Zm.png

Labels (2)
16 Replies
rwnetwork
Creator
Creator
Author

I've never had to call a global variable like this, so let me try your suggestions and advise.

Thank you!

 

rwnetwork
Creator
Creator
Author

Forgive me if I'm not understanding, but with your suggestion, how would I put single quotes around each part number when fiinst is supposed to represent the 170 products?

 

--So your variable globalMap.get("fiinst") should contain opening an closing parentheses, and single quotes around each part number, and include a comma between each part number or your query won't work - correct?

 

Sorry I'm not understanding!  I thank you for being so helpful. 0683p000009MACJ.png

 

 

billimmer
Creator III
Creator III

I would use a row#->tJavaFlex instead of iterate->tJava. It has a Start/End code section.

 

In the Start Code use:
// Initialize string variable called "parts"
String parts = "";

 

In the Main code use:
// Add each part to the "parts" string. Include single quotes and comma.  

// REPLACE THE # CHARACTER WITH YOUR CONNECTION NUMBER

// NOTE:  Also, include logic to skip parts you don't want.
parts = parts + "'" + row#.part + "',"

 

In the End Code use:
// We are done, so remove the last comma.
if (parts.length() > 0) {
parts = parts.substring(0, parts.length() - 1);
}

 

// Now add the parentheses
parts = "(" + parts + ")"

 

// Check your work to make sure it's correct. Comment out for production
System.out.println("My parts string: " + parts);

 

// Put the result in a global variable for use later in your query
globalMap.put("fiinst"", parts);

rwnetwork
Creator
Creator
Author

mmmmm ok, thanks so much billimmer!  tjavaflex is also new to me so let me give it a try!

Again thank you, I would give you an elbow bump if I could right now.  0683p000009MA9p.png

billimmer
Creator III
Creator III

Thanks hope it works for you. 

 

This will get what you asked for, but you might also want to instead try writing the list of parts to a file or DB temporary table.  This would be a more scalable solution, as there is a limit to the number of values that can be put into the "IN" statement of your query.  So for example you would use:

 

tFilterRow, with the "Advanced" option and put your filter java code there.  Then connect the tFilter to a tFileOoutputDelimited, or DB component.  Then you can use this with a join or lookup later in the job.  

 

 

rwnetwork
Creator
Creator
Author

mmmm this looks doable as well.  I feel like I've gone crazy trying to get this to work!

Thank you again for your suggestions and quick responses. 0683p000009MI7i.png0683p000009MI9i.png

rwnetwork
Creator
Creator
Author

Well billimmer

I have figured out the culprit and almost embarrassed to share.  But want to help out the community if anyone else runs into this issue. 

Maybe I've been cooped up for too long!

You were on the right path in your original suggestion.  I had a pipe delimiter in my filtered .txt file, so therefore, the global variable was not reading the separation of the 170 products (only the last one in the list).  I changed the pipe delimiter to a comma and voila!, my output is coming through as expected.

 

Thanks again for all your help!

Michelle