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: I have a situation with a trading partner where I need to sum the SAC 5.0 Amount values and place that value into a UFD field. Below is an example:
An 850 has the following:
SAC*A*H000****3*.71*****02
SAC*A*C300****3*1.25*****02
SAC*A*I170****3*4.5*****02
I need to sum the 3 amounts, .71 + 1.25 + 4.5 and place the result 6.46 into a field in the UFD.
The Solution 1: There are three steps needed to do this:
1) Create a numeric work field, SACTOTAL with enough digits to contain the possible accumulated total of the SAC segments.
2) While reading the SAC segment, add this mapping instruction source: SACTOTAL Add SAC 5.0 to target: SACTOTAL.
3) While reading the SAC segment, Map SACTOTAL to your UFD field. (make sure that #2 is before #3)
The Solution 2: If there is a possibility of the SAC 1.0 to be "C"-charge mixed with "A"-allowance, you need to condition this because this is a numeric sign:
i) Define condition on SAC 1.0: =A =C.
ii) Select conditions for mapping: when SAC 1.0=A.
iii) While reading the SAC segment, add this mapping instruction source: SACTOTAL Subtract SAC 5.0 to target: SACTOTAL plus Map SACTOTAL to your UFD field.
iv) Select conditions for mapping: when SAC 1.0=C.
v) While reading the SAC segment, add this mapping instruction source: SACTOTAL Add SAC 5.0 to target: SACTOTAL plus Map SACTOTAL to your UFD field.
Thinking of a new CHALLENGE? Let us know HERE.