none
Question about mapping with FLATFILE and EDIFACT message using BizTalk 2013 EDI Functionality RRS feed

  • Question

  • Hi,

    We have a situation using BizTalk Mapper (a single map), the source schema is a FLATFILE and the destination schema is a EDIFACT (EFACT_D96A_ORDERS.xsd).

    In the source schema we have a single line in the flatfile like this: 

    Cond. Pagto:  20/10/14 60%  20/11/14 40%

    And the destination schema we have a create a EDIFACT message like this:

    PAT+3++66'
    DTM+13:20141020:102'
    PCD+7:60'
    PAT+3++66'
    DTM+13:20141114:102'

    PCD+7:40'

    The question is: How to split the date (20/10/14 and 20/11/14 is a date) and two or more DTM segment ?

    Any help will be appreciated!

    Doug.

    Friday, September 18, 2015 5:17 PM

All replies

  • Hi Doug,

    Can you please share what kind of source schema you have created. Seems like you have repeated record in the source flat file 20/10/14 60%  20/11/14 40%. Now on the basis of source repeating record you can manipulate the EDIFACT reocrd DTM by adding an looping functoid. Connect a link from your repeating record from your source schema to the looping functoid and also connect an link from the DTM to the looping record. Make sure your source record and DTM are both marked as UNBOUNDED.

    Please indicate "Mark as Answer" or "Mark as Helpful" if this post has answered the question

    Regards

    Rahul Madaan

    biztalkvillage.blogspot.com


    Friday, September 18, 2015 6:29 PM
  • If the structure is consistent, meaning always two dates and two percentages, then you can treat that line as simple space delimited values.  Meaning, the flat file disassembler can treat the space character as a delimiter just like a comma or pipe.

    If the line is a bit more free form, you would have to create up to 4 C# Functoids, each being smart enough to parse out the specific value it should return.

    Friday, September 18, 2015 7:04 PM
  • Please send the C# Functoid examples for this case?

    Thanks,

    D.

    Friday, September 18, 2015 8:15 PM
  • Well, we don't really know what your rules are.

    Start with String.Split() and go form there.

    Friday, September 18, 2015 10:26 PM
  • Hi Rahul, thanks for your reply.

    In my source schema I have just one element (Observação field in source schema) with two data (a date and percentual value) in the same field, for example the string: 
    20/10/14 60%  20/11/14 40%
    I don't know how many date and percentual we have, and I need to link two field in the destination schema (date and percentual value).

    Sounds like this (attach file).

     I don't know how to develop the script functoid to split the string and fill the fields in the destination schema.

    Thanks again,

    Doug.

    Tuesday, September 22, 2015 11:20 AM
  • Hi Doug,

    Use Xslt. The solution will use three “Inline XSLT Call Template” scripting functoids

    1. Add the first “Inline XSLT Call Template” scripting functoid to you map.

    The functoid will have no input or output parameters.

     <xsl:template name="DTM" xmlns:ns0="http://schemas.microsoft.com/BizTalk/EDI/EDIFACT/2006">

        <xsl:param name="DTM_Date"/>

        <xsl:param name="PCD_qualifier"/>

        <ns0:PATLoop1>

          <ns0:PAT>

            <PAT01>3</PAT01>

            <ns0:C112>

              <C11201>66</C11201>

            </ns0:C112>

          </ns0:PAT>

          <ns0:DTM_6>

            <ns0:C507_6>

              <C50701>13</C50701>

              <C50702>

                <xsl:value-of select="$DTM_Date"/>

              </C50702>

              <C50703>102</C50703>

            </ns0:C507_6>

          </ns0:DTM_6>

          <ns0:PCD_2>

            <ns0:C501_2>

              <C50101>7</C50101>

              <C50102>

                <xsl:value-of select="$PCD_qualifier"/>

              </C50102>

            </ns0:C501_2>

          </ns0:PCD_2>

        </ns0:PATLoop1>

      </xsl:template>

    2. Add the  second functoid

    The functoid will have no input or output parameters.

      <xsl:template name="tokens">

        <xsl:param name="str" select="."/>

        <xsl:param name="splitString" select="' '"/>

        <xsl:choose>

          <xsl:when test="contains($str,$splitString)">

            <Line>

              <xsl:value-of select="substring-before($str,$splitString)"/>

            </Line>

            <xsl:call-template name="tokens">

              <xsl:with-param name="str" select="substring-after($str,$splitString)"/>

              <xsl:with-param name="splitString" select="$splitString"/>

            </xsl:call-template>

          </xsl:when>

          <xsl:otherwise>

            <Line>

              <xsl:value-of select="$str"/>

            </Line>

          </xsl:otherwise>

        </xsl:choose>

      </xsl:template>

    3. Add the third “Inline XSLT Call Template” scripting functoid to you map.

    Use your “single line” as the input and map the functoid to the “PATLoop1” element.

      <xsl:template name="CreateDTMSegments">

        <xsl:param name="stringInput"/>

        <xsl:variable name="LineArray">

          <xsl:call-template name="tokens">

            <xsl:with-param name="str" select="translate(normalize-space(substring($stringInput,1, string-length($stringInput)-1)),' ','')"/>

            <xsl:with-param name="splitString" select="'%'"/>

          </xsl:call-template>

        </xsl:variable>

        <xsl:for-each select="msxsl:node-set($LineArray)//Line">

          <xsl:call-template name="DTM">

            <xsl:with-param name="DTM_Date" select="concat(concat('20',substring(.,7,2)),substring(.,4,2),substring(.,1,2))"/>

            <xsl:with-param name="PCD_qualifier" select="substring(.,9,2)"/>

          </xsl:call-template>

        </xsl:for-each>

     </xsl:template>

    Best regards 

    Rasmus Jaeger

    Monday, January 4, 2016 1:17 PM