i have flat file as source with part_no as varchar(8) and hash file(as lookup) with part_no as varchar(8).but some of the part_no's are 6 digits and 7 digits.out of these valuse some has leading spaces.
and also some of part_no's with 8 digits has leading zeros. are these values causing the lookup fails??
also how to trim those 6,7 digit values which has leading spaces.
thanks in advance...
Scott R
hash file lookup fails
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 3593
- Joined: Thu Jan 23, 2003 5:25 pm
- Location: Australia, Melbourne
- Contact:
I would put this code into a routine so you can use the Test button to test different scenarios and so you can add and refine the code over time without having to change or recompile the jobs that use it.
The simplest routine code would be:
Ans = FMT(Trim(Arg1), "Z")
The trim statement will remove leading or trailing spaces, the FMT statement is the all singing all dancing format command for BASIC, the "Z" format option is a numeric formatting option that removes leading zeros.
Some code you might like to add is a check to see if the field is NULL, or if it is all zeros (the FMT will change it to an empty field), or if it has non numerics in it, etc.
See the server job developers guide for a full description of the format codes and string handling commands.
In your transformer when you join the input field to the lookup key field just add the routine to the Key Expression field. This will ensure the formatted value is used for a lookup instead of the raw input value.
The simplest routine code would be:
Ans = FMT(Trim(Arg1), "Z")
The trim statement will remove leading or trailing spaces, the FMT statement is the all singing all dancing format command for BASIC, the "Z" format option is a numeric formatting option that removes leading zeros.
Some code you might like to add is a check to see if the field is NULL, or if it is all zeros (the FMT will change it to an empty field), or if it has non numerics in it, etc.
See the server job developers guide for a full description of the format codes and string handling commands.
In your transformer when you join the input field to the lookup key field just add the routine to the Key Expression field. This will ensure the formatted value is used for a lookup instead of the raw input value.
Certus Solutions
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
Blog: Tooling Around in the InfoSphere
Twitter: @vmcburney
LinkedIn:Vincent McBurney LinkedIn
-
- Participant
- Posts: 7
- Joined: Wed Jan 05, 2005 11:05 pm