none
EDI X12 304 version 4010 - N1Loop1 RRS feed

  • Question

  • Let me ask a more specific question - I have XML going into a map. The schema is simple and is being mapped to the X12 xsd that ships with BizTalk. Each Data record has an invoice_id field, a segment_id field and then the appropriate fields for the segment. The X12 has a N1Loop1 node with a N1 node, a N2 Node, a N3 node, a N4 node and a G61 node. So I have mapped the n3:N101 from the incoming schema to a looping functoid to the N1Loop1 node. Then I use a logical string functoid to map the n3:N101 to the N1 node, n3:N201 to the N2 node and the n3:N301 to the N3 node and then map the elemets appropriately. (BZT_EDI304_CREATE is the oracle procedure name being invoked by the polling receive port)

    The xml snippit is:

    <?xml version="1.0"?>
    -<ns0:BZT_EDI304_CREATE xmlns:ns3="http://Microsoft.LobServices.OracleDB/2007/03/S2KDBA/Procedure/BZT_EDI304_CREATE" xmlns:ns0="http://Microsoft.LobServices.OracleDB/2007/03/S2KDBA/PollingProcedureRoutable">-<ns0:REC_304_DATA>-<REC_304_DATARECORD xmlns="http://Microsoft.LobServices.OracleDB/2007/03/S2KDBA/Procedure/BZT_EDI304_CREATE"><INVOICE_ID>DW05CLR5</INVOICE_ID><SEGMENT_ID>N1</SEGMENT_ID><N101>BT</N101><N102>Name 1</N102></REC_304_DATARECORD>-<REC_304_DATARECORD xmlns="http://Microsoft.LobServices.OracleDB/2007/03/S2KDBA/Procedure/BZT_EDI304_CREATE"><INVOICE_ID>DW05CLR5</INVOICE_ID><SEGMENT_ID>N2</SEGMENT_ID><N201>Address 1</N201><N202>Addess1-2</N202></REC_304_DATARECORD>-<REC_304_DATARECORD xmlns="http://Microsoft.LobServices.OracleDB/2007/03/S2KDBA/Procedure/BZT_EDI304_CREATE"><INVOICE_ID>DW05CLR5</INVOICE_ID><SEGMENT_ID>N3</SEGMENT_ID><N301>Address 2</N301></REC_304_DATARECORD>.........

    </ns0:REC_304_DATA><ns0:RoutingID>MAEU</ns0:RoutingID></ns0:BZT_EDI304_CREATE>

    In the xlst (when I am debugging the map) I see the following - which finds the N101 and so the first LogicalIsString set var:v7 = true. But then it paths back (../s0:N201/text() ) and the LogicalIsString returns false for var:v8. So it writes the N1 segment but never sees the N2 or N3 segments. The N1Loop1 is inside the for-each select="s0:N101". If I map the N201 and N301 to the looping functoid then it has problems with the n2 when it is doing a for-each select="s0:n101". I have looked through a number of books but haven't found anything comprehensive.

          <xsl:for-each select="s1:REC_304_DATA/s0:REC_304_DATARECORD">
            <xsl:for-each select="s0:N101">
              <xsl:variable name="var:v7" select="userCSharp:LogicalIsString(string(./text()))" />
              <xsl:variable name="var:v8" select="userCSharp:LogicalIsString(string(../s0:N201/text()))" />
              <xsl:variable name="var:v9" select="userCSharp:LogicalIsString(string(../s0:N301/text()))" />
              <ns0:N1Loop1>
                <xsl:if test="$var:v7">
                  <ns0:N1>
                    <N101>
                      <xsl:value-of select="./text()" />
                    </N101>
                    <xsl:if test="../s0:N102">
                      <N102>
                        <xsl:value-of select="../s0:N102/text()" />
                      </N102>
                    </xsl:if>
                  </ns0:N1>
                </xsl:if>
                <xsl:if test="$var:v8">
                  <ns0:N2>
                    <xsl:if test="../s0:N201">
                      <N201>
                        <xsl:value-of select="../s0:N201/text()" />
                      </N201>
                    </xsl:if>
                    <xsl:if test="../s0:N202">
                      <N202>
                        <xsl:value-of select="../s0:N202/text()" />
                      </N202>
                    </xsl:if>
                  </ns0:N2>
                </xsl:if>
                <xsl:if test="$var:v9">
                  <ns0:N3>
                    <xsl:if test="../s0:N301">
                      <N301>
                        <xsl:value-of select="../s0:N301/text()" />
                      </N301>
                    </xsl:if>
                    <xsl:if test="../s0:N302">
                      <N302>
                        <xsl:value-of select="../s0:N302/text()" />
                      </N302>
                    </xsl:if>
                  </ns0:N3>
                </xsl:if>
              </ns0:N1Loop1>
            </xsl:for-each>
          </xsl:for-each>


    Harold Rosenkrans
    Tuesday, November 1, 2011 6:25 PM

Answers

  • Ok, This is for the benefit of anyone who is looking at this post. The EDI304 X12 spec has quite a few loops and some nested loops. I have had to handle some differently than others. For the N1Loop1 here is the final set up that worked.

    In the Oracle procedure, for each iteration of the N1Loop1 I needed to create a single record with the N101, N102, N201, N202, N301, N302 values included for that iteration. In the BizTalk map I have three pages, one for loops, one for "gates" and one for data. in the loop page I link the N101 field from the stored procedure schema to the N1Loop1 node with the looping functiod. In the "Gates" page I link the N101 field [in the Oracle, WCF adapter, source schema] to the N1 node [in the X12 target schema], the N201 field to the N2 node and the N301 field to the N3 node.

    for the LXLoop1 I didn't use the looping functoid on the Loops page but I did link the N701 source field to the nested, N7Loop1 node on the Loops page. On the Gates page I linked the LX01 field to the LX node, the Y201 field to the Y2 node, the N701 field to the N7 node, the QTY01 field to the QTY node and the M701 field to the M7 node in the nested loop using a logical string functoid for each link.

    I found that if I subscribed to the polling receive port with a send port, pass through, transmit, I can get a copy of the record set from the stored procedure as an xml file I can then use as a test instance for testing the maps. Stepping through the map in debug mode gives you a much better Idea of what is going on under the covers.


    Harold Rosenkrans
    • Marked as answer by Hal Rose Wednesday, November 2, 2011 9:21 PM
    Wednesday, November 2, 2011 9:21 PM