Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello ,
Im trying to store a list of 'marketplace_product_id' but im always , but im getting one row (which is not the case )
Thanks .
Make sure you set your tloop type as a "While' loop. Not a for loop.
Hello again ,
Could i declare an array list using a globalvariable ? .
Im still blocked please !
Here is some working code from one of my jobs. It's in a tJavaFlex which creates an ArrayList and stores it in a global variable. What the code does is break a large file into blocks based on begin/end tags. It stores a list of the blocks in the ArrayList for use later in the job. You can use this as an example:
Start Code:
int i = 0;
String s;
boolean myStart = false;
boolean myRecCntFlag = false;
int startPos;
int endPos;
String subS;
List<String> listFilenames = new java.util.ArrayList<String>();
List<Boolean> listmyRecCntFlags = new java.util.ArrayList<Boolean>();
globalMap.put("myFilename", "nothing");
globalMap.put("myRecCntFlag", false);
Main Code:
s = row7.line;
if(!myStart) {
if(s.contains("^^^BREAK-ETL-BEGIN")) {
myStart = true;
// IndexOf returns -1 if there nothing is found
startPos = s.indexOf(":");
endPos = s.indexOf(":", startPos + 1);
//System.out.println(startPos + "-" + endPos);
if(startPos>=0 && endPos>=0 && startPos < endPos) {
subS = s.substring(startPos + 1, endPos);
} else {
subS = Integer.toString(i);
}
subS = subS + ".sql";
listFilenames.add(subS);
globalMap.put("myFilename", subS);
s = "";
i++;
}
} else {
if(s.contains("^^^BREAK-ETL-END^^^")) {
listmyRecCntFlags.add(myRecCntFlag);
globalMap.put("myRecCntFlag", myRecCntFlag);
myStart = false;
myRecCntFlag = false;
s = "";
} else {
if(s.contains("RecCnt")) {
myRecCntFlag = true;
}
}
}
row9.line = s;
End Code:
globalMap.put("myManafestFilenames", listFilenames);
globalMap.put("myManafestRecCntFlags", listmyRecCntFlags);
//System.out.println("test: " + (String)globalMap.get("myFilename"));
Then a tloop is used to iterate through the ArrayList like this:
Declaration: int i=0
Conndition: i<((List)globalMap.get("myManafestFilenames")).size()
Iteration: i++
Your value can then be accessed with:
(String)((List)globalMap.get("myManafestFilenames")).get(((Integer)globalMap.get("tLoop_1_CURRENT_ITERATION")) - 1)
The problem is when i print the value of the global varible as such :
System.out.println("Global variable : " + globalMap.get("marketplace_product_id"));
The result is : Global variable : null
Am i missing something while putting my variable into tSetGlobalVar ?
Thanks
Here is a screenshot
Make sure you set your tloop type as a "While' loop. Not a for loop.