# UPS_pkupStatus() This subprocedure calls the UPS Pickup Pending Status API. It reads request data from UPSPSRQ, and writes response data to UPSPSRS. ## Subprocedure Prototype | Field | Description | |---|---| | ` D UPS_pkupStatus PR N` | Returns *OFF if an error occurs during processing, *ON otherwise. | | ` D pUniqueID 15P 0` | The ID of the record in UPSPSRQ that will be used to build the request, and under which the response data will be saved in UPSPSRS. | | ` D pErrorDS LikeDS(UPS_Error)` | The data structure in which error information will be returned. | ## Example Code ### T_PS - Pickup Status Query ```rpgle *------------------------------------------------------------------------ * @Author: Kato Integrations * @Description: * This is a test program to illustrate how to call the UPS_pkupStatus() * subprocedure to query the status of a pickup request. * * To achieve this, generate a unique ID with UPS_getUID(), and * then populate and write a record to UPSPSRQ. Then, call * UPS_pkupStatus(), passing in your unique ID as well as * the other parameters shown. * * UPS_pkupStatus() 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 UPSPSRS physical * file, and retrieve the result fields. *------------------------------------------------------------------------ H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('UPSBND') OPTION(*NODEBUGIO) FUPSPSRQ UF A E K DISK Qualified FUPSPSRS 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 PSRQ DS LikeRec(UPSPSRQ.RUPSPSRQ:*Output) D PSRS DS LikeRec(UPSPSRS.RUPSPSRS:*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 PSRQ; PSRQ.UID = UniqueID; // Populate this field with application name set up using WRKUPSAUTH PSRQ.UserID = 'KATO_TEST'; // Populate this field with a UPS account number configured in // file UPSCFGACCT PSRQ.AcctNbr = '523FE3'; write UPSPSRQ.RUPSPSRQ PSRQ; // If UPS_pkupStatus() returns *Off, an error occurred and UPS_ErrorDS // should be reviewed to determine the cause. if not UPS_pkupStatus( 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 UPSPSRS.RUPSPSRS; if not %Found(UPSPSRS); WriteToJobLog( 'ERROR: No results found in UPSPSRS' + NewLine ); exsr cleanup; return; endif; // Read the results from UPSPSRS. 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 UPSPSRS.RUPSPSRS PSRS; dow not %Eof(UPSPSRS); WriteToJobLog( 'Result Record:' + NewLine ); WriteToJobLog( 'PID: ' + %Char(PSRS.PID) + NewLine ); WriteToJobLog( 'UID: ' + %Char(PSRS.UID) + NewLine ); WriteToJobLog( 'PKTYPE: ' + PSRS.PKTYPE + NewLine ); WriteToJobLog( 'SVCDT: ' + %Char(PSRS.SVCDT) + NewLine ); WriteToJobLog( 'PRN: ' + PSRS.PRN + NewLine ); WriteToJobLog( 'STSMSG: ' + PSRS.STSMSG + NewLine ); reade UniqueID UPSPSRS.RUPSPSRS PSRS; 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 ### UPS_Error | Field | Description | |---|---| | ` 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 ### UPSPSRQ.pf | Field | Description | |---|---| | `A R RUPSPSRQ` | **Record** Pickup Status Request | | `A UID 15P 0` | **Key** Record Unique ID | | `A USERID 30A` | UPS User ID | | `A ACCTNBR 10A` | UPS Account Number | ## Output Table Files ### UPSPSRS.pf | Field | Description | |---|---| | `A R RUPSPSRS` | **Record** Pickup Status Response | | `A PID 15P 0` | **Key** Parent Unique ID | | `A UID 15P 0` | **Key** Child Unique ID | | `A PKTYPE 2A` | Pickup Type | | `A SVCDT L` | Service Date | | `A PRN 11A` | Pickup Request Number | | `A GWNSTS 2A` | GWN Status Code | | `A STSCD 3A` | On-Call Status Code | | `A STSMSG 500A` | Pickup Status Message | | `A BILLCD 2A` | Billing Code | | `A CNNAME 35A` | Contact Name | | `A REFNBR 35A` | Pickup Reference Number |