# UPS_printZPL() This subprocedure accepts a ZPL filename and sends it to be printed on a Zebra printer. ## Subprocedure Prototype | Field | Description | |---|---| | ` D UPS_printZPL PR 15P 0` | | | ` D pFileName 256A Value` | ZPL filename for the file to be printed on a Zebra printer device. | | ` D pErrorDS LikeDS(UPS_Error)` | The data structure in which error information will be returned. | | ` D pFileControl N Value Options(*Nopass)` | | ## Example Code ### T_ZPL - Print to a ZPL Printer ```rpgle *------------------------------------------------------------------------ * @Author: Kato Integrations * @Description: * This is a test program to illustrate how to call the * UPS_printZPL() subprocedure to print a ZPL label returned from UPS. * * To achieve this, pass a filepath that was returned in a UPSSARSPK * record as part of a UPS_shipAccept() call. This filepath is in field * LBLIMG. UPS_printZPL() does not have request or response data tables. * * UPS_printZPL() will return the UniqueID of the record it printed if * it was successful, or 0 if an error occurred. If an error occurred, * you should look at the fields in ErrorDS to retrieve information about * the error. *------------------------------------------------------------------------ H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('UPSBND') OPTION(*NODEBUGIO) /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 ErrorDS DS LikeDS(UPS_ErrorDS_t) Inz(*LikeDS) D LabelPath S 256A /FREE reset ErrorDS; // Replace this with a FilePath found in field UPSSARSPK.LBLIMG. The // filepath was built by UPS_shipAccept() using the OUTPUTDIR value // in UPSCFGOPT. For example: LabelPath = '/ktprod/upsti/output/label1Z0704W70392392713.zpl'; // If UPS_printZPL() returns 0, an error occurred and // UPS_ErrorDS should be reviewed to determine the cause. // UPS_printZPL() has an optional 3rd parameter that can be used to // control the underlying printer file and improve performance. It // accepts a value of UPS_PRINT_OPEN or UPS_PRINT_CLS. If you pass // UPS_PRINT_OPEN, the underlying printer file is left open until // you either subsequently call UPS_printZPL() with UPS_PRINT_CLS, // or until you call UPS_cleanup(). This feature is generally used // in large batch processing where many ZPL labels are being printed. if UPS_printZPL( LabelPath : ErrorDS ) = 0; 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; 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 |