none
PO1 & PID Segment Syntax in EDI X12 850 PO RRS feed

  • Question

  • Hi all,

    I am a beginner in BTS.

    I am generating EDI X12 850 PO. Currently I am having the following syntax in my flat file

    ISA

    GS

    ST

    BEG

    N1

    PER

    N1

    PO1

    PO1

    PO1

    PID

    PID

    PID

    CTT

    AMT

    SE

    GE

    IEA

     

    In the above I want the segments PO1 and PID should come alternatively like following for the no of occurrance(In this 3 times)

    PO1

    PID

    PO1

    PID

    PO1

    PID

     

    I tried by using the Inline C# coding in the scripting functoid  with the following coding,

     

     

    public string RetPOPID(string LineRef, string QtyOrd,string PurchUnit, string UnitCost,string VendItemID, string NDC,string UPC, string TranDesc)<br/>
    {<br/>
     string retStr="<PO1Loop1><PO1><PO101>" + LineRef + "</PO101><PO102>" + <br/>
      QtyOrd + "</PO102><PO103>" + PurchUnit + "</PO103><PO104>" + UnitCost + "<br/>
      </PO104><PO105></PO105><PO106>VN</PO106><PO107>" + VendItemID + "</PO107><br/>
      <PO108>ND</PO108><PO109>" + NDC + "</PO109><PO110>UP</PO110><PO111>" + <br/>
      UPC + "</PO111></PO1><PIDLoop1><PID_2><PID01>F</PID01><PID02></PID02><br/>
      <PID03></PID03><PID04></PID04><PID05>" + TranDesc + "</PID05></PID_2><br/>
      </PIDLoop1></PO1Loop1>";<br/>
     return retStr;<br/>
    }<br/>
    
    

    And I gave this scripting functoid as input to another scripting functoid which has the following Inline XSLT Call Template coding

     

    <xsl:template name="MyXsltTemplate"><br/>
    <xsl:param name="LineRef" /><br/>
    <xsl:value-of disable-output-escaping="yes" select="$LineRef"/><br/>
    </xsl:template>
    
    Then I mapped this scripting functoid to the PO1Loop1   segment in the EDI X12 850 PO schema.

     

    But Im getting the following error.

    A message sent to adapter "FILE" on send port "SampleEDIPOSendPort_MCKESSON" with URI "C:\tutorial\OUTPUT\MCKESSON\%MessageID%.txt" is suspended.
     Error details: Unable to read the stream produced by the pipeline.
     Details: Error: 1 (Segment level error)
        SegmentID: CTT
        Position in TS: 5
        7: Segment Not In Proper Sequence

     

    Is this method correct or Is there any other way to achieve this concept.

    I have to finish this concept ASAP. Plz help me ASAP.

    Any Help will be greatly appreciated.


    Regards,
    Elango
    Mark As Answer or Vote As Helpful if My Reply Does.
    Monday, July 19, 2010 12:47 PM

Answers

  • Elango,

    The output of the map that I sent you, run with data created according to your input schema, produces the output following this note.  As you can see, the PO1/PID segments are in the correct order.  Two possibilities come to mind if you are still having difficulty.  Adding new links to the map can break the looping if those links are to any other node within the PO1 loop.  The other possibility is that your data might not be correct -- just because you validate a data file with the schema doesn't mean it is correct.

    <ns0:X12_00401_850 xmlns:ns0="http://schemas.microsoft.com/BizTalk/EDI/X12/2006">
    - <ST>
      <ST01>850</ST01>
      <ST02>8251</ST02>
      </ST>
    - <ns0:BEG>
      <BEG01>00</BEG01>
      <BEG02>SA</BEG02>
      <BEG03>PONbr_0</BEG03>
      <BEG05>20100721</BEG05>
      </ns0:BEG>
    -   <ns0:PO1Loop1>
    -     <ns0:PO1>
          <PO101>111</PO101>
          <PO102>1</PO102>
          <PO103>EA</PO103>
          <PO104>1</PO104>
          <PO106>VN</PO106>
          <PO107>11111</PO107>
          <PO108>ND</PO108>
          <PO109>11111</PO109>
          <PO110>UP</PO110>
          <PO111>11111</PO111>
          </ns0:PO1>
    -       <ns0:PIDLoop1>
    -       <ns0:PID_2>
              <PID01>F</PID01>
              <PID05>TranDesc_8</PID05>
            </ns0:PID_2>
          </ns0:PIDLoop1>
        </ns0:PO1Loop1>
    -   <ns0:PO1Loop1>
    -     <ns0:PO1>
            <PO101>222</PO101>
            <PO102>2</PO102>
            <PO103>EA</PO103>
            <PO104>2</PO104>
            <PO106>VN</PO106>
            <PO107>22222</PO107>
            <PO108>ND</PO108>
            <PO109>22222</PO109>
            <PO110>UP</PO110>
            <PO111>22222</PO111>
          </ns0:PO1>
    -   <ns0:PIDLoop1>
    -     <ns0:PID_2>
            <PID01>F</PID01>
            <PID05>TranDesc_8</PID05>
          </ns0:PID_2>
        </ns0:PIDLoop1>
      </ns0:PO1Loop1>
    - <ns0:CTTLoop1>
    - <ns0:CTT>
      <CTT01>10</CTT01>
      <CTT02>10.4</CTT02>
      </ns0:CTT>
    - <ns0:AMT_3>
      <AMT01>TT</AMT01>
      <AMT02>10.4</AMT02>
      </ns0:AMT_3>
      </ns0:CTTLoop1>
    - <SE>
      <SE01>10</SE01>
      <SE02>8251</SE02>
      </SE>
      </ns0:X12_00401_850>

     


    Jim -- Pro Mapping in BizTalk 2009, Apress Books, March 23, 2009
    • Marked as answer by Elango YK Monday, July 26, 2010 4:41 AM
    Friday, July 23, 2010 2:00 PM

