Issue with XSLT For each loop in B2B Mapping

Hi All,
I am trying to map the inbound 997 Payload into Headers and Lines Table. I am using the For Each XSLT Construct to map the Loop AK2 of 997 into the 997 Lines Collection.
Issue I am facing is that if the Loop AK2 is repeated for 33 times then for all the 33 times only its first element's value is getting passed into the target of mapping file.
in coming payload
<Loop-AK2>
<Segment-AK2>
<Element-143>810</Element-143>
<Element-329>0001</Element-329>
</Segment-AK2>
<Segment-AK5>
<Element-717>A</Element-717>
</Segment-AK5>
</Loop-AK2>
<Loop-AK2>
<Segment-AK2>
<Element-143>810</Element-143>
<Element-329>0002</Element-329>
</Segment-AK2>
<Segment-AK5>
<Element-717>A</Element-717>
</Segment-AK5>
</Loop-AK2>
<Loop-AK2>
<Segment-AK2>
<Element-143>810</Element-143>
<Element-329>0003</Element-329>
</Segment-AK2>
<Segment-AK5>After transformation using XSLT file the payload looks like as follows
<ns0:XxmfiEdi997_AckLines>
<ns0:lineId>33</ns0:lineId>
<ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
<ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
<ns0:segmentCode/>
<ns0:segmentPosition/>
<ns0:segmentError/>
<ns0:trxSetAckCode>A</ns0:trxSetAckCode>
</ns0:XxmfiEdi997_AckLines>
<ns0:XxmfiEdi997_AckLines>
<ns0:lineId>34</ns0:lineId>
<ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
<ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
<ns0:segmentCode/>
<ns0:segmentPosition/>
<ns0:segmentError/>
<ns0:trxSetAckCode>A</ns0:trxSetAckCode>
</ns0:XxmfiEdi997_AckLines>
<ns0:XxmfiEdi997_AckLines>
<ns0:lineId>35</ns0:lineId>
<ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
<ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
<ns0:segmentCode/>
<ns0:segmentPosition/>
<ns0:segmentError/>
<ns0:trxSetAckCode>A</ns0:trxSetAckCode>
</ns0:XxmfiEdi997_AckLines>
<ns0:XxmfiEdi997_AckLines>
<ns0:lineId>36</ns0:lineId>
<ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
<ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
<ns0:segmentCode/>
<ns0:segmentPosition/>
<ns0:segmentError/>
<ns0:trxSetAckCode>A</ns0:trxSetAckCode>
</ns0:XxmfiEdi997_AckLines>
<ns0:XxmfiEdi997_AckLines>
<ns0:lineId>37</ns0:lineId>
<ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
<ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
<ns0:segmentCode/>
<ns0:segmentPosition/>the Element-329 of incoming source payload is mapped to trxSetControlNumber of target payload, the issue is obvious from the above XML data that trxSetControlNumber is always having the value 0001 for every occurence where as its expected to fetch the value of the element of its corresponding occurence not the first elements value.
Please find below the xslt file code i used for mapping
<ns0:XxmfiEdi997_AckHeadersCollection>
      <ns0:XxmfiEdi997_AckHeaders>
        <ns0:headerId>
          <xsl:value-of select='oraext:sequence-next-val("XXMFI_EDI_997_ACK_HEADERS_S","jdbc/MTSI-apps")'/>
        </ns0:headerId>
        <ns0:processFlag>
          <xsl:text disable-output-escaping="no">I</xsl:text>
        </ns0:processFlag>
         <ns0:xxmfiEdi997_AckLinesCollection>
          <xsl:for-each select="/ns1:Transaction-997/ns1:Loop-AK2">
            <ns0:XxmfiEdi997_AckLines>
              <ns0:lineId>
                <xsl:value-of select='oraext:sequence-next-val("XXMFI_EDI_997_ACK_LINES_S","jdbc/MTSI-apps")'/>
              </ns0:lineId>
              <ns0:trxSetIdentCode>
                <xsl:value-of select="/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK2/ns1:Element-143"/>
              </ns0:trxSetIdentCode>
              <ns0:trxSetControlNumber>
                <xsl:value-of select="ns1:Segment-AK2/ns1:Element-329"/>
              </ns0:trxSetControlNumber>
              <ns0:segmentError>
                <xsl:value-of select="/ns1:Transaction-997/ns1:Loop-AK2/ns1:Loop-AK3/ns1:Segment-AK3/ns1:Element-720"/>
              </ns0:segmentError>
              <ns0:trxSetAckCode>
                <xsl:value-of select="/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK5/ns1:Element-717"/>
              </ns0:trxSetAckCode>
            </ns0:XxmfiEdi997_AckLines>
          </xsl:for-each>
        </ns0:xxmfiEdi997_AckLinesCollection>
      </ns0:XxmfiEdi997_AckHeaders>Is there something I am doing wrong in mapping or am I missing something here. Please suggest .
