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: We need to update the inbound 856 map to combine the quantity when the same item and line number is reported on the same pallet.
In the below example you can see that line number 3000 is reported twice on the pallet. Once for a quantity of 56 and a second time for a quantity of 1. What we need to do is combine those two quantities into a quantity of 57 and then map it to the target. We only want to do this for the same LIN01 line number on the same MAN02 SSCC.
23 MAN*GM*100716110000063989~
24 HL*8*7*I~
25 LIN*3000*VN*50155*JP*Z001~
26 SN1*3000*56*CA**2*EA~
27 HL*9*7*I~
28 LIN*3000*VN*50155*JP*Z001~
29 SN1*3000*1*CA**2*EA~
The Solution: Basically, we need to make sure that there is at least one record for each HL-P loop. We can easily do this by record-association. But for the difference-break and because it is variable we could not "ride it on" this record association but we need to record it on the same file. 1) By re-adding the same Item File as a new record format - it is "faking" that it is another file you are record-associating with another loop. Since we want to add a record @ SN1, but SN1 only occurs once, we need to override the occurrence of the segment to be at least two, only the can we could do record association with the record format SN1_ITEM.
2) Record-associate the original item file record format as the secondary of the Pack Level.
3) Create work fields to contain the elements of previously read segments plus a set for the "previous key" (B4 series). 4) You would need a condition for the first pass. so that it will "not break" when previous line number is zero. And a condition to indicate when a break/difference has occurred. The timing-order of the conditions is vital, hence we should make sure that these conditions are in one Condition Set.
5) The mapping will be as follows:
Initialize the B4LINE
Set work fields as you go through LIN and SN1.
Initialize for first pass.
Sum up qty and map the values for first and/or last.
If there is a break, map previous values and summation to the "new-fake" Item File. And save an record the current record to the "real" Item File.
Thinking of a new CHALLENGE? Let us know HERE.