locked
How can I create a new record for each loop. RRS feed

  • Question

  • I am working with an 310 transaction (I assume this can be any transaction set). I currently have the 310 mapped to a flat file. The mapping seems to be working okay except for when the LX Loop has multiple N7 segments. It creates the record for the first N7 but skips the others.

    How can I repeat the output for each new N7.

    I am somewhat a newbie so please detail any suggestions you may have.

    Thanx...Angel
    Wednesday, March 10, 2010 2:59 PM

Answers

  • Yep, this output is a far cry from what your original question addressed.  For the record, here is Angels problem.

    He receives a ocean shipping manifest with multiple LX loops.  Each LX loop has a container (N7 segment).  He needs to generate a complete set of output information for each container.

    His target schema does not permit this, as the root node is Manifest and all the elements are single occurrence in sequence below Manifest. 

       Manifest
          a
          b
          container

    His desired output if the input has two containers is:

       Manifest
          a
          b
          container
          a
          b
          container

    Short of doing this in XSLT, there appears to be no way to achieve this without modifying the target schema.  For example, if the target schema was

       Manifest
          Detail (unbounded)
            a
            b
            container

    multiple instances of the block could be output.  It would be interesting to know the specific business process that drives this exercise, as that might produce an entirely different schema.




    Jim -- Pro Mapping in BizTalk 2009, Apress Books, March 23, 2009
    • Marked as answer by Andrew_Zhu Wednesday, March 17, 2010 1:18 AM
    • Unmarked as answer by Angelt1 Wednesday, March 17, 2010 2:15 PM
    • Marked as answer by Angelt1 Wednesday, March 17, 2010 2:15 PM
    Tuesday, March 16, 2010 8:20 PM

