none
Looping for N1 segment in EDI X12 850 PO in BizTalk

    Question

  • Hi every one,

    I have to use the N1 segment in the EDI X12 850 PO twice for 'bill to' and 'ship to'. In between the two segments I have to place the PER segment.

    Now I don't know how to implement the above thing.

     

    Thanks in advance,

    Elango

    Wednesday, March 24, 2010 5:31 AM

Answers

  • Hi Elango

    First you need to include return statement in the current scripting functoid which even I missed it earlier. Secondly pass it to scripting function , select inline xslt call template and paste the below xslt there:

    <xsl:template name="MyXsltTemplate">
    <xsl:param name="param1" />
    <xsl:value-of disable-output-escaping="yes" select="$param1"/>
    </xsl:template>

    Map the output of this scripting to N1Loop1

    • Marked as answer by Elango YK Friday, March 26, 2010 12:19 PM
    Friday, March 26, 2010 10:37 AM

All replies

  • Hi Elango

    You can use table looping function and have one row for N1 and one row for PER. This should solve your problem. Let me know if you need any more info.

    Regards

    Nikhil

    Wednesday, March 24, 2010 8:00 AM
  • Hi Nikhil,

    Actually I need like

    N1

    PER

    N1

     

    N1 should  come twice like above and PER should come in between the N1 segments.

     

    I tried the above by mapping first N1 and PER which come under N1Loop1 node in the EDI X12 850 Schema. And tried for second N1 which come under SPILoop1>N1Loop2.

     

    But i am getting error like

    Error: 1 (Segment level error)
        SegmentID: N1
        Position in TS: 4
        2: Unexpected segment

     

    I have to complete this part as soon as possible. Please do the needful as soon as possible..

    Thanks in advance,

    Elango

    Wednesday, March 24, 2010 10:47 AM
  • Hi Elango

    By seeing the error above you are trying to repeat N1 which has maximum occurence of 1. To avoid it you have to loop for the parent node which in this case is N1loop1. This you can achieve by using table looping function or XSLT code.

    N1loop1

    N1

    Per

    N1Loop1

    N1

    This should be your output to get what you desired.

    Wednesday, March 24, 2010 11:40 AM
  • Hi Nikhil,

    Yea I tried the table loop for the parent node N1Loop1. But the PER also coming twice.

     

    And also i am passing the N101 and N103 as constants(Setting the values in properties itself). so these values are same in both of the N1 segment. But it have to change for each N1 segment like following,


    N1*BT*MAXINE MESINGER*92*C053A~

    PER*BD*Craig Hunter~

    N1*ST*MAXINE MESINGER*91*36930410 F~

    How to implement this one. Can you explain in detail.

     

    Thanks in advance,

    Elango.
    Wednesday, March 24, 2010 1:04 PM
  • Hi Elango

    After seeing your output i would suggest you to write xslt. Easy option for you would be write the complete xslt as a string in scripting functoid and then pass it as parameter to another scripting function which will have xslt code just having a return of complete string.

    First scripting functiod you will have to connect all the sources required for creating the three nodes. The script will look like this

    public string fun(inputs....)

    {

    string returnString ="<N1Loop><N1><N101>BT</N1010>....

    }

    let me know if you need more info.

     

    Wednesday, March 24, 2010 4:04 PM
  • Hi Nikhil,

    I am having another doubt that I have to get the PO Header using SP_POHead and PO details(line items) using SP_PODetails.

    Before this i am using a single SP with the two queries. Using JOIN I retrieved both the PO Header and PO Details.

     

    In mapping it came like following,

     

    -Root

       --POHeader

            --H1

            --H2

            --H3

            --PODetails

                --D1

                --D2

                --D3

     

    When i mapped, messages are generated for every Line Item(In this case i am getting 3). But I want every line item in the same message with the POHeader with repeating PO segment.

     

    I don't know how to use different SP( SP_POHead and SP_PODetails) to get the POHeader and PODetails.

    In my SPs. I have to pass every PO Number from SP_POHead to SP_PODetails as a parameter.  here I am confused whether I have to use a new SP which utilizes the above 2 SPs and can return the output or any other way is there.

    Can you help with this.

    Thanks in advance,

    Elango.

    Thursday, March 25, 2010 7:12 AM
  • Hi Elango

    What I suggest is to have one sp to call from biztalk so that you dont have performace impact by calling SQL two times. You can encapsulate both the sp into one that is one option or write a new sp to extract the values from SQL. For having a flat structure in your output like

    -Root

    --POHeader

    --H1

    --H2

    --H3

    --PODetails

    --D1

    --D2

    --D3

    You need to create a temp table or table variable which will have these as columns and then do a select from the temp table or table variable. Ex. Select * into #temp from table1 inner join table2 on table1.column1=table2.column1

    Select * from #temp

    This will do the job for you.

    Regards

    Nikhil

    Dont forget to mention the post as helpful if its helpful and answered if its answered.

    Thursday, March 25, 2010 7:43 AM
  • Hi Nikhil,

    I posted my doubt related to the above topic in another thread(How to get Multiple Line Items(PO segment) in single PO using 2 SP in EDI X12 850 ). Can you help with that.

     

    And I tried the scripting functoid for the N1 loop problem which I posted earlier.

     

    I wrote the scripting in inline C# . The code is like following,

    public string MyConcat(string param1, string param2,string param3,string param4)
    {
        string retStr= "<N1Loop1><N1><N101>BT</N101><N102>" + param1 + "</N102><N103>92</N103><N104>" + param2 + "</N104></N1><PER><PER01>BD</PER01><PER02>" + param4 + "</PER02></PER><N1><N101>ST</N101><N102>" + param1 + "</N102><N103>91</N103><N104>" + param3 + "</N104></N1></N1Loop1>";
    }

     

    But to which node I have to map the output of scripting functoid. You said that I have to use another scripting functoid in XSLT to return the output.

     

    Can you tel me the XSLT code to return the above result and also tel me the destination node.

     

    Thanks in advance,

    Elango

    Friday, March 26, 2010 7:13 AM
  • Hi Elango

    First you need to include return statement in the current scripting functoid which even I missed it earlier. Secondly pass it to scripting function , select inline xslt call template and paste the below xslt there:

    <xsl:template name="MyXsltTemplate">
    <xsl:param name="param1" />
    <xsl:value-of disable-output-escaping="yes" select="$param1"/>
    </xsl:template>

    Map the output of this scripting to N1Loop1

    • Marked as answer by Elango YK Friday, March 26, 2010 12:19 PM
    Friday, March 26, 2010 10:37 AM