All replies

  • This is a common looping issue, but without knowing the format of your input schema the question is difficult to answer.  Please post a sample of your input or post the input schema.  You might also email me and send me a copy of the schema and data file.  jim@secondstaredi.com

     


    Jim -- Pro Mapping in BizTalk 2009, Apress Books, March 23, 2009
    Monday, July 19, 2010 2:22 PM
  • Hi Elango,

    You are attempting to populate the BizTalk EDI 850 Schema using a map.  In this scenario all of the required/mandatory element/nodes of the output schema should have a valid value and be in the required order as defined by the schema.  I believe the PO1 Segment is required and the PID segment is optional and must comes after the P01 segment.  

    I would modify the output EDI 850 schema to reflect the desired order.  (Add a sequence around the P01 and PID segments, keep the P01 required and PID as optional)

    Once the output schema is defined properly, the EDI Assembler component will assemble the outgoing EDI in the format which you are looking for.

    Thanks,

    William

    Monday, July 19, 2010 2:34 PM
  • William's post is confusing to me.  The 850 schema, assuming you are using the BT schemas, is already in the correct structure.  The PO1 segment and the PID segment are within the PO1 loop as they should be.  No modification of the schema should be needed.  The input schema, on the other hand, may not be ordered properly.  Since you should not have to modify the 850 schema and may not be allowed to modify the input schema, proper mapping is needed to solve the problem.  Whether you use looping functoids or you use XSLT to solve the problem can not be determined without seeing the structure of the input.

    If the flat file structure shown above is your input structure, then there are several methods available to you.  Generally, my preference is to gather the data into an array at the start of the map, making it available for retrieval in any order desired.


    Jim -- Pro Mapping in BizTalk 2009, Apress Books, March 23, 2009
    Monday, July 19, 2010 2:42 PM
  • Hi Jim,

    Here is the structure my input schema which is appearing in the BizTalk mapper,

    Root

       --Header

            --H1

            --H2

            --H3

            --LineItems

                --PONbr

                --LineRef

                --QtyOrd

                --PurchUnit

                --UnitCost

                --VendItemID

                --NDC

                --UPC

                --TranDesc

     

    Im retrieving input data from sql. The input msg would be like following,

    <RootIn xmlns="http://SampleEDIPO">

    <Header PONbr="P0224P157" PODate="20090428" Name="Associates in ID of" CustID="C157" VendEDICode="023904428" VendAcct="3972745   " Buyer="Klentrease Simmonds" POAmt="8.24" POItemTotal="2" LineCntr="1">

    <LineItems PONbr="P0224P157           " LineRef="00001" QtyOrd="2" PurchUnit="BX        " UnitCost="4.12" VendItemID="370845         " NDC="99999020300    " UPC="99999020300                   " TranDesc="WIPES, GERMICIDAL, SANI CLOTH LARGE (Q89072 - 160/BX)       " />

    <LineItems PONbr="P0224P157           " LineRef="00002" QtyOrd="2" PurchUnit="BX        " UnitCost="4.12" VendItemID="370846         " NDC="99999020300    " UPC="99999020300                   " TranDesc="WIPES, GERMICIDAL, SANI CLOTH LARGE (Q89072 - 160/BX)       " />

    <LineItems PONbr="P0224P157           " LineRef="00003" QtyOrd="2" PurchUnit="BX        " UnitCost="4.12" VendItemID="370847         " NDC="99999020300    " UPC="99999020300                   " TranDesc="WIPES, GERMICIDAL, SANI CLOTH LARGE (Q89072 - 160/BX)       " />

    </Header></RootIn>

     

    In the above input data I am mapping the data from LineItems node(all fields except TranDesc) into PO1 segement and TranDesc field into PID segment.

     

    And my destination schema is an EDI X12 850 standard schema.

    Also I have sent a mail to your mail id(jim@secondstaredi.com ) with subject Elango YK - MSDN help . And I have attached the following files.

    • Input schema
    • Property schema (used to promote a node for content based routing)
    • Output schema
    • Map file

    Please refer those files and help ASAP.


    Regards,
    Elango
    Mark As Answer or Vote As Helpful if My Reply Does.
    Tuesday, July 20, 2010 1:05 PM
  • Hi Willliam,

    I cant understand the solution for my post from your reply. Can you explain me in detail.

    Please help me ASAP.


    Regards,
    Elango
    Mark As Answer or Vote As Helpful if My Reply Does.
    Tuesday, July 20, 2010 1:07 PM
  • Elango,

    I just emailed you a map that now outputs the PO1/PID correctly.  You can use the same technique for the N1 loops.   As soon as I can I'll blog the solution, but I'm in the middle of moving the web site and the blog is not active yet.

    Hope this helps,

     


    Jim -- Pro Mapping in BizTalk 2009, Apress Books, March 23, 2009

     

    Here is the link, which you will have to copy and paste into your browser.  For some reason it doesn't work when you click from here.  Anyone who knows why please let me know what is wrong.   http://03123b2.netsolhost.com/lostboysthinking/

    Tuesday, July 20, 2010 3:08 PM
  • Hi Jim,

    I have used your files which u sent by mail. But still im not getting the output. Im getting the following error.

    xlang/s engine event log entry: Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'SampleEDIPO.Orchestration_1(485f5fb3-9688-f1ed-ec62-72f1ad99b8f5)'.
    The service instance will remain suspended until administratively resumed or terminated.
    If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
    InstanceId: 5c1beb3c-d563-474e-a047-b44da8df5dc5
    Shape name: ConstructMessage_1
    ShapeId: c8fbe09d-6e5e-4756-a01c-88627dbc254d
    Exception thrown from: segment 1, progress 6
    Inner exception: Error encountered while executing the transform SampleEDIPO.SampleEDIPOMap. Error:Transformation failed..
           
    Exception type: XTransformationFailureException
    Source: Microsoft.XLANGs.Engine
    Target Site: Void ApplyInMemoryTransform(System.Type, Microsoft.XLANGs.RuntimeTypes.TransformMetaData, System.Object[], System.Object[])
    The following is a stack trace that identifies the location where the exception occured

       at Microsoft.XLANGs.Core.Service.ApplyInMemoryTransform(Type mapRef, TransformMetaData trfMetaData, Object[] outParams, Object[] inParams)
       at Microsoft.XLANGs.Core.Service.ApplyTransform(Type mapRef, Object[] outParams, Object[] inParams)
       at SampleEDIPO.Orchestration_1.segment1(StopConditions stopOn)
       at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
    Additional error information:

            The variable or parameter 'refqual' is either not defined or it is out of scope.
           
    Exception type: XsltException
    Source: System.Data.SqlXml
    Target Site: System.Xml.Xsl.IXsltContextVariable ResolveVariable(System.String, System.String)
    The following is a stack trace that identifies the location where the exception occured

       at System.Xml.Xsl.XsltOld.XsltCompileContext.ResolveVariable(String prefix, String name)
       at MS.Internal.Xml.XPath.VariableQuery.SetXsltContext(XsltContext context)
       at System.Xml.Xsl.XsltOld.Processor.GetValueQuery(Int32 key, XsltCompileContext context)
       at System.Xml.Xsl.XsltOld.Processor.ValueOf(ActionFrame context, Int32 key)
       at System.Xml.Xsl.XsltOld.ValueOfAction.Execute(Processor processor, ActionFrame frame)
       at System.Xml.Xsl.XsltOld.ActionFrame.Execute(Processor processor)
       at System.Xml.Xsl.XsltOld.Processor.Execute()
       at System.Xml.Xsl.XsltOld.Processor.Execute(Stream stream)
       at System.Xml.Xsl.XslTransform.Transform(XPathNavigator input, XsltArgumentList args, Stream output, XmlResolver resolver)
       at System.Xml.Xsl.XslTransform.Transform(IXPathNavigable input, XsltArgumentList args, Stream output, XmlResolver resolver)
       at Microsoft.XLANGs.Core.Service.ApplyInMemoryTransform(Type mapRef, TransformMetaData trfMetaData, Object[] outParams, Object[] inParams)

    I tried to troubleshoot but I cant.

    Also in ur map there is no mapping from the source schema for the PO1 and PID segments. I think u did some coding in background. But I cant understand it. Can u explain me in detail. Then I can also try by ur method.

    Please help ASAP.


    Regards,
    Elango
    Mark As Answer or Vote As Helpful if My Reply Does.
    Thursday, July 22, 2010 1:43 PM
  • Think I sent you an older version of the script that still had a reference to "refqual".  Copy and paste error.

    <!--******************************************************
    Creates the PID segment
    *******************************************************-->
    <xsl:template name="PID">
    <xsl:param name="description" />
    <xsl:if test="$description != ''">
    <xsl:element name="ns0:PIDLoop1">
    <xsl:element name="ns0:PID_2">
    <xsl:element name="PID01">F</xsl:element>
    <xsl:element name="PID05"><xsl:value-of select="$description"/></xsl:element>
    </xsl:element>
    </xsl:element>
    </xsl:if>      
    </xsl:template>

     


    Jim -- Pro Mapping in BizTalk 2009, Apress Books, March 23, 2009
    Thursday, July 22, 2010 1:55 PM
  • Hi Jim,

    I used ur latest coding and got some output files which is the same output i am getting already like following,

    PO1

    PO1

    PO1

    PID

    PID

    PID

    But I need the output like following,

    PO1

    PID

    PO1

    PID

    PO1

    PID

     

    Like in the above example I need the PO1 & PID segments coming alternatively.

    Thanks for your continuous help. I need your help for this also.

    Please help me ASAP.


    Regards,
    Elango
    Mark As Answer or Vote As Helpful if My Reply Does.
    Friday, July 23, 2010 12:04 PM
  • Elango,

    The output of the map that I sent you, run with data created according to your input schema, produces the output following this note.  As you can see, the PO1/PID segments are in the correct order.  Two possibilities come to mind if you are still having difficulty.  Adding new links to the map can break the looping if those links are to any other node within the PO1 loop.  The other possibility is that your data might not be correct -- just because you validate a data file with the schema doesn't mean it is correct.

    <ns0:X12_00401_850 xmlns:ns0="http://schemas.microsoft.com/BizTalk/EDI/X12/2006">
    - <ST>
      <ST01>850</ST01>
      <ST02>8251</ST02>
      </ST>
    - <ns0:BEG>
      <BEG01>00</BEG01>
      <BEG02>SA</BEG02>
      <BEG03>PONbr_0</BEG03>
      <BEG05>20100721</BEG05>
      </ns0:BEG>
    -   <ns0:PO1Loop1>
    -     <ns0:PO1>
          <PO101>111</PO101>
          <PO102>1</PO102>
          <PO103>EA</PO103>
          <PO104>1</PO104>
          <PO106>VN</PO106>
          <PO107>11111</PO107>
          <PO108>ND</PO108>
          <PO109>11111</PO109>
          <PO110>UP</PO110>
          <PO111>11111</PO111>
          </ns0:PO1>
    -       <ns0:PIDLoop1>
    -       <ns0:PID_2>
              <PID01>F</PID01>
              <PID05>TranDesc_8</PID05>
            </ns0:PID_2>
          </ns0:PIDLoop1>
        </ns0:PO1Loop1>
    -   <ns0:PO1Loop1>
    -     <ns0:PO1>
            <PO101>222</PO101>
            <PO102>2</PO102>
            <PO103>EA</PO103>
            <PO104>2</PO104>
            <PO106>VN</PO106>
            <PO107>22222</PO107>
            <PO108>ND</PO108>
            <PO109>22222</PO109>
            <PO110>UP</PO110>
            <PO111>22222</PO111>
          </ns0:PO1>
    -   <ns0:PIDLoop1>
    -     <ns0:PID_2>
            <PID01>F</PID01>
            <PID05>TranDesc_8</PID05>
          </ns0:PID_2>
        </ns0:PIDLoop1>
      </ns0:PO1Loop1>
    - <ns0:CTTLoop1>
    - <ns0:CTT>
      <CTT01>10</CTT01>
      <CTT02>10.4</CTT02>
      </ns0:CTT>
    - <ns0:AMT_3>
      <AMT01>TT</AMT01>
      <AMT02>10.4</AMT02>
      </ns0:AMT_3>
      </ns0:CTTLoop1>
    - <SE>
      <SE01>10</SE01>
      <SE02>8251</SE02>
      </SE>
      </ns0:X12_00401_850>

     


    Jim -- Pro Mapping in BizTalk 2009, Apress Books, March 23, 2009
    • Marked as answer by Elango YK Monday, July 26, 2010 4:41 AM
    Friday, July 23, 2010 2:00 PM