Sunday, April 20, 2008

Applying Barcode in oracle forms and reports

Forms configuration
1- copy the jar file in the forms/java directory
2-add the jar file name to archivjinit
3-add the path jar to the registery of the windows ( forms_builder_classpath)
4- add the full path of the jar in forms_classpath in the default.env file
5-create file in the c:\temp 'image.jpg'
6-import the following two java class into your form ( oracle.apps.barcode.util.barcodeconstant --------------- barcodemaker)
7-create a procedure or function that generate the barcode

function xxx return Char is bcobj ora_java.jobject := barcodemaker.new();
myfilename varchar2(20); result varchar2(20);
barcodeData VarChar2(50) := :serialnumbertobeconverted;
begin
barcodemaker.setBarWidthInch(bcobj, 0.005);
barcodemaker.setBaseCodeData(bcobj,barcodeData);
barcodemaker.setBarCodeType(bcobj,BarCodeConstants.BAR_CODE_128);
myfilename := barcodeData;
barcodemaker.setFullPath(bcobj, myFileName);
barcodemaker.renderBarCode(bcobj);
return(myfilename);
end;
The jar file name (oraclebarcode.jar)
-------------------------------------------------------------------------
Reports configuration
1- set the report_temp registery key as c:\temp
2-edit the windows environment variables -- add to the user variables ( REPORTS_TEMP) MUST BE CAPITAL to allow the report server to access teh temp direcotry
3- copy the jar file to (home\reports\jilib)
4- edit your reports server con file add line to the tags and classpath=full path in the jilib --- the full path must be in double qoutation
5-restart the report server
6-include the path of the jar in the report class path registery key to allow to the report builder to import the java classes
7- create new report and import the mentioned above (infroms confgiuration) to your report , then create a formula column and set its pl/sql code as follow:
function CF_1Formula return char is
bcobj ora_java.jobject := barcodemaker.new();
myfilename varchar2(20); result varchar2(20);
barcodeData VarChar2(50) := :empno;
begin
myFileName :=srw.create_temporary_filename;
barcodemaker.setBarWidthInch(bcobj, 0.005);
barcodemaker.setBaseCodeData(bcobj,barcodeData);
barcodemaker.setBarCodeType(bcobj,BarCodeConstants.BAR_CODE_128);
myfilename := barcodeData;
barcodemaker.setFullPath(bcobj, myFileName);
barcodemaker.renderBarCode(bcobj);
return(myfilename);
end;

8- after that create a field and set its source to your formula and after that set " read from file" to yes and "file format" to image
9- run your report
---###############################################################

1 comment:

Abdelrahman kholidi said...

in cannot find oracle .apps .barcode
into java class please help me