UPS_ratingReq()
This subprocedure calls the UPS Rating API. It reads request data from UPSRTRQ, and package data from UPSRTRQPK. It writes response data to UPSRTRS, and package data to UPSRTRSPK.
Subprocedure Prototype
|
Returns *OFF if an error occurs during processing, *ON otherwise. |
|
The ID of the records in UPSRTRQ and UPSRTRQPK that will be used to build the request, and under which the response data will be saved in UPSRTRS and UPSRTRSPK. |
|
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_ratingReq() subprocedure to determine shipping rates.
*
* To achieve this, generate a unique ID with UPS_getUID(), and
* then populate and write a record to UPSRTRQ, and one or more child
* records to UPSRTRQPK. Then, call UPS_ratingReq() passing in
* your unique ID as well as the other parameters shown.
*
* UPS_ratingReq() 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 UPSRTRS physical
* file, and retrieve the result fields, as well as child records
* for each package from UPSRTRSPK.
*------------------------------------------------------------------------
H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('UPSBND') OPTION(*NODEBUGIO)
FUPSRTRQ UF A E K DISK Qualified
FUPSRTRQPK UF A E K DISK Qualified
FUPSRTRS IF A E K DISK Qualified
FUPSRTRSPK 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 RTRQ DS Likerec(UPSRTRQ.RUPSRTRQ:*Output)
D RTRQPK DS Likerec(UPSRTRQPK.RUPSRTRQPK:*Output)
D RTRS DS Likerec(UPSRTRS.RUPSRTRS:*Input)
D RTRSPK DS Likerec(UPSRTRSPK.RUPSRTRSPK:*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 RTRQ;
RTRQ.UID = UniqueID;
// Populate this field with application name set up using WRKUPSAUTH
RTRQ.UserID = 'KATO_TEST';
// Populate this field with a UPS account number configured in
// file UPSCFGACCT
RTRQ.AcctNbr = '523FE3';
RTRQ.ReqOpt = 'Rate'; // Rate and validate this shipment
// Validate the shipment and return rates for all UPS products from the
// ShipFrom to the ShipTo
// RTRQ.ReqOpt = 'Shop';
RTRQ.PKUPCD = '06';
RTRQ.CSTCLSCD = '03';
RTRQ.StAddr1 = '1600 Pennsylvania Avenue NW';
RTRQ.StCity = 'Washington';
RTRQ.StState = 'DC';
RTRQ.StPostCd = '20500';
RTRQ.StCntry = 'US';
RTRQ.SfAddr1 = '4706 Chiquita Blvd S';
//RTRQ.SfAddr2 = 'STE 310';
RTRQ.SfCity = 'Cape Coral';
RTRQ.SfState = 'FL';
RTRQ.SfPostCd = '33914';
RTRQ.SfCntry = 'US';
RTRQ.SvcCd = '03';
// Other fields are available but not used in this example code
write UPSRTRQ.RUPSRTRQ RTRQ;
// Write individual package child record to UPSRTRQPK
clear RTRQPK;
RTRQPK.PID = UniqueID;
RTRQPK.UID = 1;
RTRQPK.PkgCd = '02';
RTRQPK.DimCd = 'IN';
RTRQPK.Length = 6.5;
RTRQPK.Width = 10;
RTRQPK.Height = 4;
RTRQPK.WgtCd = 'LBS';
RTRQPK.PkgWgt = 5;
write UPSRTRQPK.RUPSRTRQPK RTRQPK;
// If UPS_ratingReq() returns *Off, an error occurred and
// UPS_ErrorDS should be reviewed to determine the cause.
if not UPS_ratingReq( 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 UPSRTRS.RUPSRTRS;
if not %Found(UPSRTRS);
WriteToJobLog( 'ERROR: No results found in UPSRTRS' + NewLine );
exsr cleanup;
return;
endif;
// Read the results from UPSRTRS. 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 UPSRTRS.RUPSRTRS RTRS;
dow not %Eof(UPSRTRS);
WriteToJobLog( 'Result Record: ' + NewLine );
WriteToJobLog( 'PID: ' + %Char(RTRS.PID) + NewLine );
WriteToJobLog( 'UID: ' + %Char(RTRS.UID) + NewLine );
WriteToJobLog( 'SVCCD: ' + %Trim(RTRS.SVCCD) + NewLine );
WriteToJobLog( 'SVCDSC: ' + %Trim(RTRS.SVCDSC) + NewLine );
WriteToJobLog( 'WGTCD: ' + %Trim(RTRS.WGTCD) + NewLine );
WriteToJobLog( 'TOTWGT: ' + %Char(RTRS.TOTWGT) + NewLine );
WriteToJobLog( 'TRSCURCD: ' + %Trim(RTRS.TRSCURCD) + NewLine );
WriteToJobLog( 'TRSCHRG: ' + %Char(RTRS.TRSCHRG) + NewLine );
WriteToJobLog( 'SVCCURCD: ' + %Trim(RTRS.SVCCURCD) + NewLine );
WriteToJobLog( 'SVCCHRG: ' + %Char(RTRS.SVCCHRG) + NewLine );
WriteToJobLog( 'TOTCURCD: ' + %Trim(RTRS.TOTCURCD) + NewLine );
WriteToJobLog( 'TOTCHRG: ' + %Char(RTRS.TOTCHRG) + NewLine );
WriteToJobLog( 'GTDDAYS: ' + %Trim(RTRS.GTDDAYS) + NewLine );
WriteToJobLog( 'GTDTIM: ' + %Char(RTRS.GTDTIM) + NewLine );
WriteToJobLog( 'NEGCURCD: ' + %Trim(RTRS.NEGCURCD) + NewLine );
WriteToJobLog( 'NEGCHRG: ' + %Char(RTRS.NEGCHRG) + NewLine );
// Package level charges can be read from UPSRTRSPK if needed
reade UniqueID UPSRTRS.RUPSRTRS RTRS;
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 Rating Request |
|
Key Record Unique ID |
|
UPS User ID |
|
UPS Account Number |
|
Request Option Valid Values:
|
|
Pickup Type Code |
|
Customer Classification |
|
Ship To Company Name |
|
Ship To Address Line 1 |
|
Ship To Address Line 2 |
|
Ship To Address Line 3 |
|
Ship To City |
|
Ship To Provice/State |
|
Ship To Postal Code/Zip |
|
Ship To Country |
|
Ship To Residential Indicator Valid Values:
|
|
Ship From Company Name |
|
Ship From Address Line 1 |
|
Ship From Address Line 2 |
|
Ship From Address Line 3 |
|
Ship From City |
|
Ship From State |
|
Ship From Zip/Postal Code |
|
Ship From Country |
|
UPS Service Code |
|
Documents Only Indicator Valid Values:
|
|
Request Saturday Pickup Indicator Valid Values:
|
|
Request Saturday Delivery Indicator Valid Values:
|
|
Pickup Day Code |
|
Method to Schedule Pickup |
|
Carbon Neutral Indicator Valid Values:
|
|
Delivery Confirmation Type Code |
|
Negotiated Rate Indicator Valid Values:
|
|
Invoice Currency Code |
|
Invoice Value |
|
Record Rating Request Package Information |
|
Key Parent Unique ID |
|
Key Child Unique ID |
|
Package Type Code |
|
Package Dimensions Code |
|
Package Length |
|
Package Width |
|
Package Height |
|
Package Weight Code |
|
Package Weight |
|
Large Package Indicator Valid Values:
|
|
Insured Value Currency Code |
|
Insured Value |
|
COD Funds Code |
|
COD Currency Code |
|
COD Value |
|
Delivery Confirmation Type Code |
|
Verbal Confirmation Name |
|
Verbal Confirmation Phone Number |
|
Additional Handling Req |
Output Table Files
|
Record Rating Request Response Record |
|
Key Parent Unique ID |
|
Key Child Unique ID |
|
UPS Service Code |
|
UPS Service Description |
|
Shipment Weight Code |
|
Shipment Weight |
|
Transportation Currency Code |
|
Transportation Charge |
|
Service Currency Code |
|
Service Charge |
|
Total Currency Code |
|
Total Charge |
|
Guaranteed Days to Delivery |
|
Guaranteed Delivery Time |
|
Negotiated Currency Code |
|
Negotiated Total Charges |
|
Record Rating Request Response Package Information |
|
Key Parent Unique ID |
|
Key Child Unique ID |
|
Transportation Currency Code |
|
Transportation Charge |
|
Service Currency Code |
|
Service Charge |
|
Package Currency Code |
|
Package Charge |
|
Package Weight Code |
|
Package Weight |
|
Package Billing Weight |