UPS_timeInTransit()
This subprocedure calls the UPS Time in Transit API. It reads request data from UPSTTRQ and writes response data to UPSTTRS.
Subprocedure Prototype
|
Returns *OFF if an error occurs during processing, *ON otherwise. |
|
The ID of the record in UPSTTRQ that will be used to build the request, and under which the response data will be saved in UPSTTRS. |
|
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_timeInTransit() subprocedure to determine shipping time for a
* given shipping option.
*
* To achieve this, generate a unique ID with UPS_getUID(), and
* then populate and write a record to UPSTTRQ. Then, call
* UPS_timeInTransit() passing in your unique ID as well as the other
* parameters shown.
*
* UPS_timeInTransit() 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 UPSTTRS physical
* file, and retrieve the result fields.
*------------------------------------------------------------------------
H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('UPSBND') OPTION(*NODEBUGIO)
FUPSTTRQ UF A E K DISK Qualified
FUPSTTRS 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 TTRQ DS Likerec(UPSTTRQ.RUPSTTRQ:*Output)
D TTRS DS Likerec(UPSTTRS.RUPSTTRS:*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 TTRQ;
TTRQ.UID = UniqueID;
// Populate this field with application name set up using WRKUPSAUTH
TTRQ.UserID = 'KATO_TEST';
TTRQ.StCity = 'Washington';
TTRQ.StState = 'DC';
TTRQ.StPostCd = '20500';
TTRQ.StCntry = 'US';
TTRQ.SfCity = 'Cape Coral';
TTRQ.SfState = 'FL';
TTRQ.SfPostCd = '33914';
TTRQ.SfCntry = 'US';
TTRQ.WgtCd = 'LBS';
TTRQ.Wgt = 3.5;
TTRQ.TotPkgs = 1;
TTRQ.PkUpDt = %Date();
TTRQ.CurCd = 'USD';
TTRQ.Value = 75.00;
write UPSTTRQ.RUPSTTRQ TTRQ;
// If UPS_timeInTransit() returns *Off, an error occurred and
// UPS_ErrorDS should be reviewed to determine the cause.
if not UPS_timeInTransit( 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 UPSTTRS.RUPSTTRS;
if not %Found(UPSTTRS);
WriteToJobLog( 'ERROR: No results found in UPSTTRS' + NewLine );
exsr cleanup;
return;
endif;
// Read the results from UPSTTRS. 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 UPSTTRS.RUPSTTRS TTRS;
dow not %Eof(UPSTTRS);
WriteToJobLog( 'Result Record: ' + NewLine );
WriteToJobLog( 'PID: ' + %Char(TTRS.PID) + NewLine );
WriteToJobLog( 'UID: ' + %Char(TTRS.UID) + NewLine );
WriteToJobLog( 'SVCCD: ' + %Trim(TTRS.SVCCD) + NewLine );
WriteToJobLog( 'SVCDSC: ' + %Trim(TTRS.SVCDSC) + NewLine );
WriteToJobLog( 'GRNTEED: ' + %Trim(TTRS.GRNTEED) + NewLine );
WriteToJobLog( 'DOCONLY: ' + %Trim(TTRS.DOCONLY) + NewLine );
WriteToJobLog( 'AUTDTYCD: ' + %Trim(TTRS.AUTDTYCD) + NewLine );
WriteToJobLog( 'WEEKDAY: ' + %Trim(TTRS.WEEKDAY) + NewLine );
WriteToJobLog( 'ARRIVTIM: ' + %Char(TTRS.ARRIVTIM) + NewLine );
WriteToJobLog( 'ARRIVDT: ' + %Char(TTRS.ARRIVDT) + NewLine );
WriteToJobLog( 'PKUPTIM: ' + %Char(TTRS.PKUPTIM) + NewLine );
WriteToJobLog( 'PKUPDT: ' + %Char(TTRS.PKUPDT) + NewLine );
WriteToJobLog( 'TRANSBUS: ' + %Char(TTRS.TRANSBUS) + NewLine );
WriteToJobLog( 'TRANSTOT: ' + %Char(TTRS.TRANSTOT) + NewLine );
WriteToJobLog( 'CUTOFF: ' + %Char(TTRS.CUTOFF) + NewLine );
WriteToJobLog( 'RESTDAYS: ' + %Char(TTRS.RESTDAYS) + NewLine );
WriteToJobLog( 'HOLIDAYS: ' + %Char(TTRS.HOLIDAYS) + NewLine );
WriteToJobLog( 'CUSTOMS: ' + %Char(TTRS.CUSTOMS) + NewLine );
WriteToJobLog( '==========' + NewLine );
reade UniqueID UPSTTRS.RUPSTTRS TTRS;
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 Time in Transit Request Record |
|
Key Record Unique ID |
|
UPS User ID |
|
Ship To Town |
|
Ship To City |
|
Ship To State |
|
Ship To Postal Code/Zip |
|
Ship To Country |
|
Ship To Residential Indicator Valid Values:
|
|
Ship From Town |
|
Ship From City |
|
Ship From State |
|
Ship From Postal Code/Zip |
|
Ship From Country |
|
Weight Code |
|
Weight |
|
Total Number of Packages |
|
Pickup Date |
|
Currency Code |
|
Value |
|
Documents Only Indicator Valid Values:
|
|
Max Results |
Output Table Files
|
Record Time in Transit Response Record |
|
Key Parent Unique ID |
|
Key Child Unique ID |
|
UPS Service Code |
|
UPS Service Description |
|
Guaranteed Indicator |
|
Documents Only Indicator |
|
Auto Duty Code |
|
Arrival Day of the Week |
|
Arrival Time |
|
Arrival Date |
|
Pickup Time |
|
Pickup Date |
|
Business Transit Days |
|
Total Transit Days |
|
Customer Center Call Time |
|
Non-Movement Days |
|
Holidays |
|
Days Delayed By Customs |