UPS_pkupCreate()
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
|
Returns *OFF if an error occurs during processing, *ON otherwise. |
|
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. |
|
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_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(*NEW) 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 application name set up using WRKUPSAUTH
PCRQ.UserID = 'KATO_TEST';
// Populate this field with a UPS account number configured in
// file UPSCFGACCT
PCRQ.AcctNbr = '523FE3';
PCRQ.RTPKUP = 'N';
PCRQ.CLSTIM = %Time() + %Hours(6);
PCRQ.RDYTIM = %Time() + %Hours(2);
PCRQ.PKUPDT = %Date() + %Days(1);
PCRQ.PCONAME = 'Kato Integrations';
PCRQ.PCNNAME = 'Bob Smith';
PCRQ.PADDR1 = '4706 Chiquita Blvd S';
PCRQ.PROOM = 'PMB 411';
PCRQ.PCITY = 'Cape Coral';
PCRQ.PSTATE = 'FL';
PCRQ.PPOSTCD = '33914';
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
|
|
|
Error code raised by subprocedure |
|
Severity of error - will be either UPS_SEVERE or UPS_INFO |
|
Name of subprocedure that raised the error |
|
Error message text |
Input Table Files
|
Record Pickup Creation Request Record |
|
Key Record Unique ID |
|
UPS User ID |
|
UPS Account Number |
|
Rate Pickup Request Valid Values:
|
|
Close Time |
|
Ready Time |
|
Pickup Date |
|
Pickup Company Name |
|
Pickup Contact Name |
|
Pickup Address Line 1 |
|
Pickup Address Line 2 |
|
Pickup Address Line 3 |
|
Pickup Room Number |
|
Pickup Floor |
|
Pickup City |
|
Pickup State |
|
Pickup Urbanization |
|
Pickup Postal Code |
|
Pickup Country |
|
Residential Address Valid Values:
|
|
Pickup Point |
|
Pickup Phone Number |
|
Pickup Phone Extention |
|
Alternate Address Indicator |
|
Return Tracking Numbers |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Total Weight |
|
Weight Code |
|
Large Package Indicator Valid Values:
|
|
Payment Method |
|
Special Instructions |
|
Customer-Assigned Reference Number |
|
Customer Emails |
|
|
|
|
|
|
|
|
|
Undeliverable Email |
|
UPS Service Code |
|
Quantity of Packages |
|
Destination Country |
|
Container Code |
|
Record Pickup Creation Request Tracking Numbers |
|
Key Parent Unique ID |
|
Key Child Unique ID |
|
Return Tracking Number |
Output Table Files
|
Record Pickup Creation Request Response Data |
|
Key Record Unique ID |
|
Pickup Request Number |
|
Rate Code |
|
Rate Code Description |
|
Rate Type |
|
Currency Code |
|
Total Tax |
|
Total Charges |
|
Record Pickup Creation Resonse Charge Data |
|
Key Parent Unique ID |
|
Key Child Unique ID |
|
Charge Type Code |
|
Charge Description |
|
Charge Amount |
|
Charge Tax Amount |