Simulating record association
(multiply and post at the end)
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.
(multiply and post at the end)
The Challenge: We are faced with a challenge where we have to assemble a field to be posted in several records H03. This part is the easiest. All you need to do is record-associate H03 to the N1 loop. The challenge is how to populate the EXTINTTPID field which come from different occurrences of the N1 Segment.
The Solution: The first part of solving this:
1) is removing the record association of the N1 loop to H03.
2) Add the user file (same as H03) to the UFD as many times as the expected occurrences of the N1 Loop. In this case study, we are expecting 3 (ST, SF & VN). We also named the record IDs to match the N1 1.0 qualifier.
3) We explicitly map to the record IDs. Since, the first 3 characters is coming from the N1 occurrence when N1 1.0=ST; the mapping of all 3 EXTINTTPIDs will during this occurrence. The mapping of the next 4 characters of the EXTINTTPIDs is done when N1 1.0 = VN. Because these 3 record IDs is related to the document, the values of the fields are being updated. In contrast with when it is record associated to a loop where the update is NOT possible as soon as the loop goes to the next occurrence.
Retrofitting the old code - (with record association) : It is possible to retrofit this solution with the existing code. The only thing needed is to find a condition before the N1 loop that would condition the mapping the the H03 set of mappings vs the H03ST/SF/VN set of mappings. Or else, there will be 6 records added for every document and/or will have "duplicate key" inserts during the move. This will be confusing to maintain. Hence, we recommend to make it a separate translation format at least.
Do you have a new CHALLENGE? Let us know HERE.