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

#
     D UPS_pkupRating  PR              N

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

     D  pUniqueID                    15P 0

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.

     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_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

#

     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 RUPSPRRQ

Record

Pickup Rating Request

A            UID           15P 0

Key

Record Unique ID

A            USERID        30A

UPS User ID

A            ACCTNBR       10A

UPS Account Number

A            PADDR1        35A

Pickup Address Line 1

A            PADDR2        35A

Pickup Address Line 2

A            PADDR3        35A

Pickup Address Line 3

A            PCITY         40A

Pickup City

A            PSTATE         5A

Pickup State or Province

A            PPOSTCD       16A

Pickup Postal Code

A            PCNTRY         2A

Pickup Country Code

A            PRESDNT        1A

Pickup Residental Address Indicator

A            ALTADDR        1A

Alternate Address Indicator

A            DTOPT          2A

Service Date Option

A            CLSTIM          T

Close Time

A            RDYTIM          T

Ready Time

A            PKUPDT          L

Pickup Date

Output Table Files

#

A          R RUPSPRRS

Record

Pickup Rating Response Data

A            UID           15P 0

Key

Record Unique ID

A            RTTYPE         2A

Rate Type

A            CURCD          3A

Currency Code

A            TOTTAX        10P 2

Total Tax

A            TOTCHRG       10P 2

Total Charges

A          R RUPSPRRSCG

Record

Pickup Rating Response Data - Charge Information

A            PID           15P 0

Key

Parent Unique ID

A            UID           15P 0

Key

Child Unique ID

A            CHRGCD         1A

Charge Type Code

A            CHRGDSC       30A

Charge Description

A            CHRGAMT       10P 2

Charge Amount

A            TAXAMT        10P 2

Tax Amount