Data Iterator

 5 Replies
 0 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
Erin
Advanced Member
Posts: 24
Advanced Member
    Is there a way of resetting the _nextPosition in a Data Iterator?

    I have an IPA that reads in two variables that are passed in from another IPA flow that represents two separate but similarly formatted files.

    I have a generic variable "inputFileName" in my IPA that I set to the first of the two incoming file variables (e.g. inputFileName = FileA.txt)

    At the end of the FileA.txt file processing I use a branch to see what the inputFileName is set to in order to see if it is already set to the second file FileB.txt (so I can either end the job if already FileB.txt or know I have to reassign the inputFileName to FileB.txt). 

    But I've noticed that it loops through the FileA.txt beautifully, it sees after the last record is read that I am on the first file and reassigns inputFileName to "FileB.txt", reads in the correct number of record and then moves to the Data Integrator again. But the Data Integrator ends abruptly. I think it is because the DI_nextPosition = 93659 and hits end of stream.

    If there is another way to reuse the Data Iterator loop for more than one file, and I am just being stupid as how to do it please let me know (my feelings won't get hurt).
    Woozy
    Veteran Member
    Posts: 709
    Veteran Member
      Hi Erin,

      Maybe I'm not following you. Are you trying to use the same node to process both files without ever exiting the loop? I think that would be problematic. I don't think IPA will allow you to override the nextPosition value. Why wouldn't you use separate nodes - one for FileA and one for FileB? I realize this would require you to create and assign variables for all of the fields returned from each file, but I think you'd be better off. With some creativity you could use the same nodes within the loops, but just branch to the correct di-end node based on the filename.

      Maybe it would help if you would attach a sample of your flow that just includes the relevant nodes so we can see what you're doing?

      Kelly
      Kelly Meade
      J. R. Simplot Company
      Boise, ID
      Erin
      Advanced Member
      Posts: 24
      Advanced Member
        Hi Woozy,
        Sorry I confused you. I do exit the Iterator loop (when the first file get to the end). After the ITEnd node exit it comes out and goes to an Assign node so I reassign the input file name to the second incoming file. Then I read in that file and connect back to the DATAIT node so I can use all the same nodes all over again for the second file since the files contain the same format.
        Of course in .Net or any other language this certainly wouldn't be an issue but since I need the file names passed in from another IPA, I am trying to do it in IPA. I don't know what resets the pointer as I assumed the ITEnd did that automatically.
        Kyle Jorgensen
        Veteran Member
        Posts: 122
        Veteran Member
          Have you tried using a javascript expression in an assign node to set 'iteratornodeName_nextPosition' to zero before you loop back to it for it's second use?
          Kyle Jorgensen
          Veteran Member
          Posts: 122
          Veteran Member
            I just tried testing my idea. It works. Set the nextPosition value to zero before you loop back into the iterator for your 2nd go 'round.
            Erin
            Advanced Member
            Posts: 24
            Advanced Member
              Hi Kyle.
              No! I didn't think I could do that via JavaScript. That worked. Fantastic! Thanks!!!!!!