标签:des style blog http color os io for
利用这种方式的优点是不需要跑请求就可以打印报表
工具包中常用程序说明
htp.print
语法 htp.print (cbuf | dbuf | nbuf);Generates Generates a line in an HTML document based on the value passed to it.
them are also available as hypertext functions (HTF).
Generates </HTML>
Generates <HEAD>
Generates </HEAD>
background="background.gif">
available as hypertext functions (HTF).
ERP REPORT
Generates </TABLE>
Generates <TR ALIGN="calign" VALIGN="cvalign" DP="cdp" NOWRAP catttributes>
Generates </TR>
http://www.lnu.edu.cn/book/oracleweb/ows402.htm
一个例子
<span style="font-size:18px;">PROCEDURE CUXTS001(
p_header_id IN VARCHAR2 default null,
p_org_id IN VARCHAR2 default null
)
AS
---declare the data source
------Report page parameters
v_row_num NUMBER;
v_first_flag NUMBER := 0; -----标志
x_count NUMBER; -------总行数
v_page_rows NUMBER := 1; ------定义每张报表的line数量
v_page_count NUMBER;
v_page_width NUMBER := 800;
v_font_size NUMBER := 2;
v_page_num NUMBER := 1;
v_line_count NUMBER := 0;
v_jes NUMBER := 0;
v_dis_no NUMBER := 0;
max_line NUMBER := 7;
----------------------------------------------------
t_qty NUMBER := 0;
t_amount NUMBER := 0;
x_org_name VARCHAR2 (100);
x_sum_count_no NUMBER := 0;
----采购题头
CURSOR c_header
IS
SELECT pha.segment1 po_num,
pha.po_header_id,
pha.type_lookup_code,
pha.agent_id,
pha.comments,
ppf.full_name full_name,
pha.creation_date,
ERP REPORT
pv.vendor_id,
SUBSTR (pv.vendor_name, 1, 38) vendor_name
FROM po_headers_all pha,
po_vendors pv,
per_people_f ppf
WHERE pha.vendor_id = pv.vendor_id
AND pha.agent_id = ppf.person_id
AND pha.org_id = TO_NUMBER (p_org_id)
AND pha.po_header_id = p_header_id;
----行信息
CURSOR c_line (x_header_id NUMBER)
IS
SELECT pda.destination_subinventory,
pll.quantity,
pla.line_num,
pla.unit_meas_lookup_code,
pla.unit_price,
pla.item_description item_desc,
pll.quantity * pla.unit_price amount,
pla.po_header_id,
pll.shipment_num,
msi.segment1 item,
pll.need_by_date need_by,
pll.ship_to_organization_id,
pll.promised_date,
pll.note_to_receiver,
ood.organization_code
FROM po_lines_all pla,
po_distributions_all pda,
po_line_locations_all pll,
mtl_system_items_b msi,
financials_system_params_all fsp,
org_organization_definitions ood
WHERE pla.po_line_id = pda.po_line_id
AND pll.line_location_id = pda.line_location_id
AND (pll.closed_code = 'OPEN' OR pll.closed_code IS NULL)
AND pla.item_id = msi.inventory_item_id(+)
AND pla.po_header_id = x_header_id
AND NVL (msi.organization_id, fsp.inventory_organization_id) =
fsp.inventory_organization_id
ERP REPORT
AND fsp.org_id = p_org_id
AND pll.ship_to_organization_id = ood.organization_id(+)
;
BEGIN
fnd_client_info.set_org_context(p_org_id);
HTP.htmlopen;
HTP.p ('<head>');
HTP.p ('<STYLE>');
HTP.p (' P { page-break-before: always }');
HTP.p ('</STYLE>');
HTP.p ('</head>');
HTP.bodyopen;
FOR lc_h IN c_header
LOOP
---title2
HTP.tableopen (
cattributes=> 'cellspacing=0 cellpadding=15 border=0 width='
|| v_page_width
|| ' bgcolor="#000000"'
);
HTP.tablerowopen (cattributes => 'bgcolor="#ffffff"');
HTP.tabledata (
cvalue=> '<font size="'
|| 3
|| '"> <b><U>采 购 单 据</b></U>',
cattributes=> 'width="16%"',
calign=> 'center'
);
HTP.tablerowclose;
HTP.tableclose;
---header
HTP.tableopen (
cattributes=> 'cellspacing=0 cellpadding=4 border=0 width='
|| v_page_width
|| ' bgcolor="#000000"'
);
HTP.tablerowopen (cattributes => 'bgcolor="#ffffff" height="8"');
ERP REPORT
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> 采购单号:'
|| lc_h.po_num,
cattributes=> 'width="15%"',
calign=> 'left'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> 采购类型:'
|| lc_h.type_lookup_code,
cattributes=> 'width="20%"',
calign=> 'left'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> 采购日期:'
|| TO_CHAR (lc_h.creation_date, 'YYYY/MM/DD'),
cattributes=> 'width="20%"',
calign=> 'left'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '">采购员:'
|| lc_h.full_name,
cattributes=> 'width="15%"',
calign=> 'left'
);
HTP.tablerowclose;
HTP.tableclose;
HTP.tableopen (
cattributes=> 'cellspacing=0 cellpadding=4 border=0 width='
|| v_page_width
|| ' bgcolor="#000000"'
);
HTP.tablerowopen (cattributes => 'bgcolor="#ffffff"');
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '">供应商:'
ERP REPORT
|| lc_h.vendor_name,
cattributes=> 'width="20%"',
calign=> 'left'
);
HTP.tablerowclose;
HTP.tableclose;
HTP.tableopen (
cattributes=> 'cellspacing=0 cellpadding=2 border=0 width='
|| v_page_width
|| ' bgcolor="#000000"'
);
HTP.tablerowopen (cattributes => 'bgcolor="#ffffff"');
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '">备注:'
|| lc_h.comments,
cattributes=> 'width="20%"',
calign=> 'left'
);
HTP.tablerowclose;
HTP.tableclose;
-- line
BEGIN
HTP.tableopen (
cattributes=> 'border="1" borderColorDark="#FFFFFF"
borderColorLight="#000000" cellPadding="0" cellSpacing="0" width='
|| v_page_width
|| ' '
);
HTP.tablerowopen (cattributes => 'bgcolor="#ffffff"');
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"><b> 项目</b></font>',
calign=> 'center',
cattributes=> 'width=18%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"><b> 货物名称</b></font>',
ERP REPORT
calign=> 'center',
cattributes=> 'width=22%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"><b> 单位</b></font>',
calign=> 'center',
cattributes=> 'width=6%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"><b> 采购单价</b></font>',
calign=> 'center',
cattributes=> 'width=8%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"><b> 数量</b></font>',
calign=> 'center',
cattributes=> 'width=7%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"><b> 金额</b></font>',
calign=> 'center',
cattributes=> 'width=13%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"><b> 需要日期</b></font>',
calign=> 'center',
cattributes=> 'width=10%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"><b> 仓库</b></font>',
calign=> 'center',
cattributes=> 'width=8%'
ERP REPORT
);
HTP.tablerowclose;
SELECT COUNT (pla.po_line_id)
INTO v_jes
FROM po_lines_all pla,
po_distributions_all pda,
po_line_locations_all pll,
mtl_system_items_b msi,
financials_system_params_all fsp,
org_organization_definitions ood
WHERE pla.po_line_id = pda.po_line_id
AND pll.line_location_id = pda.line_location_id
AND (pll.closed_code = 'OPEN' OR pll.closed_code IS NULL)
AND pla.item_id = msi.inventory_item_id(+)
AND pla.po_header_id = lc_h.po_header_id
AND NVL (msi.organization_id, fsp.inventory_organization_id) =
fsp.inventory_organization_id
AND fsp.org_id = p_org_id
AND pll.ship_to_organization_id = ood.organization_id(+);
FOR lc_l IN c_line (lc_h.po_header_id)
LOOP
HTP.tablerowopen (cattributes => 'bgcolor="#ffffff"');
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> '
|| '&'
|| 'nbsp'
|| lc_l.item,
calign=> 'left',
cattributes=> 'width=16%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> '
|| '&'
|| 'nbsp'
|| lc_l.item_desc,
calign=> 'left',
cattributes=> 'width=22%'
ERP REPORT
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> '
|| '&'
|| 'nbsp'
|| lc_l.unit_meas_lookup_code,
calign=> 'left',
cattributes=> 'width=6%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> '
|| '&'
|| 'nbsp'
|| lc_l.unit_price,
calign=> 'right',
cattributes=> 'width=12%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> '
|| '&'
|| 'nbsp'
|| lc_l.quantity,
calign=> 'right',
cattributes=> 'width=7%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> '
|| '&'
|| 'nbsp'
|| lc_l.amount,
calign=> 'right',
cattributes=> 'width=13%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
ERP REPORT
|| '"> '
|| '&'
|| 'nbsp'
|| TO_CHAR (lc_l.PROMISED_DATE, 'YYYY/MM/DD'),
calign=> 'center',
cattributes=> 'width=10%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> '
|| '&'
|| 'nbsp'
|| lc_l.organization_code,
calign=> 'center',
cattributes=> 'width=6%'
);
t_qty := t_qty
+ lc_l.quantity;
t_amount := t_amount
+ lc_l.amount;
END LOOP;
v_jes := max_line
- v_jes;
LOOP
EXIT WHEN v_jes <= 0;
HTP.tablerowopen (cattributes => 'bgcolor="#ffffff"');
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> <b>'
|| '&'
|| 'nbsp'|| ' ' ,
calign=> 'center',
cattributes=> 'width=18%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> <b>'
|| '&'
ERP REPORT
|| 'nbsp' || ' ',
calign=> 'center',
cattributes=> 'width=22%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> <b>'
|| '&'
|| 'nbsp' || ' ',
calign=> 'center',
cattributes=> 'width=6%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> <b>'
|| '&'
|| 'nbsp' || ' ',
calign=> 'center',
cattributes=> 'width=8%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> <b>'
|| '&'
|| 'nbsp' || ' ',
calign=> 'center',
cattributes=> 'width=7%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> <b>'
|| '&'
|| 'nbsp' || ' ',
calign=> 'center',
cattributes=> 'width=13%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> <b>'
ERP REPORT
|| '&'
|| 'nbsp' || ' ',
calign=> 'center',
cattributes=> 'width=10%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> <b>'
|| '&'
|| 'nbsp' || ' ',
calign=> 'center',
cattributes=> 'width=8%'
);
v_jes := v_jes
- 1;
END LOOP;
--sum
HTP.tablerowopen (cattributes => 'bgcolor="#ffffff"');
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> <b>'
|| '合计',
calign=> 'center',
cattributes=> 'width=18%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> <b>'
|| '&'
|| 'nbsp' || ' ',
calign=> 'center',
cattributes=> 'width=22%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> <b>'
|| '&'
|| 'nbsp' || ' ',
calign=> 'center',
ERP REPORT
cattributes=> 'width=6%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> <b>'
|| '&'
|| 'nbsp',
calign=> 'center',
cattributes=> 'width=8%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> '
|| '&'
|| 'nbsp'
|| t_qty,
calign=> 'right',
cattributes=> 'width=7%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> '
|| '&'
|| 'nbsp' || ' '
|| t_amount,
calign=> 'right',
cattributes=> 'width=13%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> '
|| '&'
|| 'nbsp' || ' ',
calign=> 'right',
cattributes=> 'width=10%'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> '
ERP REPORT
|| '&'
|| 'nbsp' || ' ',
calign=> 'right',
cattributes=> 'width=8%'
);
HTP.tablerowclose;
HTP.tableclose;
END;
HTP.tableopen (
cattributes=> 'cellspacing=0 cellpadding=8 border=0 width='
|| v_page_width
|| ' bgcolor="#000000"'
);
HTP.tablerowopen (cattributes => 'bgcolor="#ffffff"');
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '"> 打印人:',
cattributes=> 'width="10%"',
calign=> 'left'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '">部门主管:',
cattributes=> 'width="10%"',
calign=> 'left'
);
HTP.tabledata (
cvalue=> '<font size="'
|| v_font_size
|| '">总经理:',
cattributes=> 'width="10%"',
calign=> 'left'
);
HTP.tablerowclose;
HTP.tableclose;
END LOOP;
HTP.tableclose;
HTP.bodyclose;
HTP.htmlclose;
END; </span>
开发好后注册程序:
路径:系统管理员->安全性->WEB PL/SQL
然后在需要的地方调用就可以直接打印出报表
DECLARE
v_command VARCHAR2 (200);
v_org_id NUMBER := fnd_profile.VALUE ('ORG_ID');
BEGIN
v_command := fnd_profile.VALUE ('APPS_WEB_AGENT');
v_command := v_command || '/CUXTS001?p_header_id=' || :submit.header_id;
v_command := v_command || '&p_org_id=' || TO_CHAR (v_org_id);
web.show_document (v_command, '_blank');
END; 标签:des style blog http color os io for
原文地址:http://blog.csdn.net/cai_xingyun/article/details/38640847