[ic] str_length mis-behavior?

Tim Murphy interchange-users@interchange.redhat.com
Sun Feb 3 00:24:00 2002


Hello,

	The last piece of the puzzle... I'm having trouble figuring out how the zip 
length can be modified when doing UPS lookups. It appears that I can't do a 
lookup unless the string length of the zip value is at least 3 characters. 
Quick background: I'm using <zip> with 3 characters from the Canadian Postal 
Code to get domestic shipping costs, <state> with 2 characters to get US 
shipping costs, and <country> with 2 characters to get international costs. 
The domestic shipping works fine (i.e. zip = "A0A", "B1B", etc.). Trying a US 
or International destination always returns: 

"Note: No zone found for geo code <2 letter state or country code here> type 
PIS." 

PIS in the above message is my international surface shipping cost database. 

>From my shipping.asc (only showing the initial entry for each mode):

DOM     CanPar Domestic weight  0       0       e Nothing to ship!            
  { 'ui_ship_type' => "UPSI", 'zone' => "domzone", 'table' => "DOM", 'ups' => 
"1", 'adder' => "2", 'geo' => "zip", 'str_length' => "3" }

The str_length option is unnecessary here, just included to be consistent. 
This works A-OK.

PIS     ParcelPost Intl Surface weight  0       0       e Nothing to ship!    
          { 'ui_ship_type' => "UPSI",  'table' => "PIS", 'zone' => 
"intlzone", 'ups' => "1", 'adder' => "2", 'geo' => "country", 'str_length' => 
"2" }

This is for an international surface shipping mode. This doesn't work.

Now for the interesting bit. Picking a country code to experiment with, I 
changed Australia's "AU" to "AU0" in the relevant zone file, the country 
database, and so on. I then changed str_length to 3 for the PIS mode in 
shipping.asc and reconfig'd the catalog. Success! Works like a charm. 
Changing str_length back to 2 but leaving the country code in the files as 
"AU0" resulted in 

"Note: No zone found for geo code AU (note that the "0" was removed!) type 
PIS." 

So it looks like the str_length option was truncating the country code from 
"AU0" to AU" as you would expect. Then, changing "AU0" back to "AU" in all 
the files resulted in the original error message. 

Interpolate.pm, on line 7598 (for 4.8.3) has:

$zip = substr($zip, 0, ($zref->{str_length} || 3));

I may be missing something but it certainly looks like whatever value gets 
placed in $zip can have its length modified by str_length. I changed the 3 in 
the above to a 2, restarted Interchange and re-tried the lookup with a 2 
character code. Same problem.

So...I guess I could modify the data files so all the countries and states 
have a "0" appended to the codes, but that's pretty messy. I feel like I'm 
missing something obvious. Could it be that the state/country codes are 
purely alphabetic and the lack of any numerals is screwing up the lookup 
routine? I'm just stumped as to why I can't get a 2 character string to work 
for the UPS lookups even with str_length. Is there another ups-related 
routine that must have 3 characters to function? I tried locating something 
besides tag_ups but I didn't see anything that looked like it was involved.

Thanks as always for any help,

Tim