UPS_adrVld()
This subprocedure calls the UPS Address Validation API for city/state/zip address validation. It reads in request data from UPSAVRQ and writes response data to UPSAVRS.
Subprocedure Prototype
|
Returns *OFF if an error occurs during processing, *ON otherwise. |
|
The ID of the record in UPSAVRQ that will be used to build the request, and under which the response data will be saved in UPSAVRS. |
|
The data structure in which error information will be returned. |
Example Code
*------------------------------------------------------------------------
* @Author: Kato Integrations
* @Description:
* This is a test program to illustrate how to call the UPS_adrVld()
* subprocedure to perform a non-street-level address validation.
*
* To achieve this, generate a unique ID with UPS_getUID(), and
* then populate and write a record to UPSAVRQ. Then, call
* UPS_adrVld() passing in your unique ID as well as the other
* parameters shown.
*
* UPS_adrVld() will return *On if no error was encountered, or *Off
* if an error occurred. If an error occurred, you should look at
* the fields in ErrorDS to retrieve information about the error.
*
* Otherwise, you can perform a CHAIN against the UPSAVRS physical
* file, and retrieve the result fields.
*------------------------------------------------------------------------
H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('UPSBND') OPTION(*NODEBUGIO)
FUPSAVRQ UF A E K DISK Qualified
FUPSAVRS IF A E K DISK Qualified
/COPY QRPGLECPY,UPS
// This is included for demo output purposes.
D WriteToJobLog PR 10I 0 Extproc('Qp0zLprintf')
D pString * Value Options(*String)
D NewLine C x'15'
D AVRQ DS Likerec(UPSAVRQ.RUPSAVRQ:*Output)
D AVRS DS Likerec(UPSAVRS.RUPSAVRS:*Input)
D ErrorDS DS LikeDS(UPS_ErrorDS_t) Inz(*LikeDS)
D UniqueID S Like(UPS_UniqueID_t)
/FREE
reset ErrorDS;
// Retrieve Unique ID used to identify this request
UniqueID = UPS_getUID();
clear AVRQ;
AVRQ.UID = UniqueID;
// Populate this field with application name set up using WRKUPSAUTH
AVRQ.UserID = 'KATO_TEST';
AVRQ.State = 'MN';
AVRQ.PostCD = '56001';
write UPSAVRQ.RUPSAVRQ AVRQ;
// If UPS_adrVld() returns *Off, an error occurred and UPS_ErrorDS
// should be reviewed to determine the cause.
if not UPS_adrVld( UniqueID : ErrorDS );
WriteToJobLog( 'API Error: ' + NewLine );
WriteToJobLog( 'Error Code: ' + %Trim(ErrorDS.Code) + NewLine );
WriteToJobLog( 'Error Severity: ' +
%Char(ErrorDS.Severity) + NewLine );
WriteToJobLog( 'Error Source: ' + %Trim(ErrorDS.Pgm) + NewLine );
WriteToJobLog( 'Error Text: ' + %Trim(ErrorDS.Text) + NewLine );
exsr cleanup;
return;
else;
setll UniqueID UPSAVRS.RUPSAVRS;
if not %Found(UPSAVRS);
WriteToJobLog( 'ERROR: No results found in UPSAVRS' + NewLine );
exsr cleanup;
return;
endif;
// Read the results from UPSAVRS. There are typically multiple
// records. A selection of the available fields is output by
// this example program but more are availble - review the file
// to see what else is available.
reade UniqueID UPSAVRS.RUPSAVRS AVRS;
dow not %Eof(UPSAVRS);
WriteToJobLog( 'Result Record: ' + NewLine );
WriteToJobLog( 'PID: ' + %Char(AVRS.PID) + NewLine );
WriteToJobLog( 'UID: ' + %Char(AVRS.UID) + NewLine );
WriteToJobLog( 'RANK: ' + %Char(AVRS.RANK) + NewLine );
WriteToJobLog( 'QUALITY: ' + %Char(AVRS.QUALITY) + NewLine );
WriteToJobLog( 'CITY: ' + %Trim(AVRS.CITY) + NewLine );
WriteToJobLog( 'STATE: ' + %Trim(AVRS.STATE) + NewLine );
WriteToJobLog( 'POSTCDL: ' + %Trim(AVRS.POSTCDL) + NewLine );
WriteToJobLog( 'POSTCDH: ' + %Trim(AVRS.POSTCDH) + NewLine );
WriteToJobLog( '==========' + NewLine );
reade UniqueID UPSAVRS.RUPSAVRS AVRS;
enddo;
endif;
exsr cleanup;
return;
begsr cleanup;
// Always call UPS_cleanup() any time your program will terminate
UPS_cleanup();
*INLR = *ON;
endsr;
/END-FREE
Data Structures
|
|
|
Error code raised by subprocedure |
|
Severity of error - will be either UPS_SEVERE or UPS_INFO |
|
Name of subprocedure that raised the error |
|
Error message text |
Input Table Files
|
Record AV Request Record |
|
Key Record Unique ID |
|
UPS User ID |
|
City |
|
State |
|
Postal Code |
Output Table Files
|
Record Address Validation Response Record |
|
Key Parent Unique ID |
|
Key Child Unique ID |
|
Result Rank |
|
Result Quality |
|
City |
|
State |
|
Postal Code Low |
|
Postal Code High |