UPS_PkupCancel()

This subprocedure calls the UPS Pickup Cancel API. It reads in request data from UPSPXRQ and writes response data to RPSPXRS.

Subprocedure Prototype

D UPS_pkupCancel  PR              N

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

D  pUniqueID                    15P 0

The ID of the record in UPSPXRQ that will be used to build the request, and under which the response data will be saved in UPSPXRS.

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_pkupCancel() * subprocedure to cancel a pickup request. * * To achieve this, generate a unique ID with UPS_getUID(), and * then populate and write a record to UPSPXRQ. Then, call * UPS_pkupCancel(), passing in your unique ID as well as * the other parameters shown. * * UPS_pkupCancel() 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 UPSPXRS physical * file, and retrieve the result fields. *------------------------------------------------------------------------ H DFTACTGRP(*NO) ACTGRP(*CALLER) BNDDIR('UPSBND') OPTION(*NODEBUGIO) FUPSPXRQ UF A E K DISK Qualified FUPSPXRS 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 PXRQ DS Likerec(UPSPXRQ.RUPSPXRQ:*Output) D PXRS DS Likerec(UPSPXRS.RUPSPXRS:*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 PXRQ; PXRQ.UID = UniqueID; // Populate this field with UPS user ID that is present in UPSACCT PXRQ.UserID = 'ataylorkt'; // Populate this field with your USP account number that is present // in UPSACCT PXRQ.AcctNbr = '0704W7'; // This specifies that we are cancelling by Pickup Request Number (PRN) PXRQ.CnlBy = '02'; // This must be a valid Pickup Request Number PXRQ.PRN = 'a1234567890'; write UPSPXRQ.RUPSPXRQ PXRQ; // If UPS_pkupCancel() returns *Off, an error occurred and UPS_ErrorDS // should be reviewed to determine the cause. if not UPS_pkupCancel( 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 UPSPXRS.RUPSPXRS; if not %Found(UPSPXRS); WriteToJobLog( 'ERROR: No results found in UPSPXRS' + NewLine ); exsr cleanup; return; endif; // Read the results from UPSPXRS. A selection of the available fields // is output by the example program, but more are available - review // the file to see what else is available. reade UniqueID UPSPXRS.RUPSPXRS PXRS; dow not %Eof(UPSPXRS); WriteToJobLog( 'Result Record:' + NewLine ); WriteToJobLog( 'UID: ' + %Char(PXRS.UID) + NewLine ); WriteToJobLog( 'PKTYPE: ' + PXRS.PKTYPE + NewLine ); reade UniqueID UPSPXRS.RUPSPXRS PXRS; 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 RUPSPXRQ

Record

Pickup Cancel Request Record

A            UID           15P 0

Key

Record Unique ID

A            USERID        30A

UPS User ID

A            ACCTNBR       10A

UPS Account Number

A            PRN           11A

Pickup Request Number

A            CNLBY          2A

Cancel By

Valid Values:

  • 01
  • 02

Output Table Files

A          R RUPSPXRS

Record

Pickup Cancel Response Record

A            UID           15P 0

Key

Record Unique ID

A            PKTYPE         2A

Pickup Type

A            GWNCD          3A

GWN Code

A            GWNDSC       150A

GWN Description