cancel
Showing results for 
Search instead for 
Did you mean: 

Need help to create an UDF to group PO numbers based upon Group Code then match each of the PO number of that Group with ElementNumber and take the output whose sequence number is minimun.

0 Kudos

Hi Experts,

Since the source and target structure is huge and have many nested loops I would try to make it simple with a sketch below and an example as well.


----PO.......................1-n
-----Header..................1-1
-----OrderLinkage............1-1
--------ChainSegment.........0-n
-----------SeqNo.............0-1
-----------ElementNo.........0-1
-----------DocType...........0-1
-----Item....................0-n
-------Groupcode.............0-1
-------PONo..................0-1


Suppose 4 POs are coming with n number of Items in it, I have to group all the "PONo" that belong to a particular "GroupCode".

Then I have to match each of the PO numbers of one particular Group with "ElementNo" of each "ChainSegment" and extract that particular "ElementNo" whose "SeqNo" is minimum.

The "ElementNo" under "ChainSegment"  also contains similar values as that of "PONo".

Example:

"GroupCode" G1 has 3 POs 10001, 10002, 10003
"GroupCode" G2 has 2 POs 20001, 20001, 20003

Now Chain Segment look like below for one PO

<ChainSegment/>
<SeqNo>00000001<SeqNo/>
<ElementNo>10003<ElementNo/>
<DocType>ABC<DocType/>
<ChainSegment/>
<SeqNo>00000002<SeqNo/>
<ElementNo>10005<ElementNo/>
<DocType>EFG<DocType/>
<ChainSegment/>
<SeqNo>00000003<SeqNo/>
<ElementNo>10001<ElementNo/>
<DocType>HIJ<DocType/>


Out of three POs of G1, 10001 and 10003 matches with the "ElementNo" of the chain segment. But the "SeqNo" of 10001 is 00000003 where as "SeqNo" of 10003 is 00000001. So we will consider 10003 as our output as the corresponding "SeqNo" of that "ElementNo" is minimum.


I tried doing it with a test data having 4 POs and these are the three queues that I have right now.

1st one is list of all POs based upon group.
2nd one has all the ElementNo for each ChainSegmqnt(5 chain segment in each of the 4 PO)
3rd one has all the SeqNo for each ElementNo

Please help me out

Thanks,

Accepted Solutions (0)

Answers (1)

Answers (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

You can try this mapping:

Here is the UDF

PONo context -> PO

ElementNo context -> OrderLinkage

Hope this helps,

Mark

0 Kudos

Thanks Mark for your reply.

But this is not what I need actually.

The grouping part is already done. Now I have the list of PO's that come under each of the group as given in the first screenshot.

I have to compare these PO's(from each group) with ElementNo, and get that particular ElementNo which is having the least SeqNo.

For example....

 

I have group G1 in which PO numbers present are 10001,10002,10003,10004, 10005, 10006,

once I compare these PO numbers with the ElementNo, lets suppose I have a match found for 10004 and 10006. Now I have to check which of these PO's (10004, 10006) have a least SeqNo. This might happen that the Seq No for 10004 is 5 and the SeqNo for 10006 is 3, so we will consider that PO with number as 10006 as that is having lower SeqNo than that of 10004.

I want to fetch the matching PO based upon the least SeqNo using UDF itself.

Please let me know if I am not clear enough.

Thanks,
Subhrapratim

Muniyappan
Active Contributor
0 Kudos

Hi,

please share input and output xml. it will be easy to get some idea.

Regards,

Muniyappan.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Not sure what you meant by correct order, the element number already has the correct order because it is in the same hierarchy as sequence number.

If that is not the case, please send your target message and a sample output.

Regards,

Mark