Loop over list and write to separate documents

Hello everybody, I want to see if someone can help tell me with a certain problem (or lead me in the right direction), as I am having a terrible time with coming up with the proper solution.

Okay, let’s say that I have a document LIST like the below (which took me almost 3 hours to figure out), which contains date and number information (completely sorted).

sortedDocumentList (name of list)
List (0)
Date (20120101)
LowNum (1)
List (1)
Date (20120101)
LowNum (15)
List (2)
Date (20120101)
LowNum (500)
List (3)
Date (20120315)
LowNum (10)

Of course, the above list could be different. Above is just an example, but let’s say today I received the data above and the only rule is:

If the date is the same, then you need to map the date and lownum to its own document, then after you’re done, map contents involving the next unique date to the next document. When I’m completely done, then all documents should be ftp’d to the customer.

This means that based on the above, there are TWO documents involved. 0-2 are supposed to be mapped to fields in Document A and 3 is supposed to be mapped to fields in Document B. This is because the dates are the same in sortedDocumentList 0-2 and 3 is different, which requires mapping to its own document.

I’m just not figuring out at the moment the best strategy to accomplish this. Below idea doesn’t seem right, plus whereas today I’m writing to TWO documents, tomorrow, I could need to write to 10 different documents. It all depends on how many unique dates I get and that varies.

LOOP over sourceDocumentList
Map Date to VAR
LOOP over sortedDocumentList2 (which I copied from sourceDocumentList)
If Date from sortedDocumentList2 = Date from sortedDocumentList
Write to fields in Doc A
Otherwise (Default)
Write to Doc B (however today there could just be 2 doc, whereas tomorrow there could be 10 – depends on unique dates)

PLEASE HELP! Can you point me in the right direction?

Where are you getting source data from table or Internal/Canonical document? I believe deriving sorting logic is not as easy with flow esp (Looping/branching/regex) and may be doing it via Java service (using hash table) or SQL script might be easier/faster approach per your requirement:


Hi, thanks for the response. Yes, source data is coming from Internal/Canonical. I was hoping you wouldn’t mention Java because Java is frowned upon in our working environment. Basically, it’s not allowed here except for emergencies. Something about it being difficult to support. Can you point me towards which Java services I would need to evaluate, in order to accomplish my goal? Thanks again.


Assuming That you have sorted the list on Date …

have a copy condition to your O/P doc to something lik e

inputDoc{$iteration}Date != outputDoc($iteration-1} date

Siddhartha Ravipati

Thanks, I will try that. sent you a private message.