Axaptapedia is now maintained by AgileCadence For more information please click here.

Zip codes

From Axaptapedia
Jump to: navigation, search

Sometimes zip codes are used in main tables, but the corresponding zip code does not exist. This could happen after a data conversion!

The following job creates the missing zip codes.

<xpp> static void ZipCodeCreate(Args _args) {

   CustTable CustTable;
   VendTable VendTable;
   Counter zipCreate(AddressMap record)
   {
       AddressZipCode z;
       AddressZipCode ze;
       Counter c;
       while select record
           where record.ZipCode && record.CountryRegionId
           notexists join ze
           where ze.CountryRegionId == record.CountryRegionId &&
                 ze.County          == record.County &&
                 ze.State           == record.State  &&
                 ze.ZipCode         == record.ZipCode
       {
           z.clear();
           z.CountryRegionId = record.CountryRegionId;
           z.County          = record.County;
           z.State           = record.State;
           z.ZipCode         = record.ZipCode;
           z.City            = record.City;
           z.insert();
           c++;
       }
       info(strFmt("%1 created from %2", c, tableId2pName(record.TableId)));
       return c;
   }
   ;
   zipCreate(CustTable);
   zipCreate(VendTable);

} </xpp>