Beruflich Dokumente
Kultur Dokumente
Page 1 of 63
SAP
Copyright
Copyright 2010 SAP AG. All rights reserved SAP Library document classification: PUBLIC are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, Clear Enterprise, SAP BusinessObjects Explorer, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries. Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP France in the United States and in other countries. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors. Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 2 of 63
SAP
Icons
Icon Meaning Caution Example Note Recommendation Syntax Tip
History
Version 1.0 Date 11/24/2010 Status (Comments) Initial
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 3 of 63
SAP
Contents 1
1.1 1.2
Introduction .......................................................................................... 5
Business Context ............................................................................................ 5 General Guidelines.......................................................................................... 6
2 3
3.1 3.2 3.3 3.4
Development Environment Setup ....................................................... 7 Fiscal Printer User Exit API ................................................................. 7
Overview ......................................................................................................... 7 IFiscalPrinterService ....................................................................................... 9 IPosPrinterServiceV2 .................................................................................... 13 IPosPrinterService......................................................................................... 14
4
4.1 4.2
5
5.1 5.2
Configuration ...................................................................................... 28
Fiscal Printer User Exit Classname ............................................................... 28 Setting The Classpath ................................................................................... 29
6
6.1 6.2 6.3 6.4 6.5 6.6
7
7.1 7.2 7.3 7.4 7.5 7.6
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 4 of 63
SAP
1 Introduction
This document describes the interface that a Java programmer has to develop to establish communication between the SAP Enterprise POS and a fiscal printer to produce fiscal receipts and comply with the regulations of countries where fiscal audits are performed. The key advantages of using the Fiscal Printer User Exit are: Provides options to develop/implement specific fiscal printer requirements outside the CORE code. Fiscal printer integration can be done by SAP, SAP customer, or SAP partner.
SAP provides two default Fiscal Printer User Exit implementations, which you can modify as necessary to create a customized fiscal printer user exit.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 5 of 63
SAP
You can adapt either of these default implementations to your particular requirements. For general information on implementing user exits for SAP Enterprise POS, see the Technical Product Reference section of the SAP Library documentation under User Exits.
3.
Optionally, use BAdIs to enable printing of barcodes and bitmaps on the fiscal printer. See the Java BAdI Implementation For Fiscal Printer section for more information.
Make adjustments for fiscal printers working in synchronous mode. For more information, see the Requirements For Fiscal Printers In Synchronous Mode section. 5. Modify the POS Client configuration to include the new Fiscal Printer User Exit. For more information, see the Fiscal Printer User Exit Classname section. 6. Modify the POS Client startup file to include the new Fiscal Printer User Exit. For more information, see the Setting The Classpath section. 7. Make changes to the required SAP Enterprise POS Configurator settings. For more information, see the Configurator Settings section. 8. Create documents (using the Document Editor) that use the ~FISCAL() function to print fiscal receipts and reports on the fiscal printer. See the ~FISCAL Function section for more information.
4.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 6 of 63
SAP
com.triversity.transactionware.framework.deviceservices.jpos This package contains the standard implementation of the Fiscal Printer User Exit as well as other classes and interfaces used by the user exit. AbstractFiscalPrinterControl16Monitor FiscalPrinterErrorMessage PosFiscalPrinterPendingRequest StandardFiscalPrinterService
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 7 of 63
SAP
IPosPrinterService
interface
Operations void addErrorListener(IError Listener) void removeErrorListener(IErrorListener) void addStatusUpdateListener(IStatusUpdateListener) void beginRemoval(int) int checkHealth() void cutPaper(int) void endInsertion() void endRemoval() boolean getCapability(int, String) int getJournalWidth() void removeStatusUpdateListener(IStatusUpdateListener) void print(int, String) void printBitmap(int, String, int, int) int getJournalWidthDots() int getReceiptWidth() int getReceiptWidthDots() int getSlipWidth() int getSlipWidthDots() boolean getSlpEmpty() boolean isReceiptEmpty() boolean isReceiptNearEnd() void setFlagWhenIdle(boolean) void setAsyncMode(boolean) void deleteTransactionBitmaps() void printBarCode(int, String, int, int, int, int, int) void beginInsertion(int) void setBitmap(int, int, String, int, int) void printStoredBitmap(int, int)
IPosPrinterServiceV2
JPOS
interface
OutputCompleteListener
IFiscalPrinterService ErrorListener
Operations void initialize(Map<String,Object>) Object getProperty(String) void reset() boolean isDayOpened() boolean isFiscalReceipt() void printPeriodicTotalsReport(String, String) void printPowerLossReport() void printPeriodicTotalsReport(int, int, int) void printXReport() void printZReport()
StatusUpdateListener
DirectIOListener
StandardFiscalPrinterService
JPosFiscalPrinterListener
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 8 of 63
SAP
3.2 IFiscalPrinterService
This interface is the basis for the Fiscal Printer User Exit. IFiscalPrinterService must be implemented for the POS Client to load the fiscal printer implementation. IFiscalPrinterService extends IPosPrinterServiceV2 which in turn extends IPosPrinterService, therefore the methods of both these interfaces must also be implemented even if they do not necessarily relate to the fiscal printer. The POS Client can make calls to the following methods of IFiscalPrinterService: initialize isDayOpened isFiscalReceipt printPeriodicTotalsReport printReport printPowerLossReport printXReport printZReport getProperty reset
3.2.1 Initialize
Method Name
Event class/Event Description
initialize
None Visibility Public
Method to initialize the fiscal printer with data from SAP Enterprise POS. Fiscal printer initialization is dependent on the particular printer model. The fiscal printer is initialized by the data passed by the Map parameter.
Preconditions Result Exceptions Parameter Name The fiscal printer is initialized with data from SAP Enterprise POS. DeviceServiceException Parameter Type Map<String, Object> Description The SAP Enterprise POS parameter used to initialize the internal settings of the fiscal printer. The Map parameter can possibly contain the following data: Key IDslFiscalPrinterConst.INIT_CURRENCY IDslFiscalPrinterConst.INIT_DATE_TIME IDslFiscalPrinterConst.INIT_STORE_FISCAL_ID IDslFiscalPrinterConst.INIT_TAX_INFO IDslFiscalPrinterConst.INIT_TENDER_INFO IDslFiscalPrinterConst.INIT_POS_ID Value The primary currency configured in SAP Enterprise POS The current system time
parameters
The Store ID to which the register, and subsequently the fiscal printer, are connected The accumulated tax group rates The tenders configured in SAP Enterprise POS The client ID and cashier ID, which are contained in an instance of FiscalPrinterTillAccountability
The store information parameters are also possibly contained in the parameters map in order to have access to the header and trailer lines. The key for header lines will have a prefix of IDslFiscalPrinterConst.INIT_HEADER_LINE followed by a number. The trailer lines
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 9 of 63
SAP
isDayOpened
None Visibility Public
Method to determine whether the fiscal day is open on the fiscal printer. A fiscal day is open when at least one transaction has been completed but the Z-report has not been printed.
Preconditions Result Exceptions True if the fiscal day is open on the printer, false otherwise. DeviceServiceException
isFiscalReceipt
None Visibility Public
Preconditions Result Exceptions True if the current receipt is a fiscal receipt, false otherwise.
printPeriodicTotalsReport
None Visibility Public
Method to print the Periodic Totals Report on the fiscal printer. The parameters passed to this method are two dates in String format, which set the time period for the report. (Ref: jPOS printPeriodicTotalsReport)
Preconditions Result Exceptions Parameter Name aStartDate anEndDate Periodic Totals Report is printed. DeviceServiceException Parameter Type String String Description The initial date for the report. The ending date for the report.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 10 of 63
SAP
printReport
None Visibility Public
Preconditions Result Exceptions Parameter Name aReportType Selected fiscal report is printed. DeviceServiceException Parameter Type int Description The type of report to print: Value IDslFiscalPrinterConst.DSL_FPTR_RT_ORDINAL Description Prints report between two record numbers selected from fiscal memory Prints report between two selected dates
IDslFiscalPrinterConst.DSL_FPTR_RT_DATE
aStartNum anEndNum
String String
String indicating the starting transaction record or the initial date. String indicating the final transaction record or the ending date.
printPowerLossReport
None Visibility Public
Preconditions Result Exceptions Parameter Name The power loss report is printed. DeviceServiceException Parameter Type Description
printXReport
None Visibility Public
Preconditions
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 11 of 63
SAP
printZReport
None Visibility Public
Preconditions Result Exceptions Parameter Name The Z report is printed and the fiscal day is closed. DeviceServiceException Parameter Type Description
getProperty
None Visibility Public Method to return the requested property based on the String parameter.
Preconditions Result Exceptions Parameter Name property An object containing the requested property is returned. DeviceServiceException Parameter Type String Description The name of the property to retrieve.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 12 of 63
SAP
3.2.10 Reset
Method Name
Event class/Event Description
reset
None Visibility Public
Method to reset or clear the fiscal printer and other related tasks.
Preconditions Result Exceptions Parameter Name All tasks are cleared. DeviceServiceException Parameter Type Description
3.3 IPosPrinterServiceV2
As IFiscalPrinterService extends IPosPrinterServiceV2, any Fiscal Printer User Exit implementation will must also include the IPosPrinterServiceV2 interface. This interface consists of two methods relating to printing: print isCoverOpen
3.3.1 Print
Method Name
Event class/Event Description
print
None Visibility Public
Method to print one or more paragraphs of formatted text on the selected printer.
Preconditions Result Exceptions Parameter Name aStationId aReceipt aDescriptor DeviceServiceException Parameter Type int List<Paragraph> ReceiptDescriptors Description The ID for the station to which the printer is connected. The receipt information as a list of Paragraphs, where each paragraph is a list of LineBuffers. Paragraph class details are described in the Paragraph Class section. The receipt descriptor which, if applicable, describes the page layout. May be null, so implementing classes must take note of this. ReceiptDescriptors class details are described in the ReceiptDescriptors section.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 13 of 63
SAP
isCoverOpen
None Visibility Public
Method to determine whether the cover of the printer is open or not. (Ref: jPOS isCoverOpen)
Preconditions Result Exceptions Parameter Name True if the printer cover is opened, false otherwise. DeviceServiceException Parameter Type Description
3.4 IPosPrinterService
The interface IPosPrinterServiceV2 extends IPosPrinterService, therefore any implementation of the Fiscal Printer User Exit should implement the methods of IPosPrinterService. Note: Although most methods defined in this interface are not used by the fiscal printer, nevertheless, these methods need to be included in the Fiscal Printer User Exit implementation.
addErrorListener
None Method to add an error listener. Visibility Public
Preconditions Result Exceptions Parameter Name anErrorListener The error listener is passed as a parameter to the list of error listeners. DeviceServiceException Parameter Type IErrorListener Description The error listener to add to the list.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 14 of 63
SAP
addStatusUpdateListener
None Method to add a status update listener. Visibility Public
Preconditions Result Exceptions Parameter Name statusListener The status update listener is passed as a parameter to the list of status update listeners. DeviceServiceException Parameter Type IStatusUpdateListener Description The status update listener to be added to the list.
beginInsertion
None Visibility Public
Method to set the printer into insertion mode. (Ref: jPOS beginInsertion).
Preconditions Result Exceptions Parameter Name aTimeout The printer mode is set to insertion. DeviceServiceException Parameter Type int Description The length of time in milliseconds that the method should be tried before issuing a timeout.
beginRemoval
None Visibility Public
Method to start the form removal process on the printer. (Ref: jPOS beginRemoval)
Preconditions Result Exceptions Parameter Name aTimeout Parameter Type int Description The length of time in milliseconds that the method should be tried before issuing a timeout. The form removal process is started.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 15 of 63
SAP
checkHealth
None Visibility Public
Preconditions Result Exceptions Parameter Name Parameter Type Description If a problem is found, the appropriate error code is returned, otherwise a success code is returned.
cutPaper
None Visibility Public
Method to issue the command to cut the paper in the receipt printer. Not applicable for fiscal printer as cutting of receipts is done implicitly through other commands.
Preconditions Result Exceptions Parameter Name stationId Parameter Type int Description The ID for the station to which the printer is connected.
deleteTransactionBitmaps
None Visibility Public
Method to delete all stored transaction bitmaps. Not applicable for fiscal printer.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 16 of 63
SAP
endInsertion
None Visibility Public
Method to take the printer out of form insertion mode. (Ref: jPOS endInsertion)
Preconditions Result Exceptions Parameter Name The printer exits form insertion mode. DeviceServiceException Parameter Type Description
endRemoval
None Visibility Public
Method to take the printer out of form removal mode. (Ref: jPOS endRemoval)
Preconditions Result Exceptions Parameter Name The printer exits form removal mode. DeviceServiceException Parameter Type Description
getCapability
None Visibility Public
Method to retrieve whether the selected printer has the requested capability.
Preconditions Result Exceptions Parameter Name aStationId aCapabilityId Parameter Type Int String Description The ID for the station to which the printer is connected. The ID of the capability to verify. True if the printer has the requested capability, false otherwise.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 17 of 63
SAP
getJournalWidth
None Visibility Public
Method to retrieve the defined journal width. Not applicable for fiscal printer.
getJournalWidthDots
None Visibility Public
Method to retrieve the defined journal dot width. Not applicable for fiscal printer.
getReceiptWidth
None Visibility Public
Preconditions Result Exceptions Parameter Name The maximum width of a receipt line is returned. DeviceServiceException Parameter Type Description
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 18 of 63
SAP
getReceiptWidthDots
None Visibility Public
Method to return receipt dot width. Not applicable for fiscal printer.
getSlipWidth
None Visibility Public
Method to return the slip receipt width. Not applicable for fiscal printer.
getSlipWidthDots
None Visibility Public
Method to return the slip receipt dot width. Not applicable for fiscal printer.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 19 of 63
SAP
getSlpEmpty
None Visibility Public
Method to return whether the slip printer is out of paper. Not applicable for fiscal printer.
Preconditions Result Exceptions Parameter Name True if the slip printer is empty, false otherwise. DeviceServiceException Parameter Type Description
getReceiptEmpty
None Visibility Public
Preconditions Result Exceptions Parameter Name Parameter Type Description True if the receipt printer is empty, false otherwise.
isReceiptNearEnd
None Visibility Public
Preconditions Result Exceptions Parameter Name Parameter Type Description True if the receipt is nearly out of paper, false otherwise.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 20 of 63
SAP
3.4.20 Print
Method Name
Event class/Event Description
print
None Visibility Public
Method to print one or more lines of formatted text on one or more print stations. Typically, you would not use this method with a fiscal printer; this method is used with standard receipt printers.
Preconditions Result Exceptions Parameter Name aStationId aStringToPrint Parameter Type int String Description Identifies the print station or stations where the text is to be printed. Set this parameter to one of the DSL_PTR_S_xxx found in IDslPosPrinterConst. Sets the lines of text to be printed. If the string contains multiple lines, each line should be terminated with a combination of a carriage return and a line feed character. The specified strings are printed on the selected printer.
printBarCode
None Visibility Public
Method to print the barcode on the receipt as per the specified parameters.
Preconditions Result Exceptions Parameter Name aStationId aData aSymbology aHeight aWidth anAlignment aTextPosition The barcode is printed. DeviceServiceException Parameter Type int String int int int int int Description Identifies the print station or stations (one of IDeviceSet.DEVICE_RECEIPT, DEVICE_SLIP, DEVICE_JOURNAL). The actual barcode data. The index of the entry in the ConfigPOSConstants.symbologies table. Height of barcode. Width of barcode. Alignment of the barcode. Text position of the barcode.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 21 of 63
SAP
printBitmap
None Visibility Public
Preconditions Result Exceptions Parameter Name aStationId aFileName aWidth anAlignment The bitmap is printed. DeviceServiceException Parameter Type int String int int Description Identifies the print station or stations DEVICE_SLIP, DEVICE_JOURNAL) Filename of the bitmap to be printed. The width of the bitmap. Alignment of the bitmap. (one of IDeviceSet.DEVICE_RECEIPT,
printStoredBitmap
None Visibility Public
Preconditions Result Exceptions Parameter Name aStationId aStoredBitmap DeviceServiceException Parameter Type int int Description Identifies the print station or stations DEVICE_SLIP, DEVICE_JOURNAL) Index of the stored bitmap. (one of IDeviceSet.DEVICE_RECEIPT,
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 22 of 63
SAP
removeErrorListener
None Method to remove an error listener. Visibility Public
Preconditions Result Exceptions Parameter Name anErrorListener Parameter Type IErrorListener Description The error listener to remove from the list. The specified error listener is removed from the list of Error Listeners.
removeStatusUpdateListener
None Method to remove a status update listener. Visibility Public
Preconditions Result Exceptions Parameter Name aStatusListener Parameter Type IStatusUpdateListener Description The status update listener to remove from the list. The specified status update listener is removed from the list of Status Update Listeners.
setAsyncMode
None Visibility Public
Preconditions Result Exceptions Parameter Name aFlag The printer is set to the selected mode of operation. DeviceServiceException Parameter Type boolean Description Set flag to true to operate the printer in asynchronous mode, or false to operate in synchronous mode.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 23 of 63
SAP
setBitmap
None Visibility Public
Preconditions Result Exceptions Parameter Name aBitmapNumber aStationId aFileName aWidth anAlignment DeviceServiceException Parameter Type int int String int int Description The index of the stored bitmap. The ID for the station to which the printer is connected. Filename of the bitmap. Width of the bitmap. Alignment of the bitmap.
setFlagWhenIdle
None Visibility Public
Method to set flag when idle; relevant for slip printing. Not applicable for fiscal printer.
Preconditions Result Exceptions Parameter Name flag DeviceServiceException Parameter Type boolean Description True or false.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 24 of 63
SAP
Description Specifies whether the fiscal printer connected to the particular POS Client can communicate in asynchronous mode. Specifies the user exit service class that will be used by SAP Enterprise POS to communicate to the fiscal printer.
FiscalPrinterUserExit
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
SAP
StandardSyncFiscalPrinterService In SAP Enterprise POS, the printer mode setting (synchronous or asynchronous) found in PrintManager is not modifiable through a user exit. Therefore, prior to sending the print call to the implementation of IFiscalPrinterService, the PrintManager must determine the printers mode of operation by checking the configuration in device.properties. The FiscalPrinter1.asyncMode and the FiscalPrinterUserExit settings are used by SAP Enterprise POS to determine the user exit implementation class as follows:
true
Yes
No
Class Exists?
No
In summary, to implement a Fiscal Printer User Exit for fiscal printers that only operate in synchronous mode: 1. Use the standard default implementation, StandardSyncFiscalPrinterService, as a reference to create a custom implementation. 2. Make the necessary changes in the device.properties file to activate the custom implementation.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 26 of 63
SAP
No
Error Event?
Yes
Map Error Event to ePOS event Invalid fiscal command. Critical error; cancelled printout Operational issue (i.e. printer out of paper)
No
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 27 of 63
SAP
Currently, two specific error scenarios have been determined for the Hungarian fiscal printer: An incorrect configuration of documents or master data, which cannot be resolved by the user exit. The fiscal printer automatically cancels the document and sets the printer in a monitoring state. The SAP Enterprise POS application displays a notification message of a cancelled transaction and aborts the transaction appropriately. This is mapped to an IDslConstant.DSL_FISCAL_ABORT_TRX event in SAP Enterprise POS. An ErrorEvent issued by the fiscal printer due to an operational issue, which can be corrected by the operator. The fiscal printer re-attempts to print the document. This is mapped to an IDslConst.DSL_FICAL_PROMPT_FOR_REPRINT event in SAP Enterprise POS.
Note: As all fiscal printer errors are mapped/generalized in the user exit to one of the two SAP Enterprise POS ErrorEvents listed above, other ErrorEvents may need to be introduced. Consequently, for each identified fiscal printer error, it must be determined if the error falls into one the two SAP Enterprise POS ErrorEvents or if a new ErrorEvent needs to be created/requested.
5 Configuration
5.1 Fiscal Printer User Exit Classname
To use your Fiscal Printer User Exit you must set the FiscalPrinterUserExit property in the device.properties file to the fully qualified class name of the Fiscal Printer User Exit implementation class. The device.properties file is located in the EPOS_HOME/custom/client/ folder. The FiscalPrinterUserExit property name is suffixed with a number, starting with one (1). Incrementing this number allows you to load multiple Fiscal Printer User Exits in the POS Clients. Example:
device.controls.1=com.triversity.transactionware.framework.deviceservices.triversity device.controls.2=com.triversity.transactionware.framework.deviceservices.ingenico device.controls.3=com.triversity.transactionware.framework.deviceservices.eftuserexit FiscalPrinterUserExit1=com.saptrv.te.userexit.fiscalprinter.FPDevice
In the above example, com.saptrv.te.userexit.fiscalprinter.FPDevice class should be replaced with the fully qualified class name of the Fiscal Printer User Exit implementation class.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 28 of 63
SAP
Add Triversity Jars to classpath CP=%CP%;.\security CP=%CP%;.\lib\tw-security.jar CP=%CP%;.\lib\was-stubs.jar CP=%CP%;.\lib\client-updates.jar CP=%CP%;.\lib\client.jar CP=%CP%;.\lib\editor.jar CP=%CP%;.\lib\te_clientsrvr.jar CP=%CP%;.\lib\loaderutil.jar CP=%CP%;.\lib\EFTUserExit.jar CP=%CP%;.\lib\FiscPrinter.jar CP=%CP%;.\lib\dsl.jar CP=%CP%;.\lib\dsllocal.jar CP=%CP%;.\lib\tef_logging.jar CP=%CP%;.\lib\tef.jar CP=%CP%;.\lib\ext\j2ee.jar CP=%CP%;.\lib\ext\jpos17.jar CP=%CP%;.\lib\ext\ib6core.jar
Ensure that all of the classes required for your implementation are present in the classpath by either adding a JAR file name or a fully qualified directory name containing all of your required classes to the POS Client classpath.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 29 of 63
SAP
~FISCAL(setPostLine, ||%code% - %department%) ~FISCAL(printRecItem, %description%, ~value(%price%), %quantity%, %taxcode%, ~value(%unitprice%), %unitOfMeasure%)
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 30 of 63
SAP
// deliver the event to all registered listeners int statusUpdateListenersSize = statusUpdateListeners.size(); for (int nListener = 0; nListener < statusUpdateListenersSize; nListener++) { statusUpdateListeners.get(nListener). statusUpdateOccurred(printerStatusUpdateEvent); } }
SAP Enterprise POS application then uses the FiscalPrinterListener class to access the current electronic journal of the POS Client and stores the fiscal document number in that object. In turn, the journal object is sent to the server; the JournalACO has a new property (TlogProperty. FISCAL_DOC_ID.getName(), journal.getFiscalDocId()) in the supplemental data property to store the fiscal document number. This also propagates the fiscal document number and saves it in the TLog.
Paragraph
String formName List<LineBuffer> paragraph Paragraph() Paragraph(List<LineBuffer>) Paragraph(String) Paragraph(String, List<LineBuffer>) void add(LineBuffer) void addAll(Paragraph) void clear() List<LineBuffer> getLines() String getName() int size()
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 31 of 63
SAP
The following example from the StandardSyncFiscalPrinterService implementation illustrates the usage of the Paragraph class. The code loops through all the LineBuffers contained in the paragraph and determines the type of line that should be printed. Paragraph firstForm = receipt.get(0); for (LineBuffer lb: firstForm.getLines()) { if (lb.getType() == LineBuffer.FISCAL) { if (lb.getText().startsWith("beginFiscal") || lb.getText().startsWith("setFiscalReceiptType")){ // New fiscal receipt isFiscalReceipt = true; } else if (lb.getText().equals("printXReport") || lb.getText().equals("printZReport") || lb.getText().equals("printPowerLossReport") || lb.getText().equals("printPeriodicTotalsReport") || lb.getText().equals("printReport")) { isFiscalReceipt = true; endingEvent = IDslFiscalPrinterConst.DSL_FPTR_SUE_IDLE; } else if (lb.getText().equals("beginTraining") || lb.getText().equals("endTraining")) { // Need to generate IDLE event at the end because beginTraining/ // endTraining triggers receipt printing but without output complete // event. isFiscalReceipt = true; endingEvent = IDslFiscalPrinterConst.DSL_FPTR_SUE_IDLE; } break; } }
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 32 of 63
SAP
6.5 ReceiptDescriptors
The ReceiptDescriptors class is used to contain the receipt formatting information. It must be used in the Fiscal Printer User Exit implementation of the Print method. It can include receipt margins, lines per page, whether or not there should be a paper cut, and whether or not the receipt contains sensitive data.
ReceiptDescriptors
int topMargin int leftMargin int linesPerPage boolean noPaperCut boolean sensitiveData ReceiptDescriptors() int getLeftMargin() int getLeftMargin() int getTopMargin() boolean isNoPaperCut() boolean isSensitiveData() void setLeftMargin(int) void setLinesPerPage(int) void setNoPaperCut(boolean) void setSensitiveData(boolean) void setTopMargin(int) String toString()
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 33 of 63
SAP
The following example from the StandardSyncFiscalPrinterService implementation illustrates the usage of the ReceiptDescriptors class. In this example, the value returned by the getLeftMargin method is passed as a parameter to the adjustAlignments method of the DocumentUtil method. The DocumentUtil method adjusts the alignments of the receipt to be printed.
.. .. ReceiptDescriptors descriptor = aDescriptor; .. .. case LineBuffer.TEXT: if (isFiscalReceipt) { // we have fiscal lines, so ignore this. continue; } line.setLength(0); line.append(lb.getText()); DocumentUtil.adjustAlignments(line, descriptor.getLeftMargin(), receiptWidth); DocumentUtil.replaceAttributes(line, substitutionsPrinter); DocumentUtil.expandCaretCharacter(line, receiptWidth); normalText.append(line.toString()).append("\n");
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 34 of 63
SAP
6.6 LineBuffer
The LineBuffer class is used to send a line to the printer. The line is based on the line definitions in the Configuration documents. A List of LineBuffers is an attribute of the Paragraph class that stores all the lines to be printed. One of the attributes of LineBuffer is Type, which sets the type of line to send to the printer. The following line types are permitted: TEXT BARCODE BITMAP MARKER REMOTE_FORM IMAGE PAUSE REPEAT TEXTAT FISCAL All lines sent to the fiscal printer should be of type FISCAL.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 35 of 63
SAP
LineBuffer
Attributes ABOVE AS_IS_WIDTH BARCODE BELOW BITMAP CENTER FISCAL IMAGE LEFT MARKER NO_ATTRIBUTE_SUBSTITUTION NONE PAUSE POSITION_TAG REMOTE_FORM REPEAT RIGHT ALIGNMENT_TAG TEXT TEXTAT TYPE_TAG_TEXT SERIAL_VERSION serialVersionUID STORE TEMPORARY alignment height multiUseVar1 multiUseVar2 multiUseVar3 multiUseVar4 parameters text type variables Operations decrementRepeatCount() getColumnt() getFormat() getHeight() getParameters() getPause() getRepeatCount() getRepeatOutputForm() getRow() getSymbology() getText() getTextPosition() getType() getVariables() getWidth() isNoAttributeSubstitution() isStoredOnly() isTemporary() readExternal(ObjectInput) setAlignment(int) setColumn(int) setFormat(String) setHeight(double) setNoAttributeSubstitution(boolean) setParameters(String[]) setPause(double) setRepeatCount(int) setPause(double) setRepeatOutputFrom(int) setRow(int) setStore(string) setSymbology(int) setText(String) setTextPosition(int) setType(int) setVariables(Map<String,Object)>) setWidth(double) toString() toXML(() writeExternal(ObjectOutput) getAlignment()
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 36 of 63
SAP
The following example from the StandardSyncFiscalPrinterService implementation illustrates the usage of the LineBuffer class. The code loops through all the LineBuffers contained in the paragraph and determines how the lines should be processed. for (LineBuffer lb: form.getLines()) { switch (lb.getType()) { case LineBuffer.FISCAL: if (isFiscalReceipt) { List<String> toParams = new ArrayList<String>(); String[] fromParams = lb.getParameters(); if (fromParams != null && fromParams.length > 0) { for (int i = 0; i < fromParams.length; i++) { toParams.add(fromParams[i]); } } boolean executed = executeFiscalFunction(lb.getText(), toParams); if (!executed) { errorOccurred = true; break; } } break; case LineBuffer.BARCODE: if (!isFiscalReceipt) { // Non-fiscal receipt: Delay barcode printing to the end endRequestList.add(lb); } else { printBarCode(aStationId, lb.getText(), getSymbology(lb.getSymbology()), 0 ,0 ,0); } break; case LineBuffer.TEXT: if (isFiscalReceipt) { // we have fiscal lines, so ignore this. continue; } 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 37 of 63
SAP
DocumentUtil.replaceAttributes(line, substitutionsPrinter); DocumentUtil.expandCaretCharacter(line, receiptWidth);\ normalText.append(line.toString()).append("\n"); } // switch (lb.getType()) { } // for (LineBuffer lb: form) {
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 38 of 63
SAP
Additionally, the signature of the execute method specifies, which exceptions may be thrown at runtime.
1
The Enhancement Concept for SAP Enterprise POS is not a one-to-one re-implementation of the ABAP BAdI concept, it is an adaptation of core BAdI concepts for a Java framework. 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 39 of 63
SAP
If a BAdI interface extends the interface IBAdIMulti, multiple BAdI interface implementations may be provided for the Enhancement Spot.
The Enhancement Concept Runtime executes the BAdI interface implementations synchronously and in sequence (in case of an Enhancement Spot with multiple implementations).
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 40 of 63
SAP
The following diagram shows the behavior of the EHC Framework at runtime:
SAP Core Development (SAP Enterprise POS)
Start of core application Execute core application Retrieve Configuration no Configuration available EnhancementSpot callBAdI() Configuration available Enhancement Spot Configuration default BAdI Implementation available Execute configured BAdI Implementation more configured BAdIs available Execute default BAdI Implementation no default BAdI Implementation available
Error occured
Error occured
no Error occured
no Error occured
Throw Exception
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 41 of 63
SAP
7.3.1 Prerequisites
The following table lists the requirements. Requirement Type Hardware Requirement Software Requirements Requirement Developer PC Java SE Development Kit JDK 5 Java IDE For example, SAP NetWeaver Development Studio, Eclipse or IDEs with comparable functionality SAP Enterprise POS 3.1 BAdI interfaces
7.3.2 Procedure
The following steps have to be performed: 1. Download and install the Java JDK. The JDK can be downloaded at http://www.oracle.com/technetwork/java/index.html. 2. Download and install the JAVA IDE. NWDS is part of the SAP NetWeaver delivery. Eclipse can be downloaded at http://www.eclipse.org. 3. Provide the JAR file containing the BAdI interfaces. The interfaces are bundled in the jar file sap.com~is~isr~epos~badi_interfaces~assembly.jar. The jar file is part of the SAP Enterprise POS 3.1. Software Component Archive (SCA) file. The SCA file is part of the SAP Enterprise POS 3.1 software delivery. 4. Provide the optional logging JAR files. The SAP EPOS proprietary logging API is contained in the jar file sap.com~is~isr~epos~tef_logging~assembly.jar. This file is also part of the SAP Enterprise POS 3.1. Software Component Archive (SCA) file. Note: The appropriate version of a j2ee.jar is also required if using the SAP logging API.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 42 of 63
SAP
Tip: Software Component Archives (SCA) files and Software Deployment Archives (SDA) files are zip files, which contain development artifacts such as resources, descriptors, and possibly a directory hierarchy with further JAR and SDA files. In order to extract the required resources from an SCA file or an SDA file, you may need to rename the source file from MySoftwareArchive.sca to MySoftwareArchive.zip. All jar files mentioned above can be found in: SAP Enterprise POS 3.1. Software Component Archive (SCA) file DEPLOYARCHIVES is~isr~epos~te_deliver.sda build lib or in one of the subdirectories.
7.4
The following sections describe the process of implementing a Java BAdI for Barcode printing on the Epson FP90 fiscal printer model by providing a sample implementation for the POS Client Print Barcode Enhancement Spot. Further information can be found in the Javadoc of the corresponding BAdI interface. Caution: The sample implementation described in this and the following subsections has been implemented in an Eclipsebased development environment (for example, SAP NetWeaver Development Studio or Eclipse Ganymede). Some steps may have to be adjusted for other IDEs. The sample implementation of the barcode printing BAdI interface is: package com.sap.epos.badi.interfaces.deviceservices; import com.sap.epos.badi.interfaces.IBAdI; import com.sap.epos.badi.interfaces.IBAdIContext; import com.sap.epos.badi.interfaces.IBAdIMulti; public interface IBAdIPackageBarcode extends IBAdI<IBAdIPackageBarcodeInput, IBAdIPackageBarcodeOutput>{ /** * Enhancement Spot executed while performing a POS Client Print barcode. * The Enhancement Spot is invoked when calling the print barcode method for a * fiscal printer. * The implementation has the ability to build the barcode format for the * target fiscal printer * @param IBAdILogOnInput input object available to the Enhancement Spot * implementation * @param IBAdILogOnOutput output object implementation uses to relay * information back to the core application */ public void execute(IBAdIContext<IBAdIPackageBarcodeInput, IBAdIPackageBarcodeOutput> context); public static final String BADI_DESCRIPTION = "Enhancement spot invoked when attempting to print a barcode on a Fiscal Printer."; } 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 43 of 63
SAP
Additionally, two interfaces are provided: one for the input and one for the output parameter. The interface for the input parameter is: package com.sap.epos.badi.interfaces.deviceservices; /** * The input object interface to the BAdI Enhancement spot invoked when a POS * Client print barcode is performed. * The implementation can perform further processing for the barcode printing */ public interface IBAdIPackageBarcodeInput { /** * Data to convert to a bar code. * @return some Text */ public String getBarcodeData(); /** * Retrieve the bar code symbology. * possible values. * @return a symbology type. */ public int getSymbology();
/** * The height of the barcode in printer dots. This value may be ignored by * the implementor. * @return the expected height of the barcode. */ public int getHeight(); /** * The width of the barcode in printer dots. This value may be ignored by the * implementor. * @return the expected width of the barcode. */ public int getWidth(); /** * The positioning of the barcode relative to the paper. * 0 - left aligned * 1 - centered * 2 - right aligned * The implementation may ignore this value. * @return the expected alignment of the barcode. */ public int getAlignment(); /** * The positioning of the text of the barcode, relative to the barcode. * 0 - none - don't display the text * 1 - below< 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 44 of 63
SAP
The interface for the output parameter is: package com.sap.epos.badi.interfaces.deviceservices; /** * The output object interface from the BAdI Enhancement spot invoked when a * POS Client print barcode is performed. The implementation can perform * further processing to build the barcode pertaining to the target fiscal * printer */ public interface IBAdIPackageBarcodeOutput { /** * Get the command to send as the first parameter of the directIO call. * @return an integer command. */ public int getCommand(); /** * Get the data to send as the second parameter of the directIO call. * @return the integer command array data. */ public int[] getCommandArray(); /** * Get the packaged Object that could be sent to the printer via a * directIO call to print a barcode of the given data. * @return a packaged Object suitable to send via a directIO call, or null if * it can't convert to a barcode. */ public Object getObject(); }
7.4.1
You must first create a new Java Project, which will be used for the creation of a new implementation for a BAdI interface. 1. Start the IDE. 2. Go to File New Java Project to create a new Java Project, enter the project name and press Next. 3. Add the BAdI interfaces to the build path of the Java Project: a. In the Package Explorer, right-click on the Java project and select Properties Java Build Path Libraries Add External Jars. b. Browse to select sap.com~is~isr~epos~badi_interfaces~assembly.jar. c. Browse to select sap.com~is~isr~epos~badi_interfaces~assembly.jar. d. Browse to select sap.com~is~isr~epos~te_framework~assembly.jar. e. Click OK. 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 45 of 63
SAP
4. Optionally, add the SAP EPOS logging API JAR to the build path of the Java Project. a. In the Package Explorer, right-click on the Java project and select Properties Java Build Path Libraries Add External Jars. b. Browse to select sap.com~is~isr~epos~tef_logging~assembly.jar. c. Browse to select j2ee.jar as the SAP logging API has dependencies on j2ee.jar classes. d. Click OK.
Recommendation: To avoid name clashes with existing or future SAP development objects, do not use com.sap (or any other prefixes used by SAP core Java objects) as a prefix for the package name of your BAdI implementation. Instead, you may want to use a prefix that reflects the purpose of the BAdI or that reflects your organization. It is also recommended to use the prefix BAdI for the class name of the BAdI implementation. Example: If you want to implement a BAdI for the POS Client Print Barcode Enhancement Spot: The sample BAdI interface name is com.sap.epos.framework.deviceservices.jpos.IBAdIPackageBarcode Chose com.yourcompanyname.epos.framework.deviceservices.jpos.yourprinter.packageBar code as package name Chose BarcodeSampleImpl as class name for the BAdI implementation
Having performed the above steps, the following result will be available: A new class: com.yourcompanyname.epos.framework.deviceservices.jpos.yourprinter.packageBar code.BarcodeSampleImpl has been created in your Java project. The class implements the BAdI interface: com.sap.epos.badi.interfaces.deviceservices.IBAdIPackageBarcode
The result should look like this: package com.yourcompanyname.epos.framework.deviceservices.jpos.yourprinter.packageBarcode; import jpos.FiscalPrinter; import jpos.FiscalPrinterControl17; 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 46 of 63
SAP
import import import import
public class BarcodeSampleImpl implements IBAdIPackageBarcode { public void execute(IBAdIContext<IBAdILogOnInput, IBAdILogOnOutput> context){ // TODO Auto-generated method stub } }
SAP
* Get the data to send as the second parameter of the directIO call. * * @return the integer command array data. */ public int[] getCommandArray() { return this.commArray; } /** * Get the packaged Object that could be sent to the printer via a directIO * call to print a barcode of the given data. * * @return a packaged Object suitable to send via a directIO call, or null * if it can't convert to a barcode. */ public Object getObject() { return this.buf; } public int setCommand() { return 1; } public int setCommandArray(int[] aCommand) { if (aCommand != null) { this.commArray = aCommand; } return 1; } public StringBuffer setBuffer(StringBuffer aBuf) { return this.buf = aBuf; } }
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 48 of 63
SAP
7.4.4
You must provide the business logic for your BAdI implementation within the execute method of your BAdI. At runtime, an instance of an IBAdIContext object is passed to the execute method by the EHC framework. This context object allows you to access the input parameter and to set an output parameter as a result.
The IBAdIContext interface provides the following methods: package com.sap.epos.badi.interfaces; /** * Interface definition representing the context of the BAdI execution. * This type shall be the only parameter of any BAdI interface method. * The BAdI implementer classes access the context functionality by the * methods of this interface. * @param <BAdIInput> data type of the input parameter of the BAdI * @param <BAdIOutput> data type of the output parameter of the BAdI */ public interface IBAdIContext<BAdIInput, BAdIOutput> { /** * Retrieves the input of the BAdI. It contains the current input value of * the BAdI execution, that can be the original value given by the standard * code, or the modified one if there were any preceding BAdI implementer * which modified it. * @return input */ public BAdIInput getInput(); /** * Stores the input of the BAdI into the context. It can be used when one * implementor wishes to modify the input. * @param input */ public void setInput(BAdIInput input); /** * Retrieves the output of the BAdI. This is null when no implementer have * set it yet, or contains the current value of the output. * @return output */ public BAdIOutput getOutput(); /** * Stores the output of the BAdI in the context. * @param output */ public void setOutput(BAdIOutput output); /** * Makes a proposal to terminate the BAdI execution. * @param terminationProposal */ public void setTerminationProposal(boolean terminationProposal); 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 49 of 63
SAP
/** * Retrieves proposal to terminate the BAdI execution * @return termination proposal */ public boolean getTerminationProposal(); /** * Retrieves the BAdI Interface class * @return BAdI Interface class */ public Class<? extends IBAdI<BAdIInput, BAdIOutput>> getBAdIInterface(); }
The following boxes show the sample BAdI implementation of the IBAdIBarcode interface for the Epson FP90 fiscal printer. The BarcodeSampleImpl implementation returns a barcode string which is built for the target fiscal printer. package com.yourcompanyname.epos.framework.deviceservices.jpos.yourprinter.packageBarcode; import jpos.FiscalPrinter; import jpos.FiscalPrinterControl17; import com.sap.epos.badi.interfaces.IBAdIContext; import com.sap.epos.badi.interfaces.deviceservices.IBAdIPackageBarcode; import com.sap.epos.badi.interfaces.deviceservices.IBAdIPackageBarcodeInput; import com.sap.epos.badi.interfaces.deviceservices.IBAdIPackageBarcodeOutput; import com.triversity.tef.util.logging.Log; import com.triversity.transactionware.framework.deviceservices.DeviceServiceException; import com.triversity.transactionware.framework.deviceservices.ScanDataType; import com.triversity.transactionware.framework.deviceservices.jpos.StandardFiscalPrinterS ervice; /** * Sample BAdI Implementation for the IBAdIBarcode interface, This * implementation will provide a sample implementation for the Fiscal Printer * Barcode printing. * */ public class BarcodeSampleImpl implements IBAdIPackageBarcode { protected static FiscalPrinterControl17 printer = new FiscalPrinter(); protected static StandardFiscalPrinterService printerService = new StandardFiscalPrinterService(); package com.saptest.epos.framework.deviceservices.jpos.epsonFP90.packageBarcode; import jpos.FiscalPrinter; 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 50 of 63
SAP
import jpos.FiscalPrinterControl17; import import import import com.sap.epos.badi.interfaces.IBAdIContext; com.sap.epos.badi.interfaces.deviceservices.IBAdIPackageBarcode; com.sap.epos.badi.interfaces.deviceservices.IBAdIPackageBarcodeInput; com.sap.epos.badi.interfaces.deviceservices.IBAdIPackageBarcodeOutput;
/** * Sample BAdI Implementation for the IBAdIBarcode interface, This * implementation will provide a sample implementation for the Fiscal Printer * Barcode printing. * */ public class BarcodeSampleImpl implements IBAdIPackageBarcode { protected static FiscalPrinterControl17 printer = new FiscalPrinter(); /** * Method will provide access to the default implementation for the * IBAdIBarcode as a result of the BAdIOutput. */ public void execute( IBAdIContext<IBAdIPackageBarcodeInput, IBAdIPackageBarcodeOutput> context) { IBAdIPackageBarcodeOutput output = new PackageBarcodeBitmapOutput(); IBAdIPackageBarcodeInput input = context.getInput(); output = buildBarcode(input); context.setOutput(output); } // end execute /** * @param ignoredStationId * one of IDeviceSet.DEVICE_RECEIPT, DEVICE_SLIP, DEVICE_JOURNAL * @param aSymbology * an index into the ConfigPOSConstants.symbologies table */ public static PackageBarcodeBitmapOutput buildBarcode(String data, int aSymbology, int ignoredHeight, int ignoredWidth, int ignoredAlignment, int ignoredTextPosition) throws Exception { PackageBarcodeBitmapOutput out = new PackageBarcodeBitmapOutput(); int[] command = { 1075 }; int code = -1; int wmax = 0; switch (aSymbology) { case 104: // ScanDataType.DSL_BCS_EAN13: code = 67; // 2 wmax = 5; break; case 103: // ScanDataType.DSL_BCS_EAN8: code = 68; // 3 wmax = 8; 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 51 of 63
SAP
break; case 101: // ScanDataType.DSL_BCS_UPCA: code = 65; // 0 wmax = 5; break; case 102: // ScanDataType.DSL_BCS_UPCE: code = 66; // 1 wmax = 8; break; case 108: // ScanDataType.DSL_BCS_CODE39: code = 69; // 4 // Max length is 30 data = data.substring(0, Math.min(data.length(), 30)); if (data.length() >= 16) wmax = 1; else if (data.length() >= 10) wmax = 2; else if (data.length() >= 7) wmax = 3; else if (data.length() >= 5) wmax = 4; else wmax = 8; break; case 106: // ScanDataType.DSL_BCS_ITF: // Interleaved 2 of 5 code = 70; // 5 // Max length is 54 data = data.substring(0, Math.min(data.length(), 54)); if (data.length() >= 32) wmax = 1; else if (data.length() >= 20) wmax = 2; else if (data.length() >= 16) wmax = 3; else if (data.length() >= 12) wmax = 4; else wmax = 8; break; case 107: // ScanDataType.DSL_BCS_CODABAR: code = 71; // 6 // Max length is 43 data = data.substring(0, Math.min(data.length(), 43)); if (data.length() >= 24) wmax = 1; else if (data.length() >= 16) wmax = 2; else if (data.length() >= 12) wmax = 3; else if (data.length() >= 10) wmax = 4; else if (data.length() >= 8) wmax = 5; else 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 52 of 63
SAP
wmax = 8; break; case 109: // ScanDataType.DSL_BCS_CODE93: code = 72; // Max length is 52 data = data.substring(0, Math.min(data.length(), 52)); if (data.length() >= 25) wmax = 1; else if (data.length() >= 15) wmax = 2; else if (data.length() >= 11) wmax = 3; else if (data.length() >= 8) wmax = 4; else if (data.length() >= 6) wmax = 5; else wmax = 8; break; case 110: // ScanDataType.DSL_BCS_CODE128: code = 73; // Max length is 45 data = data.substring(0, Math.min(data.length(), 45)); if (data.length() >= 21) wmax = 1; else if (data.length() >= 13) wmax = 2; else if (data.length() >= 9) wmax = 3; else if (data.length() >= 7) wmax = 4; else if (data.length() >= 5) wmax = 5; else wmax = 8; break; case 105: // ScanDataType.DSL_BCS_TF: case 120: // case ScanDataType.DSL_BCS_EAN128: default: // Not supported // log.warn("Barcode symbology " + aSymbology + " ported"); break; } if (code != -1) {
not
sup-
StringBuffer buf = new StringBuffer(); buf.append("01"); // Operator buf.append("068"); // Horizontal position in points buf.append(wmax); // Barcode Width buf.append("064"); // Barcode height in points buf.append("2"); // enabling printing HRI characters: 0=no // 1=sopra 2=sotto 3=sopra e sotto 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 53 of 63
SAP
buf.append("1"); // font for characters HRI (0-3) buf.append("00"); // Unused buf.append(code); // Barcode type buf.append(data); // Data out.setBuffer(buf); out.setCommandArray(command); } return out; } public static IBAdIPackageBarcodeOutput buildBarcode( IBAdIPackageBarcodeInput input) {
/** * * The list of JavaPOS symbology DSL_BCS_UPCA = 101; // * ScannerConst.SCAN_SDT_UPCA; // Digits DSL_BCS_UPCE = 102; // * ScannerConst.SCAN_SDT_UPCE; // Digits DSL_BCS_JAN8 = 103; // * ScannerConst.SCAN_SDT_JAN8; // = EAN 8 DSL_BCS_EAN8 = 103; // * ScannerConst.SCAN_SDT_EAN8; // = JAN 8 DSL_BCS_JAN13 = 104; // * ScannerConst.SCAN_SDT_JAN13; // = EAN 13 DSL_BCS_EAN13 = 104; // * ScannerConst.SCAN_SDT_EAN13; // = JAN 13 DSL_BCS_TF = 105; // * ScannerConst.SCAN_SDT_TF; // (Discrete 2 of 5) // Digits DSL_BCS_ITF = * 106; // ScannerConst.SCAN_SDT_ITF; // (Interleaved 2 of 5) // Digits * DSL_BCS_CODABAR = 107; // ScannerConst.SCAN_SDT_Codabar; // Digits, -, $, :, /, ., // +; * 4 start/stop // characters (a, b, c, // d) DSL_BCS_CODE39 = 108; // * ScannerConst.SCAN_SDT_Code39; // Alpha, Digits, Space, // -, ., $, /, +, %; // * start/stop (*) // Also has Full Ascii // feature DSL_BCS_CODE93 = * 109; // ScannerConst.SCAN_SDT_Code93; // Same characters as // Code * 39 DSL_BCS_CODE128 = 110; // ScannerConst.SCAN_SDT_Code128; // 128 * data characters DSL_BCS_UPCA_S = 111; // * ScannerConst.SCAN_SDT_UPCA_S; // UPC-A with // supplemental barcode * DSL_BCS_UPCE_S = 112; // ScannerConst.SCAN_SDT_UPCE_S; // UPC-E with // * supplemental barcode DSL_BCS_UPCD1 = 113; // * ScannerConst.SCAN_SDT_UPCD1; // UPC-D1 DSL_BCS_UPCD2 = 114; // * ScannerConst.SCAN_SDT_UPCD2; // UPC-D2 DSL_BCS_UPCD3 = 115; // * ScannerConst.SCAN_SDT_UPCD3; // UPC-D3 DSL_BCS_UPCD4 = 116; // * ScannerConst.SCAN_SDT_UPCD4; // UPC-D4 DSL_BCS_UPCD5 = 117; // * ScannerConst.SCAN_SDT_UPCD5; // UPC-D5 DSL_BCS_EAN8_S = 118; // * ScannerConst.SCAN_SDT_EAN8_S; // EAN 8 with // supplemental barcode * DSL_BCS_EAN13_S = 119; // ScannerConst.SCAN_SDT_EAN13_S; // EAN 13 * with // supplemental barcode DSL_BCS_EAN128 = 120; // * ScannerConst.SCAN_SDT_EAN128; // EAN 128 DSL_BCS_OCRA = 121; // * ScannerConst.SCAN_SDT_OCRA; // OCR "A" DSL_BCS_OCRB = 122; // * ScannerConst.SCAN_SDT_OCRB; // OCR "B" * // Two dimensional symbologies DSL_BCS_PDF417 = 201; // * ScannerConst.SCAN_SDT_PDF417; DSL_BCS_MAXICODE = 202; // * ScannerConst.SCAN_SDT_MAXICODE; * // Special cases DSL_BCS_VENDOR = 501; // 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 54 of 63
SAP
* ScannerConst.SCAN_SDT_OTHER; // Start of vendor- // specific bar code // * symbologies DSL_BCS_UNKNOWN = 0; // ScannerConst.SCAN_SDT_UNKNOWN; // * Cannot determine the // barcode symbology. * **/ IBAdIPackageBarcodeOutput output = null; PackageBarcodeBitmapOutput out = new PackageBarcodeBitmapOutput(); String aData = input.getBarcodeData(); int aSymbology = input.getSymbology(); int aIgnoredHeight = input.getHeight(); int aIgnoredWidth = input.getWidth(); int aIgnoredAlignment = input.getAlignment(); int aIgnoredTextPosition = input.getTextPosition(); try { out = buildBarcode(aData, aSymbology, aIgnoredHeight, aIgnoredWidth, aIgnoredAlignment, aIgnoredTextPosition); output = out; } catch (Exception e) { } return output; } }
The following boxes show the sample BAdI implementation of the IBAdIBarcode interface for the IBM 4610 fiscal printer.
package com.saptest.epos.framework.deviceservices.jpos.epsonFP90.packageBarcode; import jpos.FiscalPrinter; import jpos.FiscalPrinterControl17; import import import import com.sap.epos.badi.interfaces.IBAdIContext; com.sap.epos.badi.interfaces.deviceservices.IBAdIPackageBarcode; com.sap.epos.badi.interfaces.deviceservices.IBAdIPackageBarcodeInput; com.sap.epos.badi.interfaces.deviceservices.IBAdIPackageBarcodeOutput;
/** * Sample BAdI Implementation for the IBAdIBarcode interface, This * implementation will provide a sample implementation for the Fiscal Printer * Barcode printing. * */ public class BBoxBarcodeSampleImpl implements IBAdIPackageBarcode {
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 55 of 63
SAP
protected static FiscalPrinterControl17 printer = new FiscalPrinter(); /** * Method will provide access to the default implementation for the * IBAdIBarcode as a result of the BAdIOutput. */ public void execute( IBAdIContext<IBAdIPackageBarcodeInput, IBAdIPackageBarcodeOutput> context) { IBAdIPackageBarcodeOutput output = new PackageBarcodeBitmapOutput(); IBAdIPackageBarcodeInput input = context.getInput(); output = buildBarcode(input); context.setOutput(output); } // end execute public static IBAdIPackageBarcodeOutput buildBarcode( IBAdIPackageBarcodeInput input) { IBAdIPackageBarcodeOutput output = null; PackageBarcodeBitmapOutput out = new PackageBarcodeBitmapOutput(); String aData = input.getBarcodeData(); int aSymbology = input.getSymbology(); int aIgnoredHeight = input.getHeight(); int aIgnoredWidth = input.getWidth(); int aIgnoredAlignment = input.getAlignment(); int aIgnoredTextPosition = input.getTextPosition(); try { out = buildBarcode(aData, aSymbology, aIgnoredHeight, aIgnoredWidth, aIgnoredAlignment, aIgnoredTextPosition); output = out; } catch (Exception e) { } return output; } /** * @param ignoredStationId * one of IDeviceSet.DEVICE_RECEIPT, DEVICE_SLIP, DEVICE_JOURNAL * @param aSymbology * an index into the ConfigPOSConstants.symbologies table */ public static PackageBarcodeBitmapOutput buildBarcode(String data, int aSymbology, int ignoredHeight, int ignoredWidth, int ignoredAlignment, int ignoredTextPosition) throws Exception { /* * -----------------------------------------------------------------------------------------* The list of JavaPOS symbology DSL_BCS_UPCA = 101; // * ScannerConst.SCAN_SDT_UPCA; // Digits DSL_BCS_UPCE = 102; // 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 56 of 63
SAP
* * * * * * =
// Digits DSL_BCS_JAN8 = 103; // // = EAN 8 DSL_BCS_EAN8 = 103; // // = JAN 8 DSL_BCS_JAN13 = 104; // // = EAN 13 DSL_BCS_EAN13 = 104; // // = JAN 13 DSL_BCS_TF = 105; // (Discrete 2 of 5) // Digits DSL_BCS_ITF
* 106; // ScannerConst.SCAN_SDT_ITF; // (Interleaved 2 of 5) // Digits * * DSL_BCS_CODABAR = 107; // ScannerConst.SCAN_SDT_Codabar; // Digits, -, $, :, /, ., // +; * 4 start/stop // characters (a, b, c, // d) DSL_BCS_CODE39 = 108; // * * ScannerConst.SCAN_SDT_Code39; // Alpha, Digits, Space, // -, ., $, /, +, %; // * start/stop (*) // Also has Full Ascii // feature DSL_BCS_CODE93 = * 109; // ScannerConst.SCAN_SDT_Code93; // Same characters as // Code * 39 DSL_BCS_CODE128 = 110; // ScannerConst.SCAN_SDT_Code128; // 128 * data characters DSL_BCS_UPCA_S = 111; // * * ScannerConst.SCAN_SDT_UPCA_S; // UPC-A with // supplemental barcode * DSL_BCS_UPCE_S = 112; // ScannerConst.SCAN_SDT_UPCE_S; // UPC-E with // * supplemental barcode DSL_BCS_UPCD1 = 113; // * * ScannerConst.SCAN_SDT_UPCD1; // UPC-D1 DSL_BCS_UPCD2 = 114; // * ScannerConst.SCAN_SDT_UPCD2; // UPC-D2 DSL_BCS_UPCD3 = 115; // * ScannerConst.SCAN_SDT_UPCD3; // UPC-D3 DSL_BCS_UPCD4 = 116; // * ScannerConst.SCAN_SDT_UPCD4; // UPC-D4 DSL_BCS_UPCD5 = 117; // * ScannerConst.SCAN_SDT_UPCD5; // UPC-D5 DSL_BCS_EAN8_S = 118; // * ScannerConst.SCAN_SDT_EAN8_S; // EAN 8 with // supplemental barcode * DSL_BCS_EAN13_S = 119; // ScannerConst.SCAN_SDT_EAN13_S; // EAN 13 * with // supplemental barcode DSL_BCS_EAN128 = 120; // * * ScannerConst.SCAN_SDT_EAN128; // EAN 128 DSL_BCS_OCRA = 121; // * ScannerConst.SCAN_SDT_OCRA; // OCR "A" DSL_BCS_OCRB = 122; // * ScannerConst.SCAN_SDT_OCRB; // OCR "B" * // Two dimensional symbologies DSL_BCS_PDF417 = 201; // * ScannerConst.SCAN_SDT_PDF417; DSL_BCS_MAXICODE = 202; // * ScannerConst.SCAN_SDT_MAXICODE; * // Special cases DSL_BCS_VENDOR = 501; // * ScannerConst.SCAN_SDT_OTHER; // Start of vendor- // specific bar code // * symbologies DSL_BCS_UNKNOWN = 0; // ScannerConst.SCAN_SDT_UNKNOWN; // * Cannot determine the // barcode symbology. * */ PackageBarcodeBitmapOutput out = new PackageBarcodeBitmapOutput(); int[] command = { 0 }; int code = -1; switch (aSymbology) { case 104: // ScanDataType.DSL_BCS_EAN13: 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 57 of 63
SAP
code = break; case 103: // code = break; case 101: // code = break; case 102: // code = break; case 108: // code = // Max break; case 106: // code = break; case 107: // code = break; case 109: // code = break; case 110: // code = break; case 105: // case 120: // default: // Not break; }
2; // 2 ScanDataType.DSL_BCS_EAN8: 3; // 3 ScanDataType.DSL_BCS_UPCA: 0; // 0 ScanDataType.DSL_BCS_UPCE: 1; // 1 ScanDataType.DSL_BCS_CODE39: -1; // 4 length is 30 ScanDataType.DSL_BCS_ITF: // Interleaved 2 of 5 5; // 5 ScanDataType.DSL_BCS_CODABAR: 6; // 6 ScanDataType.DSL_BCS_CODE93: 8; ScanDataType.DSL_BCS_CODE128: 7; ScanDataType.DSL_BCS_TF: case ScanDataType.DSL_BCS_EAN128: supported
if (code != -1) { StringBuffer buf = new StringBuffer(); buf.append("PBC="); buf.append(code); buf.append(";"); buf.append(data); buf.append(";"); buf.append(";"); buf.append(";"); buf.append(";"); out.setBuffer(buf); out.setCommandArray(command); } return out; } }
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 58 of 63
SAP
Note: BAdI implementations may only throw exceptions that have been explicitly specified in the signature of the execute method of the BAdI interface. Throwing exceptions other than the specified ones will result in an undefined state of the application. If the BAdI interface does not specify an exception, a BAdI implementation must not throw an exception. Note: BAdI implementations must invoke the context.setOutput() method with the output from the implementation to make this output available to the relevant Enhancement Spots. Additionally, for IBAdIMulti BAdIs it may be appropriate to inspect the output of previous implementations (as shown in the IBAdILogOn examples). Tip: The context object provides the following setter and getter methods for a termination proposal: public void setTerminationProposal(boolean terminationProposal) public boolean getTerminationProposal() If an Enhancement Spot allows multiple implementations of the BAdI interface, these implementations are executed in sequence. An implementation may indicate that further processing is not necessary by setting a termination proposal. Other implementations can check the termination proposal and optionally decide to either: Accept the proposal and return without further processing of the request, or Continue executing
7.4.5
Once you have completed BAdI interface implementation(s) as described in the previous sections, you can prepare the implementation(s) for deployment. BAdI implementations are provided bundled as JAR files, with all BAdI implementations provided in a single JAR file whenever possible. If you are providing multiple JAR files, ensure that each BAdI implementation occurs only once, that is, that the different JAR files are disjunctive. To export the BAdI implementation in a JAR file: 1. In the Package Explorer, right-click on the Java project. 2. Optionally, add all required resources to the Java project. This is for BAdI implementations that need additional resources (for example, style sheets or images). 3. Select Export Jar Next. 4. Complete the steps of the Wizard and click Finish.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 59 of 63
SAP
7.4.6
There is a one-to-one relationship between an Enhancement Spot and the corresponding BAdI interface. The property file badi.properties is used to describe which BAdI implementation (or which BAdI implementations, in case of an Enhancement Spot that supports multiple implementations) to execute at runtime. Caution: A single badi.properties file must be used to configure all Enhancement Spots. In the badi.properties file, the fully qualified class name of the BAdI interface is used as the property name and represents the Enhancement Spot. The fully qualified class name of the implementing class of the BAdI interface represents the value. Caution: If an Enhancement Spot which supports a single BAdI implementation is configured with multiple implementations, the EHC framework will throw an exception and no implementation will be executed. In case of an Enhancement Spot which supports multiple implementations, the property value is a comma separated list of the fully qualified class names of the implementing classes. The sequence of the class names determines the sequence of the execution at runtime. To configure the EHC Framework to execute the right implementations for a BAdI interface: 1. Using the text editor of your choice, create the badi.properties file. 2. Add an entry for each Enhancement Spot you want to configure. For an Enhancement Spot that supports single BAdI implementations only, the format of the entry is: BAdIInterfaceName = ImplClass1 For an Enhancement Spot that supports multiple BAdI implementations, the format of the entry is: BAdIInterfaceName = ImplClass1, ImplClass2, 3. Save the badi.properties file to the <TE_HOME>/custom/lib/badi directory.
Example: Configuration for the POS Client Print Barcode Enhancement Spot.
com.sap.epos.badi.interfaces.deviceservices.IBAdIPackageBarcode= com.saptest.epos.framework.deviceservices.jpos. epsonFP90.packageBarcode.BarcodeSampleImpl
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 60 of 63
SAP
Caution: In the above example, the POS Client Print Barcode Enhancement Spot is configured to execute the BarcodeSampleImpl implementation of the IBAdIPackageBarcode interface. Note that the above configuration must be provided in a single line in the property file.
7.5
The second sample Java BAdI implementation provided is the POS Client Print Bitmap Enhancement Spot. This section describes how to implement the BAdI interface for Bitmap printing on the Epson FP90 printer model. The POS Client Print Bitmap Enhancement Spot allows implementations to qualify a POS Client Print Bitmap request. The implementation builds the bitmap format base on the target fiscal printer. The Epson FP90 fiscal printer does not support bitmap printing, therefore no sample implementation is provided here. Further information can be found in the Javadoc of the corresponding BAdI interface. The sample POS Client Print Bitmap Enhancement Spot BAdI interface is as follows: package com.sap.epos.badi.interfaces.deviceservices; import com.sap.epos.badi.interfaces.IBAdI; import com.sap.epos.badi.interfaces.IBAdIContext; public interface IBAdIPackageBitmap IBAdIPackageBitmapOutput>{ extends IBAdI<IBAdIPackageBitmapInput,
/** * Method execution provides functionality of the nhancement Spot. */ public void execute(IBAdIContext<IBAdIPackageBitmapInput, pOutput> context); IBAdIPackageBitma-
public static final String BADI_DESCRIPTION = "Enhancement spot invoked when attempting to print a bitmap on a Fiscal Printer."; } The interface for the input parameter is: package com.sap.epos.badi.interfaces.deviceservices; public interface IBAdIPackageBitmapInput { /** * File path to the bitmap. * @return a filename */ public String getFilename(); /** * The width of the barcode in printer dots, or -1 to print it as is. * This value may be ignored by the implementation. * @return the expected width of the bitmap, in dots, or -1. */ 2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010 Page 61 of 63
SAP
public int getWidth(); /** * The positioning of the bitmap relative to the paper. * 0 - left aligned * 1 - centered * 2 - right aligned * The implementation may ignore this value. * @return the expected alignment of the barcode. */ public int getAlignment(); }
The interface for the output parameter is: package com.sap.epos.badi.interfaces.deviceservices; public interface IBAdIPackageBitmapOutput { /** * Get the command to send as the first parameter of the directIO call. * @return an integer command. */ public int getCommand(); /** * Get the data to send as the second parameter of the directIO call. * @return the integer command array data. */ public int[] getCommandArray(); /** * Get the packaged Object that could be sent to the printer via a * directIO call to print a bitmap of the given data. * @return a packaged Object suitable to send via a directIO call, or null if * it can't print the bitmap. */ public Object getObject(); }
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 62 of 63
SAP
7.6
This guide describes the process of manually distributing and deploying the BAdI implementations. The BAdI implementations and the corresponding configuration must be distributed to all servers and clients. EHC Framework must be configured to be able to execute the right implementations for a BAdI interface. To manually distribute and deploy the BAdI implementations: 1. Stop the application. 2. Copy the JAR files with the BAdI implementations and the badi.properties file to the <TE_HOME>/custom/lib/badi directory. 3. Restart the application.
2010 SAP AG Title: SAP Enterprise POS Fiscal Printer User Exit Technical ReferDietmar-Hopp-Allee 16 ence Version: 1.0 D-69190 Walldorf Date: 11/24/2010
Page 63 of 63