<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: SAP PI Mapping help: Duplicate Idoc - continue Sequence in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/sap-pi-mapping-help-duplicate-idoc-continue-sequence/qaa-p/13870465#M4884425</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can follow these steps:&lt;/P&gt;&lt;P&gt;1. Use a Counter Variable:&lt;BR /&gt;Introduce a global counter variable to track the sequence numbers for your IDocs. Initialize this counter before processing the source records.&lt;/P&gt;&lt;P&gt;2. Increment the Counter:&lt;BR /&gt;For each occurrence of the IDoc node, increment the counter. This will ensure that every IDoc generated (including duplicates based on the flag) receives a unique sequence number.&lt;/P&gt;&lt;P&gt;3. Check Flag and Generate IDocs:&lt;BR /&gt;When processing each record:&lt;BR /&gt;If the flag is 'Y', create an additional IDoc and use the current value of the counter for both the original and the additional IDoc.&lt;BR /&gt;If the flag is 'N', just create one IDoc with the current counter value.&lt;/P&gt;&lt;P&gt;4. Update the Sequence Logic:&lt;BR /&gt;Instead of resetting or duplicating the counter for the duplicate IDocs, keep it incrementing for every new IDoc creation. This will continue the sequence seamlessly.&lt;/P&gt;&lt;P&gt;5. Example Implementation:&lt;BR /&gt;If you are using an XSLT mapping or a Java mapping, ensure the logic checks the flag and increments the counter accordingly:&lt;BR /&gt;pseudo&lt;BR /&gt;if (flag == 'Y') {&lt;BR /&gt;generateIDoc(currentEmployeeID, counter++);&lt;BR /&gt;generateIDoc(currentEmployeeID, counter++);&lt;BR /&gt;} else {&lt;BR /&gt;generateIDoc(currentEmployeeID, counter++);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;This will ensure your IDoc sequences are continuous and do not reset or duplicate unnecessarily, yielding the expected output:&lt;/P&gt;&lt;P&gt;2247_04&lt;BR /&gt;2247_05&lt;BR /&gt;5832_03&lt;BR /&gt;5832_04&lt;/P&gt;</description>
    <pubDate>Thu, 19 Sep 2024 06:37:33 GMT</pubDate>
    <dc:creator>umasaral</dc:creator>
    <dc:date>2024-09-19T06:37:33Z</dc:date>
    <item>
      <title>SAP PI Mapping help: Duplicate Idoc - continue Sequence</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-pi-mapping-help-duplicate-idoc-continue-sequence/qaq-p/13869997</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;Can you help with the below issue related to PI mapping logic.&lt;/P&gt;&lt;P&gt;Requirement: Source file structure&lt;BR /&gt;Target IDoc&lt;BR /&gt;in the current design: Target Idoc node is duplicated for a flag field and additional Idocs are generated.&lt;BR /&gt;Eg:&lt;BR /&gt;I have 3 employee ID's 2247,2799,5832&lt;BR /&gt;2247 has 3 records -&amp;gt; 3 Idocs are generated and It has a field flag as Y for two records, so additional 2 idocs are generated&lt;BR /&gt;2799 - 1 record -&amp;gt; 1 Idoc is generated with flag as N&lt;BR /&gt;5832 - 2 records -&amp;gt; 2 Idocs are generated It has a field flag as Y for one record, so additional 1 idoc is generated&lt;/P&gt;&lt;P&gt;So in total 3 + 2 + 1 + 2 + 1 = 9 Idocs are generated.&lt;/P&gt;&lt;P&gt;In the target Structure, there is a field Record_Seq which has the values as&lt;BR /&gt;These Idocs are generated by the 1st Occurance of Idoc node&lt;BR /&gt;2247_01&lt;BR /&gt;2247_02&lt;BR /&gt;2247_03&lt;BR /&gt;2799_01&lt;BR /&gt;5832_01&lt;BR /&gt;5832_02&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;As I mention earlier, Idoc node is duplicated where Additional Idocs are generated based on Flag Y,&amp;nbsp; sequence is as below&lt;BR /&gt;2247_01&lt;BR /&gt;2247_01&lt;BR /&gt;5832_01&lt;BR /&gt;5832_01&lt;/P&gt;&lt;P&gt;Expected Sequence in the Above Idocs is&lt;/P&gt;&lt;P&gt;2247_04&lt;BR /&gt;2247_05&lt;BR /&gt;5832_03&lt;BR /&gt;5832_04&lt;BR /&gt;Basically, I want to continue Idoc sequence in the 2nd Idoc node occurence, please advise how to achieve it&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 17:41:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-pi-mapping-help-duplicate-idoc-continue-sequence/qaq-p/13869997</guid>
      <dc:creator>varun_kasireddy</dc:creator>
      <dc:date>2024-09-18T17:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: SAP PI Mapping help: Duplicate Idoc - continue Sequence</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-pi-mapping-help-duplicate-idoc-continue-sequence/qaa-p/13870445#M4884419</link>
      <description>&lt;P&gt;Hi Varum,&lt;/P&gt;&lt;P&gt;Sometimes it should be better to add a second step in OM with a graphical mapping aka MM to make a counter with a specific routine.&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;P&gt;- MM_1 with its rules to create the expected idoc structure, but with the “flag” field to be referenced with the values 2247,2799,5832 (without counter)&lt;BR /&gt;- MM_2: based on the “flag” field of the previous MM_1, add a counter for the same value as 2247 starting at 1 with step 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 06:27:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-pi-mapping-help-duplicate-idoc-continue-sequence/qaa-p/13870445#M4884419</guid>
      <dc:creator>ONavas</dc:creator>
      <dc:date>2024-09-19T06:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: SAP PI Mapping help: Duplicate Idoc - continue Sequence</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-pi-mapping-help-duplicate-idoc-continue-sequence/qaa-p/13870465#M4884425</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can follow these steps:&lt;/P&gt;&lt;P&gt;1. Use a Counter Variable:&lt;BR /&gt;Introduce a global counter variable to track the sequence numbers for your IDocs. Initialize this counter before processing the source records.&lt;/P&gt;&lt;P&gt;2. Increment the Counter:&lt;BR /&gt;For each occurrence of the IDoc node, increment the counter. This will ensure that every IDoc generated (including duplicates based on the flag) receives a unique sequence number.&lt;/P&gt;&lt;P&gt;3. Check Flag and Generate IDocs:&lt;BR /&gt;When processing each record:&lt;BR /&gt;If the flag is 'Y', create an additional IDoc and use the current value of the counter for both the original and the additional IDoc.&lt;BR /&gt;If the flag is 'N', just create one IDoc with the current counter value.&lt;/P&gt;&lt;P&gt;4. Update the Sequence Logic:&lt;BR /&gt;Instead of resetting or duplicating the counter for the duplicate IDocs, keep it incrementing for every new IDoc creation. This will continue the sequence seamlessly.&lt;/P&gt;&lt;P&gt;5. Example Implementation:&lt;BR /&gt;If you are using an XSLT mapping or a Java mapping, ensure the logic checks the flag and increments the counter accordingly:&lt;BR /&gt;pseudo&lt;BR /&gt;if (flag == 'Y') {&lt;BR /&gt;generateIDoc(currentEmployeeID, counter++);&lt;BR /&gt;generateIDoc(currentEmployeeID, counter++);&lt;BR /&gt;} else {&lt;BR /&gt;generateIDoc(currentEmployeeID, counter++);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;This will ensure your IDoc sequences are continuous and do not reset or duplicate unnecessarily, yielding the expected output:&lt;/P&gt;&lt;P&gt;2247_04&lt;BR /&gt;2247_05&lt;BR /&gt;5832_03&lt;BR /&gt;5832_04&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 06:37:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-pi-mapping-help-duplicate-idoc-continue-sequence/qaa-p/13870465#M4884425</guid>
      <dc:creator>umasaral</dc:creator>
      <dc:date>2024-09-19T06:37:33Z</dc:date>
    </item>
  </channel>
</rss>

