Hi PI buddies and gurus.
I have a problem regarding a sorting requirement. Upon trying out all the basic functions in PI, I can confirm that it cannot be done without using a UDF. Honestly, I'm not that proficient in JAVA. I would like to ask for your help guys. Kindly see source and IDEAL output below:
case (parent node)
caseid 1111 (field)
deliveryid (subnode)
deliverynumber 1 (field)
deliveryid
deliverynumber 2
case
caseid 2222
deliveryid
deliverynumber 1
deliveryid
deliverynumber 1
case
caseid 3333
deliveryid
deliverynumber 1
case
caseid 4444
deliveryid
deliverynumber 1
deliveryid
deliverynumber 2
So the requirement is to separate the deliverynumbers into multiple idocs. in the sample above, we will only have 2 idocs because of deliverynumbers 1 and 2. the next requirement is to group the deliverynumbers according to their case. the problem with the standard functions sort and sortbykey is that they don't take into account the splitting of the deliverynumbers into two idocs. Kindly see below output for better understanding of the issue.
output (ideal):
idoc
header
case
caseid 1111
delivery
deliverynumber 1
case
caseid 2222
delivery
deliverynumber 1
delivery
deliverynumber 1
case
caseid 3333
delivery
deliverynumber 1
case
caseid 4444
delivery
deliverynumber 1
idoc
header
case
caseid 1111
delivery
deliverynumber 2
case
caseid 4444
delivery
deliverynumber 2
If we use the normal sorting functions of PI, and use case as reference for the case segment in the output, we will only have 4 contexts (1111 2222 3333 4444). And if we use the deliverynumber as reference for the case segment in the output, we will have 7 instances. As you may have noticed in the ideal output, there are only 6 instances of the case segment. Also, the case segments were separated according to the deliverynumber value.
Is this at all possible using UDF? I'm having a hard time generating the necessary codes. Please help.