UPS_pkupRating()
This subprocedure calls the UPS Pickup Rate API. It reads in request data from UPSPRRQ, and writes response data to UPSPRRS and charge data to UPSPRRSCG.
Subprocedure Prototype
|
Returns *OFF if an error occurs during processing, *ON otherwise. |
|
The ID of the record in UPSPRRQ that will be used to build the request, and under which the response data will be saved in UPSPRRS and UPSPRRSCG. |
|
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_pkupRating() subprocedure to rate a pickup.
*
* To achieve this, generate a unique ID with UPS_getUID(), and
* then populate and write a record to UPSPRRQ. Then, call
* UPS_pkupRating() passing in your unique ID as well as the other
* parameters shown.
*
* UPS_pkupRating() 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 UPSPRRS physical
* file, and retrieve the result fields, as well as child records
* from UPSPRRSCG to view details about individual charges.
*------------------------------------------------------------------------
H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('UPSBND') OPTION(*NODEBUGIO)
FUPSPRRQ UF A E K DISK Qualified
FUPSPRRS IF A E K DISK Qualified
FUPSPRRSCG 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 PRRQ DS Likerec(UPSPRRQ.RUPSPRRQ:*Output)
D PRRS DS Likerec(UPSPRRS.RUPSPRRS:*Input)
D PRRSCG DS Likerec(UPSPRRSCG.RUPSPRRSCG:*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 PRRQ;
PRRQ.UID = UniqueID;
// Populate this field with application name set up using WRKUPSAUTH
PRRQ.UserID = 'KATO_TEST';
// Populate this field with a UPS account number configured in
// file UPSCFGACCT
PRRQ.AcctNbr = '523FE3';
PRRQ.PADDR1 = '4706 Chiquita Blvd S';
PRRQ.PCITY = 'Cape Coral';
PRRQ.PSTATE = 'FL';
PRRQ.PPOSTCD = '33914';
PRRQ.PCNTRY = 'US';
PRRQ.PRESDNT = 'N';
PRRQ.ALTADDR = 'Y';
PRRQ.DTOPT = '03';
PRRQ.CLSTIM = %Time() + %Hours(6);
PRRQ.RDYTIM = %Time() + %Hours(2);
PRRQ.PKUPDT = %Date() + %Days(1);
write UPSPRRQ.RUPSPRRQ PRRQ;
// If UPS_pkupRating() returns *Off, an error occurred and
// UPS_ErrorDS should be reviewed to determine the cause.
if not UPS_pkupRating( 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 UPSPRRS.RUPSPRRS;
if not %Found(UPSPRRS);
WriteToJobLog( 'ERROR: No results found in UPSPRRS' + NewLine );
exsr cleanup;
return;
endif;
// Read the results from UPSPRRS. 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 UPSPRRS.RUPSPRRS PRRS;
dow not %Eof(UPSPRRS);
WriteToJobLog( 'Result Record: ' + NewLine );
WriteToJobLog( 'UID: ' + %Char(PRRS.UID) + NewLine );
WriteToJobLog( 'RTTYPE: ' + %Trim(PRRS.RTTYPE) + NewLine );
WriteToJobLog( 'CURCD: ' + %Trim(PRRS.CURCD) + NewLine );
WriteToJobLog( 'TOTTAX: ' + %Char(PRRS.TOTTAX) + NewLine );
WriteToJobLog( 'TOTCHRG: ' + %Char(PRRS.TOTCHRG) + NewLine );
// Read through UPSSCRSPG for package-level charges. Depending on
// your request, there may not be any.
chain UniqueID UPSPRRSCG.RUPSPRRSCG PRRSCG;
if not %Found(UPSPRRSCG);
WriteToJobLog( 'ERROR: No results found in UPSPCRSCG' + NewLine );
exsr cleanup;
return;
endif;
dow not %Eof(UPSPRRSCG);
WriteToJobLog( 'Child Result Record: ' + NewLine );
WriteToJobLog( 'PID: ' + %Char(PRRSCG.PID) + NewLine );
WriteToJobLog( 'UID: ' + %Char(PRRSCG.UID) + NewLine );
WriteToJobLog( 'CHRGCD: ' + %Trim(PRRSCG.CHRGCD) + NewLine );
WriteToJobLog( 'CHRGDSC: ' + %Trim(PRRSCG.CHRGDSC) + NewLine );
WriteToJobLog( 'CHRGAMT: ' + %Char(PRRSCG.CHRGAMT) + NewLine );
WriteToJobLog( 'TAXAMT: ' + %Char(PRRSCG.TAXAMT) + NewLine );
WriteToJobLog( '==========' + NewLine );
reade UniqueID UPSPRRSCG.RUPSPRRSCG PRRSCG;
enddo;
reade UniqueID UPSPRRS.RUPSPRRS PRRS;
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 Pickup Rating Request |
|
Key Record Unique ID |
|
UPS User ID |
|
UPS Account Number |
|
Pickup Address Line 1 |
|
Pickup Address Line 2 |
|
Pickup Address Line 3 |
|
Pickup City |
|
Pickup State or Province |
|
Pickup Postal Code |
|
Pickup Country Code |
|
Pickup Residental Address Indicator |
|
Alternate Address Indicator |
|
Service Date Option |
|
Close Time |
|
Ready Time |
|
Pickup Date |
Output Table Files
|
Record Pickup Rating Response Data |
|
Key Record Unique ID |
|
Rate Type |
|
Currency Code |
|
Total Tax |
|
Total Charges |
|
Record Pickup Rating Response Data - Charge Information |
|
Key Parent Unique ID |
|
Key Child Unique ID |
|
Charge Type Code |
|
Charge Description |
|
Charge Amount |
|
Tax Amount |