You are on page 1of 10

Oracle Functional Services

Application Management Services


Generating and Printing QR Code from EBS

Author: Mohammed Arif


Creation Date: 30-Mar-2020
Last Updated: 08-Apr-2020
Version: 3.0

Copy Number _____


Document Control

Change Record
Date Author Version Change Reference
30-Mar-2020 Mohammed Arif 1.0 Initial Version
04-Apr-2020 Abraham Thomas 2.0 Reviewed and changed incorporated
08-Apr-2020 Abraham Thomas 3.0 Additional info on java library added

Reviewers & Approvers


Name Status
Abraham Thomas

Distribution
Copy No. Name Location

Document References
Sl No. Document Name Location
1
2
3
4
5
6

Note to holders:

If you receive an electronic copy of this document and print it out, please write your name on the cover
page, for document control purposes.

If you receive a hard copy of this document, please write your name on the front cover, for document
control purposes.

Company Confidential - For internal use only Contents ii


Contents

1 Introduction................................................................................................5
1.1 About This Document.............................................................................5
1.1.1 About Oracle Functional Services................................................5
2 QR Code - Requirement...............................................................................6
3 Set Up.........................................................................................................8
3.1 Code Files................................................................................................8
4 Implementation........................................................................................10
4.1 Generating the QR Code.......................................................................10
4.2 Using the QR Code during Invoice Print................................................10
5 Known Issues.............................................................................................11

Company Confidential - For internal use only Contents iii


1. Introduction
1. About This Document
The purpose of this document is to guide Engineers from Oracle Functional Services Team with the
steps to generate and print QR Code from EBS. QR Code is a requirement for India GST Invoicing.

1. About Oracle Functional Services


OFS (Oracle Functional Services) is an organization under Advanced Customer Services, providing
dedicated Application Support of Software Applications to customers all over the world.

Company Confidential - For internal use only Set Up 4 of 10


2. QR Code - Requirement

QR Code Printing on Invoices in EBS was necessitated by the new directives from Tax Authorities in
India with respect to GST

The data/string for generation of QR code will be initiated by Invoice Registration Portal (IRP) on
successful e-registration of the invoice.  The legislative update patch planned will support the
features of capturing the inbound information received back as per prescribed way in our
application.  Means the string for generation of QR code will be available once the e-invoice process
is completed.

e-invoice generation process includes:

Generate Tax invoice from ERP :  The legislative update patch will support user configurable options
for customers to opt for e-invoice generation process for B2B supplies which is applicable for tax
payers having turnover more than one hundred crore of rupees

User will have an option to extract the invoice information as per Government prescribed schema
where all mandatory information will be captured and the same will be processed as an xml file in a
batch mode

GST Suvidha Providers (GSP) are expected to pull this outbound file generated from ERP

GSP need to convert the data received into prescribed json file format and communicate the same to
IRP as per the prescribed process using the API's provided by IRP

GSP to receive back the feedback received from IRP and decrypt the same

GSP to send back specified inbound information received back from IRP

Customer is required to run a process in ERP which will append the tax invoices with inbound
information received back from GSP and complete the tax invoice generation process in ERP.

The GSP is at Customer’s choosing. 

Oracle India Localization will not provide any out of the box solution for printing the tax invoice.  Tax
payers will have to customize the invoice printing as per their business requirements and all the
mandatory data points required for printing the tax invoice will be made available in the applications.

Based on the above, QR Code generation with the below details is required to be generated.

o GSTIN of the supplier

o GSTIN of the recipient

o Invoice number given by the supplier

o Date of the generation of invoice

o Invoice value

o Number of line items

o HSN Code of the main item

o Unique Invoice Reference Number/Hash

Company Confidential - For internal use only Set Up 5 of 10


Subsequently the generated QR code should be printed on the Invoice PDF copy. This QR Code
should be available for scanning by external applications like mobile applications or other Interface
API.

Company Confidential - For internal use only Set Up 6 of 10


3. Set Up
1. Code Files

Code files required depends on your Java Version

QR Code Generation using java code is already developed and is available in published repositories
of Maven Community.

The java files requires are Core-x.x.jar, javase-x.x.jar and qrgen-1.x.jar

https://repo1.maven.org/maven2/net/glxn/qrgen/

At the command line of the EBS MT server the below command will give the version

Java – version

For 1.7 version, the compatible file versions are

core-1.7.jar

https://mvnrepository.com/artifact/com.google.zxing/core/1.7

