Data Iterator Question

Sort:
You are not authorized to post a reply.
Author
Messages
Brian Berenger
Basic Member
Posts: 11
Basic Member

    I'm using the data interator to input a file.   The file is comma seperated.  The fields are "Name", "ID", "Email","Company", etc.

    I have four variables, varName, varID, varEmail, varCompany

    What I want to do is simply loot is through the file and assign each of the fields to its corresponding variable in an assignment node that is nested within the data iterator loop.  I do not want to have to read the whole line into one variable and then use code to parse the line into its fields.  The problem is that it reads one field at a time and I never know which field it has read so I can't; hterefore ; selective branch or determine easily which variable it has read so that I can assign it appropriately.   

    Would anyone be able to post a quick example flow that achieves what I am attempting to accomplish?  I think I'm missing something obvious. I've looked at the user guide and reference materials, and they don't really address what i'm looking to accomplish.

    Thanks

    Brian

    John Henley
    Posts: 3352

      Brian, you need to use 2 data iterators: one to parse the file and one to parse the record:

      Attachments
      Thanks for using the LawsonGuru.com forums!
      John
      nlmoran
      Veteran Member
      Posts: 53
      Veteran Member
        I love when you put sample's out there.
        Wish we had one for adding users to Resource Manager
        Brian Berenger
        Basic Member
        Posts: 11
        Basic Member
          Thanks John, I appreciate your help. How do I link the two? How do I tell iterator #2 to use the data that iterator #1 has .. or better yet how to I implicitly pass this inofrmation? I tried setting iterator #1 up by file and then connecting iterator #2 to it in order to see if any new variables became available or any new menu items.... there was nothing I could see different.

          Should I set up iterator= #1 to parse by line and iterator #2 parse by data element?

          Is there any Lawson publication that helps demonstrate this? I hate asking basic questions, especially if there is a resource that has it documented sufficiently. Unfortunately the user guide is oh so very vague...

          Thank you again!

          Brian
          John Henley
          Posts: 3352
            Iterator1 parses by line, using 'File' method; Iterator2 parses by delimiter using 'Data' method and using Iterator1_outputData is its input.
            Output from Iterator2 is: field1 is Iterator2_outputData1, field2 is Iterator2_outputData2, etc.
            Thanks for using the LawsonGuru.com forums!
            John
            Brian Berenger
            Basic Member
            Posts: 11
            Basic Member
              Thanks a billion John, I really appreciate your assistance.  This is a tremendous help.
              Brian Berenger
              Basic Member
              Posts: 11
              Basic Member

                I’m struggling with how to assign these data elements and would appreciate just a little more clarification. I’m popping in 3 screenshots. The first is iterator #1, the second is iterator #2, and the third is the assignment tab. Given what you see can you please advise how exactly I need to specify the field? I’ve tried a bunch of stuff and keep getting errors. Thanks again

                Brian

                Attachments
                John Henley
                Posts: 3352
                  Assign varEmail=interator2_outputData1
                  When iterating by delimiter, the DataIterator appends the field number to _outputData for each field, so output from Iterator2 is:
                  field1 is Iterator2_outputData1
                  field2 is Iterator2_outputData2
                  etc.

                  The part you're missing is that the outputData* fields don't show up in the variable list....you have to *know* ..

                  I reported this to Lawson in JANUARY 2007 for DataIterator bug as well as ResourceQuery (PT# 166360)
                  Thanks for using the LawsonGuru.com forums!
                  John
                  Brian Berenger
                  Basic Member
                  Posts: 11
                  Basic Member

                    Thank you AGAIN John.  I’ll give it a shot!

                    Brian Berenger
                    Basic Member
                    Posts: 11
                    Basic Member

                       

                      [script removed]

                      [script removed]

                      Still struggling here and am wondering if this is a designer problem.  I’m getting “not defined” errors.  My log is below.  I am getting output data to ppopulate and hand off to “Iterator2”.  So I’ve gone ahead and assigned these values by field to my assignment node.  I have tried putting my assignment node inside the second iterator loop, AND I’ve tried putting it outside of it as well to no avail.  Any ideas what could be wrong?  Thanks
                       
                      My Assignment Node Screenshot is below
                       
                       
                      Executing Data Iterator Activity myfile.....
                      iteration 1 nextPosition=0
                      myfile_errorCode = 0
                      myfile_informationCode = 0
                      myfile_returnMessage = got record
                      myfile_outputData = 12345,testfsmith,Fred,Smith,testone@testbshsi.org,0,TESTPORTROLE
                      myfile_nextPosition = 66
                      myfile_recordNumber = 1
                      Executing Data Iterator Activity Iterator2.....
                      iteration 1 nextPosition=0
                      Iterator2_errorCode = 0
                      Iterator2_informationCode = 0
                      Iterator2_returnMessage = got record
                      Iterator2_outputData = 12345
                      Iterator2_nextPosition = 6
                      Iterator2_recordNumber = 1
                      Exception while evaluating expression: varEmail = Iterator2_outputData5;
                      "Iterator2_outputData5" is not defined.
                      Exception while evaluating expression: varID = Iterator2_outputData2;
                      "Iterator2_outputData2" is not defined.
                      Exception while evaluating expression: varEmpNum = Iterator2_outputData1;
                      "Iterator2_outputData1" is not defined.
                      Exception while evaluating expression: varFirst = Iterator2_outputData3;
                      "Iterator2_outputData3" is not defined.
                      Exception while evaluating expression: varLast = Iterator2_outputData4;
                      "Iterator2_outputData4" is not defined.
                      Exception while evaluating expression: varWFUSER = Iterator2_outputData6;
                      "Iterator2_outputData6" is not defined.
                      Exception while evaluating expression: varPortalRole = Iterator2_outputData7;
                      "Iterator2_outputData7" is not defined.
                       
                      Attachments
                      John Henley
                      Posts: 3352
                        On the iterator2 node, make sure you have the 'accumulate output variables' option selected.
                        Thanks for using the LawsonGuru.com forums!
                        John
                        cpaine216
                        Basic Member
                        Posts: 14
                        Basic Member

                          Has anyone used the data iterator with a flat file that is fixed length and each line has different lengths? I have a file for example that has the following:

                          ER01 - length of 3221

                          ER02 - length of 6128

                          ER03 - length of 265

                          ER05 - 861

                           

                          The ER01 record is the header record for each person's expenses, the ER02 is the detailed line of each person's expenses. There is nothing to correlate ER01 with ER02 records....right now we have this being done via Cobol and it reads in the ER01 header then all ER02 records following that ER01 and resets at the next ER01 record for the next set of ER02 records. I have been able to get (using data iterator) all the ER01 data and ER02 data into corresponding tables, but now have no way to correlate the header records to the detail records.

                          I need to get this data written into IPA as lawson/infor is moving away from cobol.

                          Dave Curtis
                          Veteran Member
                          Posts: 136
                          Veteran Member
                            Posted By cpaine216 on 07/30/2018 1:26 PM

                            Has anyone used the data iterator with a flat file that is fixed length and each line has different lengths? I have a file for example that has the following:

                            ER01 - length of 3221

                            ER02 - length of 6128

                            ER03 - length of 265

                            ER05 - 861

                             

                            The ER01 record is the header record for each person's expenses, the ER02 is the detailed line of each person's expenses. There is nothing to correlate ER01 with ER02 records....right now we have this being done via Cobol and it reads in the ER01 header then all ER02 records following that ER01 and resets at the next ER01 record for the next set of ER02 records. I have been able to get (using data iterator) all the ER01 data and ER02 data into corresponding tables, but now have no way to correlate the header records to the detail records.

                            I need to get this data written into IPA as lawson/infor is moving away from cobol.


                            Maybe you could use the data iterator to read each line. Then send the output data to a string variable.

                            Use JavaScript to analyse the string variable with the output data. Using a JavaScript if statement to determine if the record is of an ER01 or not. If ER01 record then pass the value into the "header" value variable. If not ER01 put it into a details variable.
                            Then you can use those to pass into a data file. Then clear the details value and loop around. Then when it hits the next ER01 record it clears the header variable and so on.

                            So you would need
                            String Variable = strOutPutData
                            String Variable = strHeader
                            String Variable = strDetails

                            After the data iterator node set up an assign node and assign the outputData of the data iterator to strOutPutData

                            The JavaScript would be something like this


                            var fld = strOutPutData;
                            var d = fld.substring(0, 4);
                            var dta = fld.replace(d,"");

                            if(d == 'ER01')
                            {strHeader = dta;
                             strDetails = "";}
                            else {strHeader = strHeader;
                             strDetails = dta;}
                             
                             Following the assign node with the JavaScript you could then pass the strHeader and strDetails onto a file or message builder to create a data file. Then another assign node to clear the strDetails varible, then it would loop around each line and make the assignements for each type of record and reset the header at each ER01 record.
                             
                             Just an on the fly thought...
                             

                             I do not have one specifically like this but I have one that has to evaluate each line and determine what to do based on data in the line and the output is not the same each time so it does a similar evaluation and cannot rely on standard delimiter.

                            You are not authorized to post a reply.