Create a barcode report for paper
---------------------------------

To create a package for storing your information:

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


To create a Before Report trigger:

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


To create the query:

SELECT ALL CUSTOMERS_A1.CUST_FIRST_NAME, 
CUSTOMERS_A1.CUSTOMER_ID, CUSTOMERS_A1.CUST_LAST_NAME,
CUSTOMERS_A1.CUST_ADDRESS.STREET_ADDRESS,
CUSTOMERS_A1.CUST_ADDRESS.POSTAL_CODE, 
CUSTOMERS_A1.CUST_ADDRESS.CITY,
CUSTOMERS_A1.CUST_ADDRESS.STATE_PROVINCE, 
CUSTOMERS_A1.CUST_ADDRESS.COUNTRY_ID, ORDERS.ORDER_ID,
ORDERS.ORDER_DATE, 
ORDERS.ORDER_TOTAL, ORDER_ITEMS.LINE_ITEM_ID,
PRODUCTS.PRODUCT_NAME, 
ORDER_ITEMS.UNIT_PRICE, ORDER_ITEMS.QUANTITY,
COUNTRIES.COUNTRY_NAME
FROM CUSTOMERS CUSTOMERS_A1, ORDER_ITEMS, ORDERS,
PRODUCTS, HR.COUNTRIES
WHERE ((ORDER_ITEMS.ORDER_ID = ORDERS.ORDER_ID)
AND (ORDERS.CUSTOMER_ID = CUSTOMERS_A1.CUSTOMER_ID)
AND (ORDER_ITEMS.PRODUCT_ID = PRODUCTS.PRODUCT_ID)
AND (CUSTOMERS_A1.CUST_ADDRESS.COUNTRY_ID =
HR.COUNTRIES.COUNTRY_ID)) 
AND ORDERS.ORDER_ID = :P_ORDER_ID
ORDER BY order_ID, line_item_ID


To create the first formula column:

function CF_1Formula return Char is
  myFilename varchar2(20);
  result varchar2(20);
  barcodeData VarChar2(50) := :customer_ID ||:order_ID;
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;

To create the second formula column:

function LineTotalFormula return Number is
begin
  return (:quantity * :unit_price);
end;


Create a barcode report for the Web
-----------------------------------

To create a query in an existing HTML file:

SELECT ALL CUSTOMERS_A1.CUST_FIRST_NAME,
CUSTOMERS_A1.CUSTOMER_ID, CUSTOMERS_A1.CUST_LAST_NAME,
CUSTOMERS_A1.CUST_ADDRESS.STREET_ADDRESS,
CUSTOMERS_A1.CUST_ADDRESS.POSTAL_CODE,
CUSTOMERS_A1.CUST_ADDRESS.CITY,
CUSTOMERS_A1.CUST_ADDRESS.STATE_PROVINCE,
CUSTOMERS_A1.CUST_ADDRESS.COUNTRY_ID,
ORDERS.ORDER_ID, ORDERS.ORDER_DATE, ORDERS.ORDER_TOTAL,
COUNTRIES.COUNTRY_NAME FROM CUSTOMERS CUSTOMERS_A1, ORDERS,
HR.COUNTRIES
WHERE ((ORDERS.CUSTOMER_ID = CUSTOMERS_A1.CUSTOMER_ID)
AND (CUSTOMERS_A1.CUST_ADDRESS.COUNTRY_ID = HR.COUNTRIES.COUNTRY_ID))
AND ORDERS.ORDER_ID = :P_ORDER_ID ORDER BY order_ID 


To create the TrackingNumber formula column:

function TrackingNumberFormula return char is
begin
    return(:Customer_id||:Order_ID||:country_ID);
end;


To create the OriginScan formula column:

function OriginScanFormula return char is
begin
return('34324-OH-US');
end;


To create the DestinationScan formula column:

function DestinationScanFormula return char is
begin
return(:postal_code||'-'||:state_province||'-'||:country_ID);
end;


To initialize the JavaBean:

<jsp:useBean id="BC" scope="page" class="oracle.apps.barcode.util.BarCodeConstants" />
<jsp:useBean id="BM" scope="page" class="oracle.apps.barcode.BarCodeMaker" />


To set the barcode JavaBean properties:

<jsp:setProperty name="BM" property="BarCodeType" value="<%= BC.BAR_CODE_128 %>" />
<jsp:setProperty name="BM" property="BarWidthInch" value="0.01"/>
<jsp:setProperty name="BM" property="Directory" value="<%= BarcodePhysicalPath %>"/>


To define the barcode variables

<%! private String BarCodeData1 = "12345-XX-XX"; %>
<%! private String BarCodeData2 = "12345-XX-XX"; %>
<%! private String BarCodeData3 = "12345-XX-XX"; %>


To create a For Each loop:

<rw:foreach id="R_G_SHIPMENT" src="G_SHIPMENT">

</rw:foreach>


To code the formula columns to render the barcodes:

<!-- Get the value of the TrackingNumber and assign it to the variable -->
<rw:getValue id="BarCodeData1" src="TrackingNumber"/>
<!-- Set the data for tbe barcode and the filename -->
<jsp:setProperty name="BM" property="BaseCodeData" value="<%= BarCodeData1 %>"/>
<jsp:setProperty name="BM" property="FileName" value="<%= BarCodeData1 %>"/>
<!-- Render the barcode -->
<% BM.renderBarCode(); %>
<!-- View the image in the page -->
<img src="assets/barcodes/<%= BarCodeData1 %>">


<!-- Get the value of the OriginScan and assign it to the variable -->
<rw:getValue id="BarCodeData2" src="OriginScan"/>
<!-- Set the data for tbe barcode and the filename -->
<jsp:setProperty name="BM" property="BaseCodeData" value="<%= BarCodeData2 %>"/>
<jsp:setProperty name="BM" property="FileName" value="<%= BarCodeData2 %>"/>
<!-- Render the barcode -->
<% BM.renderBarCode(); %>
<!-- View the image in the page -->
<img src="assets/barcodes/<%= BarCodeData2 %>">


<!-- Get the value of the DestinationScan and assign it to the variable -->
<rw:getValue id="BarCodeData3" src="DestinationScan"/>
<!-- Set the data for tbe barcode and the filename -->
<jsp:setProperty name="BM" property="BaseCodeData" value="<%= BarCodeData3 %>"/>
<jsp:setProperty name="BM" property="FileName" value="<%= BarCodeData3 %>"/>
<!-- Render the barcode -->
<% BM.renderBarCode(); %>
<!-- View the image in the page -->
<img src="assets/barcodes/<%= BarCodeData3 %>">