Thanks in advance
~TK.

Hi,
In your xslt code within the for loop, for the trxSetIdentCode why are you using the xpath "/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK2/ns1:Element-143"? It should be just "ns1:Segment-AK2/ns1:Element-143". Similar changes for segmentError and trxSetAckCode also should be done. Remove the '/ns1:Transaction-997/ns1:Loop-AK2/' part from your xpath expressions inside the for loop and try it.
Sahay

Similar Messages

  • SQL Agent Permssions With SSIS for each loop not looping through files

    Hi I am Having trouble getting a ssis package to iterate through a file directory using a proxy account set up in Sql Server.
    So I have a package that loops over csv files. If I run the package manually or set the sql agent job to run as Sysadmin the pakage runs fine all files are processed.
    However if I use the proxy account. the package completes but no files are processed. there are no failures, there is no error handling set up in the control flow. the for each loop container simply does not recognise any files when run under a proxy.
    Note: the proxy is set up with credentials to access the folder. the credential is also set up with the server admin server role... still nothing
    i'm not sure is this is a ssis or permissions problem?
    Any comments will be appreciated

    Can you check this and see if you've configured all the steps correctly
    http://www.mssqltips.com/sqlservertip/2163/running-a-ssis-package-from-sql-server-agent-using-a-proxy-account/
    Also enable logging in package and see if you're getting any error messages obtained in output table/file based on the logging option you chose.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • XSLT For-each loop issue

    Hi All,
    I have a below requirement:
    two source nodes:
    <NODE1>
         <NODE2>
    Here node 2 is optional. i want to check if node 2 is present, if it is present then for-each value of node 2
    if not the the for each must be based on the value of the parent node which is node1.
    Can anyone help me out on this..
    Thanks in Advance!

    Hi,
    In your xslt code within the for loop, for the trxSetIdentCode why are you using the xpath "/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK2/ns1:Element-143"? It should be just "ns1:Segment-AK2/ns1:Element-143". Similar changes for segmentError and trxSetAckCode also should be done. Remove the '/ns1:Transaction-997/ns1:Loop-AK2/' part from your xpath expressions inside the for loop and try it.
    Sahay

  • Custom List with for-each loop

    How do I get a list I am making to be able to be used with a for-each loop?

    As far as I know there is no "for-each" loop in Java, there is however a "for" loop. Is that what you're referring to?
    To use a for loop, let's say you have an array like the following, you could iterate through it like this:
    String[] str = new String[]{"a", "b", "c", "d", "e"};
    for (int i = 0; i < str.length; i++)
             System.out.println(str);
    hope this help you get started ;-)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • For each loop start on odd page number

    Hy,
    I've an rtf template with a for each loop. I want to skip a page between each loop and to start each new loop on an odd page number (duplex printing). It's easy to skip a page but i don't know how to start each loop on an odd page. i've tried this before or after my for-each
    <?section:force-page-count;'end-on-even-layout'?>
    but it doesn't work for me.
    Sorry for my english
    regards

    One way of doing this is to create an object (B_1) at the end of the report and only have the object print if the current page is an odd page.
    - To force the page break, you need to set the "page break before" property against "B_1".
    - To test the page number in the format trigger use the srw.get_page_num(page_num out number) built-in function.
    You need to make sure that "B_1" is formatted after all the other objects in the layout. One way of ensuring this is to create a frame around all the other objects and make the frame variable. Any objects that come below the frame will be formatted after the variable frame.
    There is still the issue of any margin objects. Since margin objects print before any objects in the body, your margin objects will still print in the overflow page. However, this may be what you want if you're printing the page number in the margin.

  • For each loop and modification of a LinkedList

    When going thourhg my LinkedList with a for each loop, I want to do a modification. I just saw that it cast a ConcurrentModification Exception, so it seems I can't do that.
    How should I do then? I don't want to go through all the list each time an object is removed, I want it to restart where it stopped.

    Not the best solution but something like thisshould work:
    if( linkedList.get(i) == "modification")No: don't compare Strings with the == operator.
    http://access1.sun.com/FAQSets/newtojavatechfaq.html#9
    You are correct, must be .equals() my bad.

  • How to use for each loop in XSLT when my source is a multilayout file and db

    How do I use a for each loop in XSLT when my source is multilayout file and db .
    My multilayout file is basically contain 2 kind of data one for employee and another for dependent.
    Now my requirement is I want to read each line of data whether it is it is employee or dependent do a join with db and write it in my target file.
    eg :  File content
    1 RichaKumari 311289 TCS INDIA
    2 KiarnKumar 456782 BRO RichaKumari 311289 INDIA
    2 Ravi            456882 BRO RichaKumari 311289 INDIA
    eg : db Content
    311289 RichaKumari TCS INDIA Bangalore [email protected]
    Now in Final File I need something like this :
    1 RichaKumari 311289 TCS INDIA
    2 KiarnKumar RichaKumari 311289 TCS INDIA
    2 Ravi            RichaKumari 311289 TCS INDIA
    here 1 and 2 are the identifier which will decide which layout to follow .

    Hi,
    I think you'll need two nested for-each's... Something like...
    <xsl:for-each select="$root/row[layout = 1]">
    <xsl:variable name="employee" select="."/>
    ... write employee ...
    <xsl:for-each select="$root/row[layout = 2 and dependentid = $employee/id]">
    ... write dependent ...
    </xsl:for-each>
    </xsl:for-each>
    Cheers,
    Vlad

  • Issues with nested for loops - saving images from a camera

    Hi all,
    I've written a vi. to capture a specific number of images ('Image No') and save these images, outputted to a folder of my choice.  Each image is identified sequentially.  However, I wish to do a number of iterations ('Run') of this capture sequence, such that the filename of each image would be 'Filename (Run)_(Image No).png', e.g. run 5, image 10 would be 'Filename 5_10.png'.  I have tried a nested for loop for this but I receive an error 'Asynchronous I/O operation in progress' (I've attached a printscreen).
    Can anyone assist me in solving this problem? I preiously posted this in machine Vision but got no response (http://forums.ni.com/t5/Machine-Vision/Capturing-image-sequences-issues-with-nested-for-loops/m-p/19...).  Please find attached my vi.
    Kindest regards and thanks,
    Miika
    Solved!
    Go to Solution.
    Attachments:
    Labview problem.jpg ‏3841 KB
    Image sequence save to file.vi ‏48 KB

    Miika,
    the problem is not the filenam, but the name of the folder (AHHHHH!). You try to create the same folder in the outer for loop over and over again.... (it is the error message above the '======', not below )
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • For Each Loop Issue In SSIS

    Hi All,
    I have a SSIS Package which unzips the folder and then imports the files and then moves *.zip folders into processed location. If this task is executed as a part of total package its not moving the *.zip folders into processed location, but when we execute
    for each loop alone this *.zip folders are moved into processed location. I am unable to figure out the issue here.
    ZippedFile variable holds fully qualified file name..
    Rohan
    Rohan

    Can you put a OnPreExec breakpoint on the file system task (Right click on the file system task > Edit Breakpoint... > Select the first (OnPreExec breakpoint) and when the pkg pauses @ the breakpoint, chk the value of the ZippedFle and FilePathDestination
    variable values in your Local window (should be available at the bottom of the SSIS window as one of the tabs and you will need to expand the variable tree and find these two variables and their values). Are you seeing the appropriate values here?

  • For Each Loop for XML Task

    Hello Everyone,
    Please assist with a step by step guide on how to setup a For Each Loop for XML Task
    I'm trying to convert XML to XSLT
    I have tried more than 10 times and i just do not know what i am doing wrong - no error, my package just runs for a few seconds but nothing happens
    Thanks in advance
    Dee

    I managed to get my XML to XSLT to work but now when i run my package to import the data into SQL table,
    it stops after a few records, i get the following error: 
    [XML Source [1]] Error: The component "XML Source" (1) was unable to process the XML data. The element "Errors" cannot contain a child element. Content model is text only.
    Please assist
    Check this:
    http://social.msdn.microsoft.com/Forums/en-US/80726e0c-9e85-43ca-87bc-7cf90fd7fb31/xml-source-data-flow-throws-cannot-contain-a-child-element-content-model-is-text-only-error?forum=sqlintegrationservices
    Chaos isn’t a pit. Chaos is a ladder. Many who try to climb it fail and never get to try again. The fall breaks them. And some are given a chance to climb, but they refuse. They cling to the realm, or the gods, or love. Illusions. Only the ladder is real.
    The climb is all there is.

  • For Each Loop: Truncation error on excel field

    In my SSIS package, I'm using a WMI file watcher combined with a ForEach loop to process excel files and load them into a SQL Server database as they are deposited in a drop box folder. Recently I've been getting truncation errors on one of my fields (Comments).
    I know that this is because Excel is scanning the first 8 rows to determine column length and there are several records that have a comments field that is greater than what excel determined.
    I've tried going to the excel editor in my advanced editor and setting the data type length of my external and output columns to a larger length (500 W_STR vs 255 W_STR) but I get a warning saying that the data type is not valid. I've tried adding IMEX=1
    to my extended properties in my excel connection string but no dice. Still getting truncation errors.
    I was wondering if anyone had any thoughts or suggestions? I'm always getting new files so the comments field will potentially always encounter this type of error. This SSIS package runs on a production server so making a Registry change to the excel drivers
    regarding the scanning of the first 8 rows is not an option for me.
    Migince

    I wound up making the registry change for # of rows scanned by excel and that seemed to solve the issue.
    I tried utilizing an excel template but every time my for each loop scanned for a new file, the metadata was updated with whatever column length was in the first 8 records of my new file. If you've got a good example of building an excel template to set
    the column length metadata in my excel source (For Each Loop) I would love to take a look at it. Good information to know.

  • SSIS Help For each Loop Container

    I need a little help with this process that I am developing. I am fairly new to SSIS so please bear with me. I have done research online so If I seem limited in my knowledge please apologize me.
    Requirement: I have a folder where we will have flat files monthly they could be one or more...
    each file will have the following name standard "123456.EEAKQ2.EASDREWA12A.BID".
    What I need to do is maintain a table which will have filename and date when it was added to the folder.
    I have created a package with the following components "For each loop" which grabs files from a source folder.
    This is where I am stuck. I need to grab the file name from the path and insert it into the table.
    Can someone help me with this?
    Thank you
    FM
    FM

    See similar requirement implemented here
    What you need is to declare and use a variable inside for each loop to get filename each time. Then you may use script task to check for pattern within the file for identifying correct files
    http://visakhm.blogspot.in/2012/05/package-to-implement-daily-processing.html
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Need to access parent elements in nested for-each loop

    Hi All,
    I have a xslt mapping requirement in which I am completely stuck. The details are as listed below. Please help!
    Schema structure is as follows:
    Root
    Payload
    Transaction-123
    Loop-LINE
    Loop-SDPP
    Segment-FSTT
    Element-111
    Required xslt file structure is:
    <xsl:for-each Loop-LINE>
    <tns:Item>
    <Line-1000>
    <Line-2000>
    <Line-3000>
    <Line-8000>
    <xsl:for-each Loop-SDPP>
    <xsl:for-each Segment-FSTT[ns0:Element-111 != "A"]>
    <SDetails>
    </SDetails>
    <xsl:for-each Loop-LINE> --------- How to access Loop-LINE element from this for loop????
    <tns:Item>
    <2000>
    <2020>
    <2070>
    <2150>
    </tns:Item>
    </xsl:for-each>
    </for-each>
    </for-each>
    </tns:item>
    </for-each>
    Need help in understanding how can I run a for-each loop for Loop-LINE which is two levels up in the schema tree structure.
    Thanks..

    Thanks for this answer but I can't obtain the right output with my test case; the multi column must be in the loop as that :
    ALPHABETICAL INDEX C1
    Alternator .......................................... Feed Pump
    Belt Details / Engine Gaskets Sets ..... Flywheel Housing
    < NEW PAGE>
    INDEX ALPHABETIQUE C2
    Alternateur......................................... Culbuteurs
    Bloc-Cylindres.................................... Demarreur
    Denis

  • For each loop container executing multiple times....

    Hi,
    We are using SQL SERVER version 2005.
    I am having a For each loop container and inside that container there are multiple Sequence containers and inside each sequence containers there are Execute SQL Tasks (which are just stored procedures).
    Now, when i run sequence containers individually they are running perfectly fine.
    But when I run the whole For each loop container, it is just running and running multiple times without ending the process.
    I really couldnt figure out what would be the issue?
    Any ideas????
    Thanks....

    Hi grk666,
    To check whether the values stored in the object type variable are correct, you can disable all the Sequence Containers within the Foreach Loop Container, and add a Script Task with the following code to display the string type variable value (supposing
    you use the string type variable StrVar to store the value retrieved from the object variable):
    MsgBox(Dts.Variables(“StrVar”).Value.ToString())
    It would be helpful if you could post a screenshot to show the package execution at runtime in BIDS.
    Regards,
    Mike Yin
    TechNet Community Support

  • Loading accdb file using for each loop in to single target table

    I have 3 accdb file as below in single folder, in control flow I have created a for each loop to loop through all the below file.  In dataflow task I have created oledb source using connection manager to point to first file a1.accdb. I am trying
    to load all the file into single below mentioned target table, here It is only loading first file it is not looping through other two file.
    This I have tried to load .txt files and csv files it is working perfectly but similarly when I try to load access db file table it is not working, can any one of you help me?
    1. a1.accdb contains only one table  a1tab ( col1 col2 col3 )  
    2. a2.accdb  contains only one table  a2tab  ( col1 col2 col3 )
    3. a3.accdb  contains only one table  a3tab   ( col1 col2 col3 )
    I have a target table with similar structure as source
    Target table <TargetTable> Col1 Col2 Col3
    aak

    Thanks Arthur, please find below response
    How do you handle the different table names?  Cant we handle it in a similar manner, how we handle the .csv/.txt files with different name and similar structure for sources(multiple files) and target (single table)
    Is it good to drop the idea of for each loop and create a separate task for each accdb file? to be loaded to same target table( performance wise etc.. any justification would be helpful)
    You must handle the connection string dynamically?
    Can you help me with the logic for handling connection string dynamically
    aak

Maybe you are looking for

  • Firefox immediately reports problem on start and cannot be opened in safe mode.

    Anti-virus and anti-malware are run and no problems reported. Firefox reports error: firefox.exe has encountered an error and needs to be close. Firefox will still run for a little while but eventually crashes. Same problem in safe mode. The weird th

  • Code to include Structure infoset query

    Dear Experts, I am a functional person in Plant Maintenance. I am working on an infoset/query and having to use some fileds from structure RIWO00. System warns for a code in case of use of Structure in the Extras-->Additional structure option. Kindly

  • MBAM 2.5 SCOM Management Pack

    With the newest release of MBAM 2.5 is there a SCOM management pack? Or will the original version 1 that has been released work with this?

  • Multiple failure in CC

    Hello, since I've installed CreaticeCloud Apps my Mac OS X 9.1 awfully slows down, certain apps crash, licenses seem to be a trial-version... What's going on there? Are you in deep trouble? How to come back to a convenient work experience. Some times

  • Siebel Gateway Name Server Configuration Wizard returns "Execution failed"

    Hi, I am installing Siebel 8.1.1.1 on Linux platform and now having problem while trying to configure Siebel Gateway Name Server. Steps done: 1) DB instance prepared 2) Created Siebel installation image 3) Installed Siebel server and configured Gatew