Merge Use Examples
Two sets of data can be merged together as long as they have a common child node value.
Here we have a process that is retrieving an order in the OrderHistory query.
Then, in OrderTotal, it is finding the sum of all the lines for a given order and it is doing that for all the orders returned from OrderHistory. Here are the results that come back from OrderTotal:
The merge is responsible for merging the WorkData/OrderTotal/ShippedTotal back to the corresponding order in OrderHistory.
This is the end result from the logs of OrderHistory. It now has the nodes from both OrderHistory and OrderTotal.
Merging an Unequal Number of Nodes
Merge can be used to merge an unequal number of nodes. This means that if our initial query has 10 results, we can merge Node2 to Node1 even if Node2 does not also have 10 results.
In this example we have an OrderHistory query that is returning 3 results
Next, the ShippingAddresses query is finding the name (F0101.ABALPH) of each of the ShipTos (F4201.SHSHAN). You’ll notice, only one result returned from the ShippingAddresses, while 3 results returned from the OrderHistory query. This is because if we look into the logs on these orders, we can see that they are all from the same shipping address.
The ShippingAddresses query runs and finds the one result in F0101 matching ABAN8=’4242’
And it returns the name we want.
The merge service will merge that one result to all three orders to they are all given a ShipToName:
Merging with the Same Key for a Cleaner Output
You could clean up your final result after the merge by merging with the same key. In the example above the OrderHistory node has successfully been given a ShipToName based on the ShipTo value. However, there is a left over “ABAN8” which is a duplicate value of “ShipTo”.
We could alter our ShippingAddresses Query to alias ABAN8 as ShipTo so that both Node1 and Node2 have the “ShipTo” child.
Then, if we alter our Merge service to merge on that key
Our end result will have only one “ShipTo”.
Merging with Override On
Override could be used to override a property that has old or unwanted data. In this example we have a query, GetOrderDetails, which returns the WarehouseDescription by adding strings together from the F0116 (Address by Date) table.
The end result is “[City], [State]”. Here is that piece from the select clause of GetOrderDetails (|| is the concat operator in Iseries).
However, due to incomplete data in JDE, this sometimes returns results that look incomplete.
In order to correct this and be able to display it on the webpage with complete data, we could do an override with a merge.
In this particular example we created a new process called WarehouseDescriptionOverrides, which would accept the input of WarehouseDescription and then check against all the known descriptions which would display incorrectly. When the WarehouseDescription was needed to be shown on a page, it would always pass through the new process first. It would utilize the following logic:
This way, there would be only one list of overrides to maintain since everywhere a WarehouseDescription was shown, it came from the output of this process.
After the process call, the Merge service would override the old value of “London,“ with the new correct value of “London, UK” from the process output.
Merging with Compute Nodes
Accepted values are “FromVal” and “ToVal”.
The Compute Nodes feature is used to do math between a child node in "Node1" and "Node2".
In this example we have Node1 and Node 2 each with an availability count of the same ItemNumber, but from different BranchPlants.
If you wanted to sum the availability of these two BranchPlants in a Merge service, we would set up our Merge like so:
This works because both nodes have the Availability child node.
The end result is an Availability of 7, the sum of the two availabilities. Also, notice that because we did not set Override=’True’, both BranchPlants are present after the Merge.
Using this same example, we can also show other math operators which can be used in the Compute Nodes. Now the merge has been changed to multiply the two values instead of add.
Similarly, we could also subtract.
We could also divide. The operator for division is ‘/’.
Additional Math Examples