Quick Reference to Building a Paper Report with a Barcode JavaBean

Quick Reference to Building a Paper Report with a Barcode JavaBean

Quick Reference to Building a Paper Report with a Barcode JavaBean

Titleimage

Posted by Patrick Hamou on 2017:09:19 23:55:04

APPLIES TO: Oracle Reports Developer

Oracle Reports Developer - Version 10.1.2.0.0 to 11.1.2.2.0 [Release 10gr2 to 11g]
Information in this document applies to any platform.
"Checked for relevance on 7-Apr-2014"
 

GOAL: Paper Report, Barcode JavaBean

This Note is a Quick Reference to build a Paper Report with a Barcode JavaBean.

Important Information for Version 11g : The steps in this document are related to the barcode java bean. Reports Version 11g has a very important enchancement in this area and these steps are not required if you are using (or if you upgrade to) version 11g. Release 11g of Reports on linux/unix platforms can read font metric information directly from the ttf files just like Windows platforms and there are barcode available as ttf files for Windows that can be used instead. For more details please see :

Note:852698.1 "How to Use TTF Fonts for Font Metrics On Unix With Reports 11g?"

If you are using Reports version 10gR2 and below
or 
if you are using Reports 11g and desire to use the barcode bean as in 10.1.2.x , 

please continue with the steps below in this document 

SOLUTION: Barcode Javabean demo

Download the Barcode Javabean demo from OTN.

1) Unzip the contents of the zip file into a directory.

2) Edit the reports.sh file, and add the path of the oraclebarcode.jar to the REPORTS_CLASSPATH variable in the
reports.sh file.
For example :

REPORTS_CLASSPATH = /oracle/usupport/dev9i/reports/barcode/scripts/oraclebarcode.jar

3) Create a simple report based on emp table using barcode bean.
These are the steps:

a) Launch Report Builder and click on Program -> Import Java classes.

b) Select oracle.apps.barcode.util.BarCodeConstants, then click Import.Once the packages have been created,
import the second JavaBean: oracle.apps.barcode.BarCodeMaker.

c) Make sure the corresponding program units are created.

d) Create a Package named Globals as follows:

 

PACKAGE globals IS
bcobj ora_java.jobject;
barcode_to_use varchar2(256);
tempdir varchar2(100);
directory_sep varchar2(2);
END;



e) Save the report and then create a BeforeReport Trigger as follows:
 

begin
globals.barcode_to_use := BarCodeConstants.BAR_CODE_128;
globals.bcobj := barcodemaker.new();
return (TRUE);
end;

f) Save the report and then create a query in data model with SQL "select * from emp" using the scott schema.

g) Drag the deptno column down into a detail group.


4) Create formula column (CF_1) in the master as follow :

a) In the Data Model view, click the Formula Column tool in the tool palette.

b) Click in the master group (the main group that still contains most of the column names) 
to create a new formula column.

c) Double-click the new formula column object (CF_1) to display the PropertyInspector, and set properties:

Under Column, set the Datatype property to Character.
Under Placeholder/Formula, click the PL/SQL Formula property field to display the PL/SQL Editor.

d) In the PL/SQL Editor, use the template to enter the following PL/SQL code:
 

function CF_1Formula return VarChar2 is
myFileName varchar2(500);
result varchar2(500);
barcodeData VarChar2(50) := :empno || :deptno;
begin
myFileName := srw.create_temporary_filename;
barcodemaker.setBarWidthInch(globals.bcobj, 0.005);
barcodemaker.setBaseCodeData(globals.bcobj,barcodeData);
barcodemaker.setBarCodeType(globals.bcobj,globals.barcode_to_use);
barcodemaker.setFullPath(globals.bcobj, myFileName);
barcodemaker.renderBarCode(globals.bcobj);
return(myFileName);
end;

e)Under Column, set the Read from File property to Yes, and set the File Format property to Image.

5) Now create a Paper layout using the Report Wizard. Choose the Group above option as Style.

Save the report and run it from Builder to check if this works.

In the repserv.conf file, add the classPath as follows:

 

<engine id="rwEng" class="oracle.reports.engine.EngineImpl" initEngine="1" 
maxEngine="1" minEngine="0" engLife="50" maxIdle="30" callbackTimeOut="60000" 
classPath="/oracle/usupport/dev9i/reports/barcode/scripts/oraclebarcode.jar">

Restart Report Server. Run the report using the Report Server

6) For Reports 10g (9.0.4) set the REPORTS_DEFAULT_DISPLAY=NO and define the DISPLAY variable
in unix environments, because the barcode java bean require a valid display.

Return to Blog