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

D UPS_timeInTransit...
D                 PR              N

Returns *OFF if an error occurs during processing, *ON otherwise.

D  pUniqueID                    15P 0

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.

D  pErrorDS                           LikeDS(UPS_Error)

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(*CALLER) 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 UPS user ID that is present in UPSACCT TTRQ.UserID = 'ataylorkt'; TTRQ.StCity = 'Mankato'; TTRQ.StState = 'MN'; TTRQ.StPostCd = '56001'; TTRQ.StCntry = 'US'; TTRQ.SfCity = 'Faribault'; TTRQ.SfState = 'MN'; TTRQ.SfPostCd = '55021'; 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

D UPS_Error       DS                  Qualified Inz
 
D  Code                         10A

Error code raised by subprocedure

D  Severity                     10I 0

Severity of error - will be either UPS_SEVERE or UPS_INFO

D  Pgm                          30A   Varying

Name of subprocedure that raised the error

D  Text                      32000A   Varying

Error message text

Input Table Files

A          R RUPSTTRQ

Record

Time in Transit Request Record

A            UID           15P 0

Key

Record Unique ID

A            USERID        30A

UPS User ID

A            STTOWN        30A

Ship To Town

A            STCITY        40A

Ship To City

A            STSTATE        5A

Ship To State

A            STPOSTCD      16A

Ship To Postal Code/Zip

A            STCNTRY        2A

Ship To Country

A            STRESDNT       1A

Ship To Residential Indicator

Valid Values:

  • T
  • Y

A            SFTOWN        30A

Ship From Town

A            SFCITY        40A

Ship From City

A            SFSTATE        5A

Ship From State

A            SFPOSTCD      16A

Ship From Postal Code/Zip

A            SFCNTRY        2A

Ship From Country

A            WGTCD          3A

Weight Code

A            WGT            5P 2

Weight

A            TOTPKGS       10P 0

Total Number of Packages

A            PKUPDT          L

Pickup Date

A            CURCD          3A

Currency Code

A            VALUE         11P 2

Value

A            DOCONLY        1A

Documents Only Indicator

Valid Values:

  • T
  • Y

A            RESULTS        2P 0

Max Results

Output Table Files

A          R RUPSTTRS

Record

Time in Transit Response Record

A            PID           15P 0

Key

Parent Unique ID

A            UID           15P 0

Key

Child Unique ID

A            SVCCD          4A

UPS Service Code

A            SVCDSC        50A

UPS Service Description

A            GRNTEED        1A

Guaranteed Indicator

A            DOCONLY        1A

Documents Only Indicator

A            AUTDTYCD       2A

Auto Duty Code

A            WEEKDAY        3A

Arrival Day of the Week

A            ARRIVTIM        T

Arrival Time

A            ARRIVDT         L

Arrival Date

A            PKUPTIM         T

Pickup Time

A            PKUPDT          L

Pickup Date

A            TRANSBUS       2P 0

Business Transit Days

A            TRANSTOT       2P 0

Total Transit Days

A            CUTOFF          T

Customer Center Call Time

A            RESTDAYS       2P 0

Non-Movement Days

A            HOLIDAYS       2P 0

Holidays

A            CUSTOMS        2P 0

Days Delayed By Customs