Answer doesn't solve the actual problem
Johannes, March 19, 2019 - 7:42 am UTC
Hi,
I apologize for opening this up quite a while after it was created, but I'm currently facing the same problem and the answer doesn't solve the actual problem.
The problem in the question is, that there is a null indicator field 'V4_NULL', which is not to be reflected in the target table, which is why it needs to be specified as FILLER.
However, this field still is the null indicator for 'POS_COST_PRC_FUND', which is why it is checked in the NULLIF-clause of that field.
Expected behaviour would now be that 'POS_COST_PRC_FUND' is always null whenever 'V4_NULL' is a '?'.
Unfortunately, what actually happens is, that the nullif is ignored and the sql (nvl(...)) is executed instead.
The desired behaviour would be that the sql gets ignored when nullif condition is specified.
In your solution you don't use a FILLER field, that's why it works. Unfortunately as soon as the null indicator is a FILLER field it can't be referenced anymore within an sql clause.
I can't find a solution for this as well and would be happy if someone could check this again. Or, if the original author of the question found a way to solve it, that would also be well appreciated!
Thanks a lot,
Johannes
Found the real answer
Johannes, March 19, 2019 - 7:52 am UTC
To everyone still looking for the solution,
my previous review was too quick, I now found the actual solution by myself.
In order to solve the original problem, the FILLER field should be specified with BOUNDFILLER instead and then it can be referenced in data field 'POS_COST_PRC_FUND' as the original answer suggested. So the code should be as follows to work as intended:
POS_COST_PRC_FUND POSITION(173:202) DECIMAL EXTERNAL "case when :V4_NULL = '?' then null else NVL(TO_NUMBER(LTRIM(:POS_COST_PRC_FUND,'0')),0) end",
V4_NULL BOUNDFILLER POSITION(203:203) CHAR,
Since I haven't found this anywhere else and it took me quite some time to figure it out, maybe this will be of help to someone else looking for this.
Thanks,
Johannes
March 19, 2019 - 8:09 am UTC
Thanks for passing that info back.