All replies

  • You will need to use the table looping functiod with the table extract functiod. 
    These two functiod are designed for this very purpose you are asking about. The following link is for BTS 2004, but it is the same through all of the versions of BiztTalk (http://msdn.microsoft.com/en-us/library/ee253864(BTS.10).aspx)

    Eric Stott [http://blog.biztalk-info.com] - Mark as Answer if this reply does.
    Wednesday, March 10, 2010 3:07 PM
  • Just thought
    Using custom XSLT, could populate multiple records at runtime.
    Thanks, Raja
    Thursday, March 11, 2010 5:22 AM
  • I must be doing something wrong or I just don't understand how to use the Table Looping control.

    I added a table looping control and assigned the first parameter to N7Loop1 and my second parameter = 3(Three columns).

    I think the link to the flat file schema is were I'm going wrong. I am linking the Table looping to the Manifest record but this iteration only happens once since it is a flat file.

    I am getting the same results I had prior  to adding the Table Looping control

     

    Thursday, March 11, 2010 5:56 PM
  • Raja,

    I'm sure this can be done in XSLT but I don't know were to start with it. I never did anything with XSLT  and I am new to BTS.

    Any guidance would be appreciated.

    Thanx...Angel
    Thursday, March 11, 2010 6:00 PM
  • Angel,

    This should be a very simple mapping.  If you like, zip up your map and schemas and send them to me at jim@sspsi.com and I'll take a look.


    Jim -- Pro Mapping in BizTalk 2009, Apress Books, March 23, 2009
    Friday, March 12, 2010 4:20 PM
  • You can use Looping Functiod to achieve it. Just connect the N7 record to Looping functiod and then Looping functiod to the destination record. This will create one record in destination record for each record in N7.

    Nikhil J

    Sunday, March 14, 2010 4:31 PM
  • The looping functoid sounds like the simple answer, but using the looping functoid does not always ensure that the output will be as desired.  The problem often occurs because compiler-inferred loops conflict with each other or with loops created with looping functoids.

    Often you can have two loops, each of which will work alone in the map but only one or neither will work if both are present.  In these cases you most often must resort to an XSLT template for one of the loops, as Raja noted above.

     

    Jim -- Pro Mapping in BizTalk 2009, Apress Books, March 23, 2009
    Monday, March 15, 2010 6:52 PM
  • In the table grid, you place two lines, and ensure that the item that determines if the output needs to be created is placed in the first column and you have the check mark box checked.

    I have done it successfully on very complex maps.

    Eric Stott [http://blog.biztalk-info.com] - Mark as Answer if this reply does.
    Monday, March 15, 2010 7:45 PM
  • Angel,

    I just looked at your map and there are fundamental problems with your schema.  Your Manifest schema (output schema) is single occurrence both at the root level and at the element level.  For those who have not seen the schema, it consists of a root node with 18 child elements.

    I believe that you are trying to show one manifest which can have multiple containers. You have the N7 segment linked to the Container element, thus I infer that you are trying to create multiple Container elements.

    To do this, you must first make the Container element a one to many (change max occurs to unbounded, for example) or move the element into a loop (Add a Containers record with max occurs unbounded and a child element Containers).

    Once you've done this, test the map.  You may or may not need a looping functoid to drive the output.

    I'll send you both methods in your map.

    Jim -- Pro Mapping in BizTalk 2009, Apress Books, March 23, 2009
    Tuesday, March 16, 2010 2:43 PM
  • Jim,

    I used the wizard to create the output schema and since I'm a newbie I didn't know any better.

    Here is what I need to accomplish:

    I need one output record for each N7 available. As you can see, I am also needing to extract information from the N1 loop based on the N101.

    Okay, the output schema may not be setup properly but the positional layout is what I need.

    Can you give me an example of how the output schema needs to be setup? Are you going to include this in the map?

    Again I appreciate your help.

    Thanx...Angel
    Tuesday, March 16, 2010 3:17 PM
  • Simply make your record Unlimited (or the max number you can have) and you should be good to go
    <Schema>
          File
             Record (unlimited)
                Field1
                Field2
                Field3
                Field4

    Eric Stott [http://blog.biztalk-info.com] - Mark as Answer if this reply does.
    Tuesday, March 16, 2010 3:54 PM
  • Eric,

    Like Jim mentioned this schema is not setup properly but how do I change my schema without having to redo it?

    My schema looks like this:
    <Schema>
        Record
            Element 1
            Element 2
            and so on...


    Thanx...Angel
    Tuesday, March 16, 2010 4:56 PM
  • Angel,

    The answer is in the sample that I sent you.  Look at the schema change I gave you.  The Container element has been changed to unbounded.  Remove the second change, the added Containers record, and you are good to go.

    Eric's suggested change is incorrect for your schema.

    Jim
    Jim -- Pro Mapping in BizTalk 2009, Apress Books, March 23, 2009
    Tuesday, March 16, 2010 5:22 PM
  • Geez;
    Go through the trouble and fix the schema and remap it if necessary, better to fix the problem earlier than later!

    Eric Stott [http://blog.biztalk-info.com] - Mark as Answer if this reply does.
    Tuesday, March 16, 2010 6:06 PM
  • Jim,

     

    It is not exactly what I was looking for.

    I was hoping to get a new record/line for each N7; instead the N7 is added to the same record/line.

     

    Also, you had linked the looping functoid to N1, did you mean to do this or did you mean to link it to N7. I changed it to N7. Hopefully this is want you meant to do.

     

    Thanx...Angel

    Tuesday, March 16, 2010 6:47 PM
  • Doh!  The N1 was a mistake.

    I looked at your data, and saw that the structure was also different than expected.  You do not have an N7 loop in the source.  You have one N7 segment for each line item.

    N7*...
    N7*...
    N7*...

    was what we thought you were describing.

    LX*1
    N7*....
    LX*2
    N7*....
    LX*3
    N7*....

    is what you actually have.  In other words, you have an N7 per LX loop.  This requires a different construct that would be used in the case of the N7 loop.

    I have fixed your map and tested it using the LX1 loop case, and it puts out a container object for each instance of N7 in the transaction.  Once you check the results, let us know if the output is what you desire.


    Jim -- Pro Mapping in BizTalk 2009, Apress Books, March 23, 2009
    Tuesday, March 16, 2010 6:59 PM
  • Jim,

    I just sent the desired output based on the single310 file you sent me.

    The current output is not correct.

    Maybe this is a little bit more complex then you and I thought or I just wasn't clear in what my desired output needed to be (Probably the latter). :)

    Hopefully, this file will shed some light on the issue.

    Thanks a bunch!

    Thanx...Angel

    Tuesday, March 16, 2010 8:04 PM
  • Yep, this output is a far cry from what your original question addressed.  For the record, here is Angels problem.

    He receives a ocean shipping manifest with multiple LX loops.  Each LX loop has a container (N7 segment).  He needs to generate a complete set of output information for each container.

    His target schema does not permit this, as the root node is Manifest and all the elements are single occurrence in sequence below Manifest. 

       Manifest
          a
          b
          container

    His desired output if the input has two containers is:

       Manifest
          a
          b
          container
          a
          b
          container

    Short of doing this in XSLT, there appears to be no way to achieve this without modifying the target schema.  For example, if the target schema was

       Manifest
          Detail (unbounded)
            a
            b
            container

    multiple instances of the block could be output.  It would be interesting to know the specific business process that drives this exercise, as that might produce an entirely different schema.




    Jim -- Pro Mapping in BizTalk 2009, Apress Books, March 23, 2009
    • Marked as answer by Andrew_Zhu Wednesday, March 17, 2010 1:18 AM
    • Unmarked as answer by Angelt1 Wednesday, March 17, 2010 2:15 PM
    • Marked as answer by Angelt1 Wednesday, March 17, 2010 2:15 PM
    Tuesday, March 16, 2010 8:20 PM
  • Jim,

    You are right on with what I need. I'm looking forward to completing this task.

    This business process is a process that was developed about 10yrs ago. A couple of our clients provided flat files that were in the specific format of the output file. The system I developed initially worked around the format the clients provided. Today we are now working with some new clients that are giving us the same information but in x12 format, hence the conversion.
    So long story short, I am just trying to replicate what our system can currently process without have to change our system.

    ...Angel
    Tuesday, March 16, 2010 8:37 PM
  • Wow,

    Kudos to Jim!

    He has gone way beyond my expectations of what I thought someone would do in this forum.

    I would HIGHLY Recommend buying his book. His knowledge and expertise in this subject has been superb.

    A big THANK YOU is well deserved.

    Thanx...Angel

    To sum up what has transpired:
    My original schema had to be changed as described above. Plus Jim added a dummy data node(outside the main loop) to the output schema to accommodate for the N1 loop (I guess so it doesn't interfere with the N7 loop). He also created some inline scripts to handle specific elements needed. Now I have what I need for my output.

    This was all well beyond my knowledge of BTS mapping.
    Wednesday, March 17, 2010 2:14 PM