Subscribe to keep this site alive! Under new management but as always, still 100% FREE. Anyone with the IBM i is a friend of ours.
The Challenge: When to use Element Set or NOT?
The Analysis: The best way to decide which one to use is to demonstrate two situations and discuss how it will be implemented for each.
Scenario #1: Posting of incoming SDQ to a file with 10 sets of fields for the Store Number and Quantity.
This scenario is easiest solved when the Element Set is UNDONE: The elements are explicitly numbered to its relative position in the segment. the first set is would be, SDQ 3.0 and SDQ 4.0; second would be SDQ 5.0 and SDQ 6.0 and so on:
But when the ELEMENT SET is Created; it will involve a little programming and some imagination (because the mapping is implied):
1)Make sure that the Element Set is Created.
2)Define Occurrence Condition on the loop starter SDQ 3.0.
3)Map the SDQ 4.0 to the UFD Field relative to the SDQ34 Occurrence Number.
Scenario #2 requires to locate the quantity of store number 0343 to be posted to a field in the header file.
The second scenario can easily be solve with two mapping instructions with the Created SDQ ELEMENT SET : a)Define Condition against the SDQ 3.0 for a value 0343, b)And map SDQ 4.0 to the Header field when this condition is met. It is implied that an iteration through the ten occurrences is done.
On the other hand, if the SDQ Element Set is UNDONE. Condition for Identification Code has to be set individually and explicit mapping from the corresponding quantity - having 10 more times mapping instruction to do the same thing.
The Verdict: It depends on situation and need.
Do you have a new CHALLENGE? Let us know HERE.