Hi Team,
Can you help with the below issue related to PI mapping logic.
Requirement: Source file structure
Target IDoc
in the current design: Target Idoc node is duplicated for a flag field and additional Idocs are generated.
Eg:
I have 3 employee ID's 2247,2799,5832
2247 has 3 records -> 3 Idocs are generated and It has a field flag as Y for two records, so additional 2 idocs are generated
2799 - 1 record -> 1 Idoc is generated with flag as N
5832 - 2 records -> 2 Idocs are generated It has a field flag as Y for one record, so additional 1 idoc is generated
So in total 3 + 2 + 1 + 2 + 1 = 9 Idocs are generated.
In the target Structure, there is a field Record_Seq which has the values as
These Idocs are generated by the 1st Occurance of Idoc node
2247_01
2247_02
2247_03
2799_01
5832_01
5832_02
As I mention earlier, Idoc node is duplicated where Additional Idocs are generated based on Flag Y, sequence is as below
2247_01
2247_01
5832_01
5832_01
Expected Sequence in the Above Idocs is
2247_04
2247_05
5832_03
5832_04
Basically, I want to continue Idoc sequence in the 2nd Idoc node occurence, please advise how to achieve it
Request clarification before answering.
Hi
you can follow these steps:
1. Use a Counter Variable:
Introduce a global counter variable to track the sequence numbers for your IDocs. Initialize this counter before processing the source records.
2. Increment the Counter:
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.
3. Check Flag and Generate IDocs:
When processing each record:
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.
If the flag is 'N', just create one IDoc with the current counter value.
4. Update the Sequence Logic:
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.
5. Example Implementation:
If you are using an XSLT mapping or a Java mapping, ensure the logic checks the flag and increments the counter accordingly:
pseudo
if (flag == 'Y') {
generateIDoc(currentEmployeeID, counter++);
generateIDoc(currentEmployeeID, counter++);
} else {
generateIDoc(currentEmployeeID, counter++);
}
This will ensure your IDoc sequences are continuous and do not reset or duplicate unnecessarily, yielding the expected output:
2247_04
2247_05
5832_03
5832_04
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.