This subprocedure calls the UPS Pickup Creation API. It reads request data from UPSPCRQ, and tracking number data from UPSPCRQTK. It writes response data to UPSPCRS, and charge data to UPSPCRSCG.

Subprocedure Prototype

D UPS_pkupCreate  PR              N

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

D  pUniqueID                    15P 0

The ID of the records in UPSPCRQ and other input tables that will be used to build the request, and under which the response data will be saved in UPSPCRS and UPSPCRSCG.

D  pErrorDS                           LikeDS(UPS_Error)

The data structure in which error information will be returned.

Example Code

*------------------------------------------------------------------------ * @Author: Krengel Technology * @Description: * This is a test program to illustrate how to call the * UPS_pkupCreate() subprocedure to schedule a pickup. * * To achieve this, generate a unique ID with UPS_getUID(), and * then populate and write a record to UPSPCRQ, and one or more child * records to UPSPCRQTK. Then, call UPS_pkupCreate() passing in * your unique ID as well as the other parameters shown. * * UPS_pkupCreate() 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 UPSPCRS physical * file, and retrieve the result fields, as well as child records * for each package from UPSPCRSCG. *------------------------------------------------------------------------ H DFTACTGRP(*NO) ACTGRP(*CALLER) BNDDIR('UPSBND') OPTION(*NODEBUGIO) FUPSPCRQ UF A E K DISK Qualified FUPSPCRQTK UF A E K DISK Qualified FUPSPCRS IF A E K DISK Qualified FUPSPCRSCG 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 PCRQ DS Likerec(UPSPCRQ.RUPSPCRQ:*Output) D PCRQTK DS Likerec(UPSPCRQTK.RUPSPCRQTK:*Output) D PCRS DS Likerec(UPSPCRS.RUPSPCRS:*Input) D PCRSCG DS Likerec(UPSPCRSCG.RUPSPCRSCG:*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 PCRQ; PCRQ.UID = UniqueID; // Populate this field with UPS user ID that is present in UPSACCT PCRQ.UserID = 'ataylorkt'; PCRQ.AcctNbr = '0704W7'; PCRQ.RTPKUP = 'N'; PCRQ.CLSTIM = %Time() + %Hours(6); PCRQ.RDYTIM = %Time() + %Hours(2); PCRQ.PKUPDT = %Date() + %Days(1); PCRQ.PCONAME = 'Krengel Technology'; PCRQ.PCNNAME = 'Bob Smith'; PCRQ.PADDR1 = '124 E. Walnut Street'; PCRQ.PROOM = 'STE 310'; PCRQ.PCITY = 'Mankato'; PCRQ.PSTATE = 'MN'; PCRQ.PPOSTCD = '56001'; PCRQ.PCNTRY = 'US'; PCRQ.PPHONE = '18005736435'; PCRQ.ALTADDR = 'Y'; PCRQ.TOTWGT = 1.0; PCRQ.WGTCD = 'LBS'; PCRQ.LRGPKG = 'N'; PCRQ.PAYMTHD = '01'; PCRQ.SVCCD = '002'; PCRQ.QTY = 1; PCRQ.DCNTRY = 'US'; PCRQ.CNTNRCD = '01'; // Other fields are available but not used in this example code write UPSPCRQ.RUPSPCRQ PCRQ; // Records can be written to UPSPCRQTK to provide tracking numbers for // return packages. A maximum of 30 can be provided. This is optional // and not used in this example. // clear PCRQTK; // PCRQTK.PID = UniqueID; // PCRQTK.UID = 1; // PCRQTK.RTRACK = ''; // write UPSPCRQPK.RUPSPCRQPK PCRQTK; // If UPS_pkupCreate() returns *Off, an error occurred and // UPS_ErrorDS should be reviewed to determine the cause. if not UPS_pkupCreate( 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 UPSPCRS.RUPSPCRS; if not %Found(UPSPCRS); WriteToJobLog( 'ERROR: No results found in UPSPCRS' + NewLine ); exsr cleanup; return; endif; // Read the results from UPSPCRS. 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 UPSPCRS.RUPSPCRS PCRS; dow not %Eof(UPSPCRS); WriteToJobLog( 'Result Record: ' + NewLine ); WriteToJobLog( 'UID: ' + %Char(PCRS.UID) + NewLine ); WriteToJobLog( 'REQNBR: ' + %Trim(PCRS.REQNBR) + NewLine ); WriteToJobLog( 'RTCD: ' + %Trim(PCRS.RTCD) + NewLine ); WriteToJobLog( 'RTDSC: ' + %Trim(PCRS.RTDSC) + NewLine ); WriteToJobLog( 'RTTYPE: ' + %Trim(PCRS.RTTYPE) + NewLine ); WriteToJobLog( 'CURCD: ' + %Trim(PCRS.CURCD) + NewLine ); WriteToJobLog( 'TOTTAX: ' + %Char(PCRS.TOTTAX) + NewLine ); WriteToJobLog( 'TOTCHRG: ' + %Char(PCRS.TOTCHRG) + NewLine ); // Read through UPSSCRSPG for package-level charges. Depending on // your request, there may not be any. chain UniqueID UPSPCRSCG.RUPSPCRSCG PCRSCG; if not %Found(UPSPCRSCG); WriteToJobLog( 'No results found in UPSPCRSCG' + NewLine ); exsr cleanup; return; endif; dow not %Eof(UPSPCRSCG); WriteToJobLog( 'Child Result Record: ' + NewLine ); WriteToJobLog( 'PID: ' + %Char(PCRSCG.PID) + NewLine ); WriteToJobLog( 'UID: ' + %Char(PCRSCG.UID) + NewLine ); WriteToJobLog( 'CHRGCD: ' + %Trim(PCRSCG.CHRGCD) + NewLine ); WriteToJobLog( 'CHRGDSC: ' + %Trim(PCRSCG.CHRGDSC) + NewLine ); WriteToJobLog( 'CHRGAMT: ' + %Char(PCRSCG.CHRGAMT) + NewLine ); WriteToJobLog( '==========' + NewLine ); reade UniqueID UPSPCRSCG.RUPSPCRSCG PCRSCG; enddo; reade UniqueID UPSPCRS.RUPSPCRS PCRS; 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 RUPSPCRQ


Pickup Creation Request Record

A            UID           15P 0


Record Unique ID

A            USERID        30A


A            ACCTNBR       10A

UPS Account Number

A            RTPKUP         1A

Rate Pickup Request

Valid Values:

  • Y

A            CLSTIM          T

Close Time

A            RDYTIM          T

Ready Time

A            PKUPDT          L

Pickup Date

A            PCONAME       35A

Pickup Company Name

A            PCNNAME       35A

Pickup Contact Name

A            PADDR1        35A

Pickup Address Line 1

A            PADDR2        35A

Pickup Address Line 2

A            PADDR3        35A

Pickup Address Line 3

A            PROOM          8A

Pickup Room Number

A            PFLOOR         3A

Pickup Floor

A            PCITY         40A

Pickup City

A            PSTATE         5A

Pickup State

A            PURBAN        50A

Pickup Urbanization

A            PPOSTCD       16A

Pickup Postal Code

A            PCNTRY         2A

Pickup Country

A            PRESDNT        1A

Residential Address

Valid Values:

  • Y

A            PPOINT        11A

Pickup Point

A            PPHONE        15A

Pickup Phone Number

A            PEXT          10A

Pickup Phone Extention

A            ALTADDR        1A

Alternate Address Indicator

A            TRACK1        18A

Return Tracking Numbers

A            TRACK2        18A
A            TRACK3        18A
A            TRACK4        18A
A            TRACK5        18A
A            TRACK6        18A
A            TRACK7        18A
A            TRACK8        18A
A            TRACK9        18A
A            TRACK10       18A
A            TRACK11       18A
A            TRACK12       18A
A            TRACK13       18A
A            TRACK14       18A
A            TRACK15       18A
A            TRACK16       18A
A            TRACK17       18A
A            TRACK18       18A
A            TRACK19       18A
A            TRACK20       18A
A            TRACK21       18A
A            TRACK22       18A
A            TRACK23       18A
A            TRACK24       18A
A            TRACK25       18A
A            TRACK26       18A
A            TRACK27       18A
A            TRACK28       18A
A            TRACK29       18A
A            TRACK30       18A
A            TOTWGT         7P 1

Total Weight

A            WGTCD          3A

Weight Code

A            LRGPKG         1A

Large Package Indicator

Valid Values:

  • T
  • Y

A            PAYMTHD        2A

Payment Method

A            INSTRCT       57A

Special Instructions

A            REFNBR        35A

Customer-Assigned Reference Number

A            CEMAIL1       59A

Customer Emails

A            CEMAIL2       59A
A            CEMAIL3       59A
A            CEMAIL4       59A
A            CEMAIL5       59A
A            UEMAIL        59A

Undeliverable Email

A            SVCCD          3A

UPS Service Code

A            QTY            3P 0

Quantity of Packages

A            DCNTRY         2A

Destination Country

A            CNTNRCD        2A

Container Code



Pickup Creation Request Tracking Numbers

A            PID           15P 0


Parent Unique ID

A            UID           15P 0


Child Unique ID

A            RTRACK        18A

Return Tracking Number

Output Table Files

A          R RUPSPCRS


Pickup Creation Request Response Data

A            UID           15P 0


Record Unique ID

A            REQNBR        11A

Pickup Request Number

A            RTCD           2A

Rate Code

A            RTDSC         35A

Rate Code Description

A            RTTYPE         2A

Rate Type

A            CURCD          3A

Currency Code

A            TOTTAX        10P 2

Total Tax

A            TOTCHRG       10P 2

Total Charges



Pickup Creation Resonse Charge Data

A            PID           15P 0


Parent Unique ID

A            UID           15P 0


Child Unique ID

A            CHRGCD         1A

Charge Type Code

A            CHRGDSC       30A

Charge Description

A            CHRGAMT       10P 2

Charge Amount

A            TAXAMT        10P 2

Charge Tax Amount