Академический Документы
Профессиональный Документы
Культура Документы
Prepared by:
Sumana Mukherjee
&
Suvrajyoti Bandyopadhyay
Page of 20 1
Contents
Overview:......................................................................................................... 2
Main Components of a Report Builder:.............................................................3
Report Customization steps:............................................................................ 8
Steps to change the report output to a Pipe delimited output:........................8
Page of 20 2
Overview:
In this tutorial, we will see how to customize the existing standard Oracle
report to get a delimited output file instead of the regular layout. Most
business users prefer delimited report output as it can easily be imported
into Excel where they can manipulate and perform calculations on the
data easily.
Report Builder is the tool used to develop/customize Oracle reports.
Before getting into the details, I would like to give an overview about
Report Builder.
Main Components of a Report Builder:
Below is the snapshot of the Object navigator when you open a report in
Report Builder. Some important components are Data Model, Layout
Model, Parameter form, Triggers. Lets discuss about each one of them in
detail.
Data Model:
The Data Model is a work area in which you define what data to
retrieve when the report is submitted. You create and define queries,
groups, columns, parameters, and links which are called data model
objects to determine what data needs to be extracted from the
database as part of a report.
Page of 20 3
Description
Select
Magnify
To Magnify an area
SQL Query
RefCursor
Query
Page of 20 4
Summary
Column
Formula Column
Cross Product
Data Link
Placeholder
Column
To Create a Placeholder column. A placeholder is a column for which you set the
datatype and value in PL/SQL that you define. You can set the value of a
placeholder column in the following places:
Before Report Trigger, if the placeholder is a report-level column
report-level formula column, if the placeholder is a report-level column
a formula in the placeholders group or a group below it (the value is set once for
each record of the group)
Layout Model:
Layout Model is a work area in which you can define the format (using
objects like frames, repeating frames, fields, boilerplate, anchors, and
Graphics objects) of your report output. When you run a report, Report
Builder uses the Layout Model as a default template for the report
output.
Page of 20 5
Select Tool
Frame Select To select frame or repeating frame and all the objects within them.
Rotate
To rotate Objects
Reshape
Magnify
Line
To draw a line
Rectangle
Rounded
Rectangle
Ellipse
10
Arc
To draw arc
11
Polyline
12
Polygon
13
Text
14
Freehand
Page of 20 6
Frame
To create a frame. Frames are used to surround other objects and protect them from
being overwritten or pushed by other objects
16
Repeating
Frame
To create a repeating frame. Repeating frames surround all of the fields that are
created for a groups columns meaning each repeating frame must be associated
with a group created in the Data model. The repeating frame prints (is fired) once
for each record of the group.
17
Link file
18
Field
To create a field
19
Chart
To create a Chart
20
Button
To create a button
21
Anchor
To create an anchor between two objects. Since the size of some layout objects may
change when the report runs, you need anchors to define where you want objects to
appear relative to one another.
22
OLE2
15
Parameter Form:
Parameter Form enables you to define the parameters for your report.
Tool Palette:
Report Triggers:
Report triggers execute PL/SQL functions at specific times during the
execution and formatting of your report. Report Builder has five global
report triggers:
o
After Parameter Form trigger:
This trigger fires after the Parameter form is displayed.
o
After Report trigger:
This trigger fires after the report output is displayed. You can use
this trigger to delete any temporary values or tables created during
the process.
o
Before Parameter Form trigger:
This trigger fires before the Parameter form is displayed.
Page of 20 7
Page of 20 8
To achieve this:
We have to get rid of the current layout and create a new layout
with 2 objects:
Frame to print the header information.
Repeating Frame to print the data.
We need to create a Formula column in the Data model that will get
the concurrent programs output filename. We will use this file to write
our pipe delimited report output to.
Steps:
1.
Download the original report POXRVRTN.rdf
Page of 20 9
2.
3.
Page of 20 10
1.
Click
in the tool palette
Click and drag a rectangle.
Page of 20 11
Page of 20 12
1.
2.
Page of 20 13
Page of 20 14
Page of 20 15
Page of 20 16
1.
To print a pipe delimited text in the output file, we will use a format
trigger on the frame and repeating frame.
A format trigger is a PL/SQL function executed before an object is
formatted. This function must return a Boolean value (TRUE or FALSE).
Depending on whether the function returns TRUE or FALSE, the current
instance of the object is included or excluded from the report output.
Format trigger can be used to highlight a value, for suppressing values
and labels.
In the property palette of the Frame, under Advanced Layout section:
Page of 20 17
Double Click on the Format Trigger. This opens up a SQL Editor, where you
can place the below code to print the header information to the output
file.
function M_SHIPMENT_LINE_HDRFormatTrigg return boolean is
Variable declaration
cmd_line VARCHAR2(3000);
v_file_name text_io.file_type;
begin
Setting cmd_line variable to the header info
cmd_line := Vendor Name||~'||PO Number||~'||PO Line||~'||Po
Line Description||~'||Item
Number||~'||Category||~'||Organization||~'||Ship To
Location||~'||Qty Ordered||~'||Net Qty Received||~'||Qty
Billed||~'||Qty Accepted||~'||Qty Rejected||~'||Qty
Cancelled||~'||Received Qty Corrected||~'||Net Qty RTV||~'||Qty
RTV Corrected||~'||Receipt Num||~'||Transaction
Date||~'||Transaction Type||~'||Parent Transaction||~'||Transaction
amount||~'||Unit;
Opening the concurrent requests output file to write the data into it
Always prefix : with the field,when you refer to a field in the data
model like
:C_OUTPUT_FILE
v_file_name := TEXT_IO.FOPEN(:C_OUTPUT_FILE, A);
IF TEXT_IO.IS_OPEN(v_file_name) THEN
TEXT_IO.PUT_LINE(v_file_name, cmd_line);
END IF;
TEXT_IO.FCLOSE(v_file_name);
If the return value is true then only this object will be included in the
report output
return (TRUE);
end;
Page of 20 18
Similarly include the below code in the format trigger of the repeating
frame to write the receipt records into the output file.
function R_shipment_linesFormatTrigger return boolean is
cmd_line VARCHAR2(2000);
v_file_name text_io.file_type;
begin
cmd_line :=
:Source||~'||:Document_Number||~'||:Line||~'||:Description||~'||:C_
FLEX_ITEM_DISP||~'||:C_FLEX_CAT_DISP||~'||:Organization_name||~'
||:Ship_To_Location||~'
||:Quantity_Ordered||~'||:C_qty_net_rcvd||~'||:qty_billed||~'||:qty_ac
cepted||~'||:qty_rejected||~'||:qty_cancelled||~'||:C_qty_corrected||
~'||:C_qty_rtv_and_corrected||~'||:C_qty_corrected_rtv||~'||:Receipt_
Number||~'||:Receipt_Date||~'||:Transaction_Type||~
||:Parent_Transaction_Type||~'||:Transaction_Quantity||~'||:Transaction
_Unit;
v_file_name := TEXT_IO.FOPEN(:C_OUTPUT_FILE, A);
IF TEXT_IO.IS_OPEN(v_file_name) THEN
TEXT_IO.PUT_LINE(v_file_name, cmd_line);
END IF;
TEXT_IO.FCLOSE(v_file_name);
return (TRUE);
end;
1.
2.
1.
Page of 20 19
1.
2.
Page of 20 20