SW022

Validate Address

Last Revised: 04/15/09

This program is used to validate and correct an address.  SW022 is typically specified as a Standard View Validation routine with File Maintenance applications, although it could be called by another Standard View Validation routine.  SW022 calls CDS358 to perform the validation, and will display any fields changed by CDS358.  Note that CDS358 requires the Dynamo Address Correction option to be enabled.  If the Dynamo Address Correction option is enabled, then I for Information Menu Option will include DAC in the list of Licensed Options in the Application Software Information section.

SW022 submits the address for verification when either a) the name or address fields have changed, or b) there is a field named ADDRCORDATE within the record, and this date is more than 90 days ago, or ADDRCORDATE is zero.

SW022 will display any corrected address fields in yellow, or in white if the primary text color is yellow.  Other optional fields such as the county code are also displayed if included in the View.

SW022 will use upper case for the address if there is a NAME field that is mostly upper case, otherwise proper (mixed) case will be used.

If an address cannot be validated or corrected, then the operator will have the option to revise the address manually, or to accept the address even though it may not be valid.

CALL "SW022", ERR=XXXX, Y$, REC$, RECA$, D1$, D2$, S039$

SW022
Argument In/Out Usage
XXXX   Branch to line XXXX if the address was invalid, and the operator selected the option to manually correct the address.
Y$ In Standard Session Control Variable
REC$ In/Out The templated data structure containing the address fields.  Any fields changed will be replaced by their corrected values.  Optional fields will also be assigned if present in the record.  They will also be displayed if included in the View.
Field NameRequiredSizeDescription
NAMENounlimitedCompany or Individual Name field sometimes used during address validation.
ADDRESSNo*unlimitedSingle line address field
ADDR1 and ADDR2No*unlimitedTwo line address field.  ADDR2 will be used for address validation if non-blank, otherwise ADDR1 will be used.
* Either the ADDRESS field or ADDR1 & ADDR2 fields are required.
CITYYes28City
STATEYes2US State Code or Canadian province code.
ZIPYes10US Zip Code (XXXXX-XXXX) or Canadian Postal Code (ANA-NAN)
COUNTRYNo2Country Code
CRRTNo4Carrier Route Code
DPBCNo3Delivery Point Bar Code
COUNTYCODENo5County Code that can be useful in determining the Sale Tax rate.
COUNTYNAMENo26County Name
ADDRCORDATENoN(7) or U(3)Set to the current julian date and typically stored in the record to know when the last address change was done.  Can also be used to bypass address validation when it was done recently.
ADDRCORCODENo1Set to the address correction code passed back from the address validation routine CDS358.  It indicates the reason that the address was invalid.
RECA$ In This variable is passed by CDS550 and contains the data structure before any operator entries were made.  SW022 does not use RECA$.
D1$ In This variable is passed by CDS550 and contains information about the View.  The only field needed by SW022 is D1.FLDS which is the number of fields in the view.
D2$ In This variable is passed by CDS550 and contains information about each field in the view.  Each field is a S039$ template referenced as D2.FLD$[I].  See SW022 code for example.  SW022 uses this information to know where on the display to display the corrected address.
S039$ In This variable is passed by CDS550 and is used only for its template, and not for its contents.  See SW022 code.

SW022 will validate one address in REC$.  The address to be validated will be based on the first data element in the view that ends with "CITY".  In most cases, the fields in REC$ are named CITY, STATE, ZIP, ADDRESS, etc.  However, SW022 can also validate addresses with a prefix before the field names.  For example, a check address could contain fields named CHKCITY, CHKSTATE, CHKZIP, CHKADDRESS, etc., and a Ship To address could contain fields named SHIP2CITY, SHIP2STATE, SHIP2ZIP, SHIP2ADDR1, SHIP2ADDR2, etc.

If multiple addresses are contained in the same record, then maintain each address in a separate view, so that each address can be validated by the view validation routine that is called by the View Manager when exiting the view.