javase-1.7.jar

https://mvnrepository.com/artifact/com.google.zxing/javase/1.7

qrgen-1.2.jar

https://repo1.maven.org/maven2/net/glxn/qrgen/1.2/

Upload all jar archives in lib folder $COMMON_TOP/java/lib and execute loadjava command in
database:
loadjava -force -genmissing -r -user apps/password@instance -verbose core-1.7.jar
loadjava -force -genmissing -r -user apps/password@instance -verbose javase-1.7.jar
loadjava -force -genmissing -r -user apps/password@instance -verbose qrgen-1.2.jar

Create a java procedure to call the qrcode generation related code from the class file
net.glxn.qrgen.QRCode
use the image type from net.glxn.qrgen.image.ImageType

declare a ByteArrayOutputStream variable and collect the QRCODE Image into this variable

ByteArrayOutputStream invqr = new ByteArrayOutputStream();


invqr = net.glxn.qrgen.QRCode.from(value).to(ImageType.GIF).stream();

//Sample Code: You can save this as a .jvs file

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "XXVRTQRBean" as


import oracle.sql.BLOB;
import oracle.sql.*;
import oracle.jdbc.driver.*;
import java.sql.*;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;

Company Confidential - For internal use only Set Up 7 of 10


import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.*;
import java.util.*;
import net.glxn.qrgen.QRCode;
import net.glxn.qrgen.image.ImageType;

public class XXVRTQRCodeGenerator{

static OracleDriver ora = new OracleDriver();


static Connection conn;
static ByteArrayOutputStream invqr;
static {
try {
conn = ora.defaultConnection();
}
catch(Exception ex){}
}

public static BLOB XXVRTgetQrCode(String value) throws Exception


{

if (conn == null) conn = ora.defaultConnection();


BLOB retBlob = BLOB.createTemporary(conn, true,
oracle.sql.BLOB.DURATION_SESSION);

ByteArrayOutputStream invqr = new ByteArrayOutputStream();


invqr = net.glxn.qrgen.QRCode.from(value).to(ImageType.GIF).stream();

try {
java.io.OutputStream outStr = retBlob.setBinaryStream(0);
outStr.write(invqr.toByteArray());
outStr.flush();
} finally {
invqr.close();
}
return retBlob;
}
}
/

connect to EBS database as APPS and execute the java stored procedure.

Once the stored Procedure is compiled, create a database function to call the java
procedure

//Sample Code
CREATE OR REPLACE function XXVRT_getQRImage(p_text in varchar2) return BLOB as
LANGUAGE JAVA
NAME 'XXVRTQRCodeGenerator.XXVRTgetQrCode(java.lang.String) return
oracle.sql.BLOB';
/

Company Confidential - For internal use only Set Up 8 of 10


4. Implementation
1. Generating the QR Code
Connect to database and execute the below command
Sample Select statement
select XXVRT_getQRImage(‘12344’||’Customer Name”) from dual;

Sample Anonymous Block

declare
qrCode Blob;
v_Invoice_num Varchar2(100);
v_invoice_id number;
begin
select trx_number into v_Invoice_num from ra_customer_trx_all where
customer_trx_id=v_invoice_id;
qrCode := XXVRT_getQRImage(v_Invoice_num);
end;

2. Using the QR Code during Invoice Print


Here Invoice details are taken in to an xml output, and using RTF Template, a pdf output is
published.

Within the RTF, Blob has to be converted to CLOB as BLOB is not supported. For the same simple
code as below can be used.

FUNCTION XXVRT_blob2clob( p_source BLOB )


RETURN CLOB
IS
v_result CLOB;
BEGIN
DBMS_LOB.createtemporary(lob_loc => v_result, CACHE => FALSE, dur => 0);
Wf_Mail_Util.EncodeBLOB ( p_source, v_result);
RETURN ( v_result );
END XXVRT_blob2clob;

While generating the XML tags in the code use the above function and pass BLOB object so
that the returned CLOB object is passed to RTF.

output_line('<QRCODE>' || xx_getbase64(header.qrcode) || '</QRCODE>');

Use the below command in the field in the RTF to print the QRCode. Please find the below
sample code and RTF and sample output.

<fo:instream-foreign-object content-type="image/jpg"> <xsl:value-of


select=".//QRCODE"/>

Company Confidential - For internal use only Set Up 9 of 10


5. Known Issues

Company Confidential - For internal use only Set Up 10 of 10

You might also like